= Linux Hands - On = Through this hands-on you will install Ubuntu Server on a vm. == Setting up virtualbox == === Installation of virtualbox and Downloading Ubuntu iso image === - Download and install virtualbox 6.x - [https://ubuntu.com/download/server] Ubuntu image from the website (Ubuntu Server 22.04.1 LTS) - Also you can download the iso file from following link : [https://url.ac.lk/hHJsYUfw] Ubuntu image (Ubuntu Server 22.04 LTS) === Creating the VM === - Start virtualbox and Click on '''New''' button to create new virtual machine - Enter name of the VM as: '''ubuntuserver'''. - Select OS Type: '''Linux''' - Select Version: '''Ubuntu (64-bit)''' - Then click on '''Continue''' button - Set VM's memory size to '''4096MB''' and click on Continue button - Set VM's hard disk option to '''Create a virtual hard disk now''' and then click on '''Continue''' - Select disk type to '''VDI''' - Select storage type to '''Fixed size''' and '''Continue''' - adjust the disk size to '''50.0GB''' and click on '''Create''' to create the VM This might take couple of minutes (Note down the location of vdi image file when virtualbox flashes it on the screen) === Setting up Network Interface === - Select the VM from left panel on Virtual box, right click and open '''Settings''' - Click on the '''Network''' title - On '''Adapter 1''' While ''Enable'' Network Adapter selected choose Attached to be '''Bride Adapter''', then select the name of the network (please select only LAN connection, later it will help you to access switches) This virtual interface will work as the WAN port of the firewall (Can be connect from out side). [[Image(network_bidge_adapter.png, 600px, nolink)]] === Setting up boot device and Booting=== - Click on '''Storage''' title and select '''CD ROM icon''' with Caption "Empty" under the '''Controller:IDE''', Click on CD ROM icon under the '''Attribute''' on the left side to select - Choose '''Virtual Optical Disk File''' - Locate the '''Ubuntu CD Image''' file you downloaded from the above mentioned link. Press OK to close the settings window. - Right click on VM and select Start to make a '''Normal Start'''. You should now see a separate window with Installation screen" [[Image(storage.png, 600px, nolink))]] == Installation Method 1== === Initial Installation options === - Select '''English''' as language for the installation wizard - Select '''Continue without updating''' - Select '''Done''' for keyboard configuration - Select '''Done'''' for Network connection (it will automatically assign an IP address) - Select '''Done''' for Proxy settings - Select '''Done''' for Guided storage configuration (check if it uses the entire disk) - Select '''Continue''' for confirm destructive actions Note that it configure network with DHCP - Type host name as: '''LibreNMS or iCinga''' - When it asked, add a User by entering Your '''Name, your username, password''' (Please give a strong password. This VM will be directly exposed to the internet) === Final Configuration === SSH Setup - Select only OpenSSH server (select by pressing space) - Select '''Done''' to continue Features server snaps Select '''Done''' as the final setup of installation Select '''Reboot''' VM now should restart with the newly installed OS. You may now login using your credentials == Installation Method 2 == === Initial Installation options === - Select '''English''' as language for the installation wizard - Select '''Continue without updating''' - Select '''Done''' for keyboard configuration - Select '''Done'''' for Network connection (it will automatically assign an IP address) - Select '''Done''' for Proxy settings - Select '''Custom storage layout''' to create LVM Storage configuration window will now appear. Here, we will find FILE SYSTEM SUMMERY, AVAILABLE DEVICES and USED DEVICES sections. In AVAILABLE DEVICES section, we will find our devices. In the following image, we can see our available device is /dev/sda or VBOX_HARDDISK_ and its storage size is 50GB. Now we will do LVM partition on this disk drive. In Linux system, we need to create minimum (/boot) boot, swap and (/) root partition. But we will do more two partitions also – (/home) and (/var) because these two partitions are frequently used in Enterprise Linux System. [[Image(boot.png, 600px, nolink)]] Among these partitions, /boot and swap should be out of LVM. So, at first we will do these two partitions before creating LVM. === Create boot partition === - Select the available device by pressing Up and Down arrow key and then hit Enter key. A popup option will appear. - Select Add GPT Partition option and hit Enter key. Now options will appear to manage a GPT Partition. - From Adding GPT Partition to /dev/ sda or freespace section, Put size (for example: 512M) for the boot partition in Size input box. - Choose partition format (for example: ext4) from Format drop down menu. - Choose /boot from Mount drop down menu. - Now select Create option and hit Enter key. [[Image(512m boot.png, 600px, nolink)]] === Create swap partition === We will now create swap partition following the below steps. - Select the storage device by pressing up and down arrow key again and the hit Enter key. - Select Add GPT Partition option and hit Enter key. Now options will appear to create a new GPT Partition. - From Adding GPT Partition to /dev/sda or freespace section, Put size (for example: 1G) for the swap partition in Size input box. - Choose swap from the Format drop down menu. - Now select Create option and hit Enter key. [[Image(swap.png, 600px, nolink)]] Now we will create LVM partition because rest of our partitions will keep under LVM. So, at first, we have to make unformated storage before creating LVM partition. === Creating LVM Volume Group === Now we will create LVM partition because rest of our partitions will keep under LVM. So, at first, we have to make unformated storage before creating LVM partition. - Select Add GPT Partition option and hit Enter key. Now options will appear to create a new GPT Partition. - From Adding GPT Partition to /dev/sda section, Put size (for example: 8G) for the LVM partition in Size input box. - Choose leave unformatted from Format drop down menu. - Now select Create option and hit Enter key. [[Image(unformat.png, 600px, nolink)]] === Creating LVM Volume Group (VG) === - From AVAILABLE DEVICES section, select Create volume group (LVM) option and hit Enter key. Create LVM volume group option will appear. - By default the system will provide (vg0) for the volume group name. Change it from Name input field or keep the default one if you wish. - Now select partition option from Devices section and press Space key to enable it. - Select Create option and hit Enter key. [[Image(lvm.png, 600px, nolink)]] === Creating LVM Root (/) Partition === - Select the created volume group (vg0) by pressing up and down arrow key again and the hit Enter key. - Select Create Logical Volume option and hit Enter key. Now options will appear to create new logical volume. - From Adding logical volume to vg0section, put the volume name (for example: lv-root) in Name input field. - Put size (for example: 4G) for the root partition in Size input box. - Choose partition format (for example: xfs) from Format drop-down menu. - Now select Create option and hit Enter key. [[Image(lvm_root_creation.png, 600px, nolink)]] Similarly, create /home and /var LVM partition from volume group vg0. After creating Home and Var partition, the FILE SYSTEM SUMMERY will look the following image. [[Image(after_creation.png, 600px, nolink)]] Now select the Done option and hit Enter key. The system will now ask to confirm the destructive action because after creating and formatting partition, no previous data can be found in this storage device. Select Continue and hit Enter key to confirm the action. [[Image(continue.png, 600px, nolink)]] === Profile Setup === The installer will now ask to provide profile information where we have to provide username, password and other personal information like the following image. [[Image(profile_setup.png, 600px, nolink)]] === SSH setup === In the last step, the installer will ask whether it will install SSH server or not. As we wish to install SSH server, select the Install OpenSSH Server option and press Space key to enable it. Select Done option and hit Enter key to start installation. [[Image(ssh_setup.png, 600px, nolink)]] === Finalizing Ubuntu Server Installation === The system will now start installing Ubuntu kernel and other required packages and within few minutes, the Ubuntu Server installation will be completed. We can see installation log while installing the Ubuntu Server. [[Image(installing.png, 600px, nolink)]] After Installation Hit "reboot now" to restart the server.