Thursday, November 28, 2024

Adding Space to an Ubuntu VM

I ran out of space on an Ubuntu VM today and had to go through the process of expanding the hard drive. 

  1. First, we shut down the VM and reconfigured VMware to let it have a larger hard drive. 
  2. Another thing to note is that we used the default settings when configuring the disk when installing Ubuntu.
  3. 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.
  4. When it finished booting, we used GParted to expand the partition to use the extra space on the drive.
  5. Then we ejected the ISO and booted up as normal.
  6. 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
  7. 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
A simple df -h later and we could see that the drive now had access to the extended space.

No comments:

Post a Comment