Linux
The VM template have 50GB by default which is usually not enough. Once the VM have setup with additional hard disk space, the actual root disk may still have only 50GB, you needs to add the additional space with LVM to make root disk able to use it
To do this, please follow the below steps. The below steps are dangerous, you should follow the steps carefully under run though the whole steps.
Type “lsblk” to see what is the disk name, for example, the above picture already shows that we need to work with sda, because root disk “/” is under sda3. Follow Steps will assume you are working with “sda”.
Type “sudo fdisk /dev/sda”, this will get you into the fdisk tool, the tool used for format and partitioning the hard disk
Type “n” to add a new partition, we will need to create a new partition with all new available space. It will ask you the setting, all you need to do is just pressing enter and use the default setting instead, usually this should create a new partition called sda4. After that, press “w” and enter, this will write the table and exit the tool to confirm the setting. Press Ctrl+C to quit the tool if it didn’t quit.
Type “sudo pvcreate /dev/sda4” to make the new partition as new physical volume.
Now, type “sudo vgs” to check the VG name and remember it, usually it should named “ubuntu-vg”
Now, type “sudo vgextend ubuntu-vg /dev/sda4” to add /dev/sda4 into this VG. You should see the VG is now extended with newly added partition with “sudo vgdisplay”
Now, type “sudo lvs”, here should will see the system LV name, usually called “
ubuntu-lv”
The actual LV path usually format as /dev/mapper/[VG path]-[LV path], do for the above case, LV actual path is /dev/mapper/ubuntu—vg-ubuntu—lv. Type “sudo lvextend -l +100%FREE /dev/mapper/ubuntu—vg-ubuntu—lv” to extend all free space to the LV level volume.
Finally, you get free LV volume able to add to the root disk, and resize it at file system level. Type “sudo resize2fs /dev/mapper/ubuntu—vg-ubuntu—lv”, the root disk will now extended successfully, and I will recommend you restart the server once at this stage.