Skip to content

Increase the Size of a Linux Disk in VirtualBox

March 26, 2014

After running out of space on a VirtualBox, I searched for some instructions on how to expand the size of the drive. I found a couple of good descriptions, such as this one, and this other one, both which are very similar.

Both of these instructions conclude with you happily finding the extra space when restarting your virtual machine. For me, this was a sadder experience. Once I rebooted the machine, it still showed the same amount of space. The reason was that the storage on my VM is managed by LVM, and although the physical space was expanded, the logical volume still needed to be extended in order for the system to use it.

This HOWTO reference explains how to extend a logical volume, and I used the following steps:

$ # Extend the volume to consume all of the free physical space
$ sudo lvextend -l +100%FREE /dev/mapper/vg_agent-lv_root
$ # Resize the filesystem to the logical volume size
$ sudo resize2fs /dev/mapper/vg_agent-lv_root

Here /dev/mapper/vg_agent-lv_root was the name of the root filesystem as reported by df. I was able to run these commands on the already mounted filesystem (they worked without requiring an unmount). After running the two commands, my root filesystem joyfully showed the correct full size.

No comments yet

Leave a Reply

Your email address will not be published. Required fields are marked *