I ran out of space on an Ubuntu VM today and had to go through the process of expanding the hard drive.
- First, we shut down the VM and reconfigured VMware to let it have a larger hard drive.
- Another thing to note is that we used the default settings when configuring the disk when installing Ubuntu.
- We downloaded the ISO for GParted. This is an entirely self contained OS with Gparted installed (along with a few other tools) and mounted it in the optical drive of the VM and booted it up.
- When it finished booting, we used GParted to expand the partition to use the extra space on the drive.
- Then we ejected the ISO and booted up as normal.
- Since we used the default options when installing Ubuntu, it uses a logical volume. We expanded the logical volume to encompass the new expanded size of the partition on the physical (virtual) drive using this:
sudo lvextend -l 100%VG ubuntu-vg-/ubuntu-lv - Then we increased the size of the file system to use the available space in the logical volume using this:
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv