---
# System prepended metadata

title: How to increase the hard disk size of the VM? (Ubuntu default setup as example)

---

###### tags: `Linux`
# How to increase the hard disk size of the VM? (Ubuntu default setup as example)


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
 ![](https://hackmd.io/_uploads/rkG9fwX23.png)

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.

1.	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”.

2.	Type “sudo fdisk /dev/sda”, this will get you into the fdisk tool, the tool used for format and partitioning the hard disk
 ![](https://hackmd.io/_uploads/Hkq5zDXnn.png)

3.	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.
 ![](https://hackmd.io/_uploads/B17sMwX2n.png)

4.	Type “sudo pvcreate /dev/sda4” to make the new partition as new physical volume.
5.	Now, type “sudo vgs” to check the VG name and remember it, usually it should named “ubuntu-vg”
 ![](https://hackmd.io/_uploads/H1tiMPX23.png)

6.	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”
 ![](https://hackmd.io/_uploads/Hy6sMwX3n.png)

7.	Now, type “sudo lvs”, here should will see the system LV name, usually called “
ubuntu-lv”
 ![](https://hackmd.io/_uploads/HyfhfDm3h.png)

8.	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.
 ![](https://hackmd.io/_uploads/ryU2fDQn3.png)

9.	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.
 ![](https://hackmd.io/_uploads/Sks3GDm22.png)



