Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running CentOS 6.1 as a guest in VirtualBox 4.1.18 on a Mac OS X (Snow Leopard) host. Since 50 GB for my CentOS guest proved to be insufficient, I resolved to double its available disk space. After extensively searching the internet for a viable course of action, I settled on the following:

  1. Double size of VDI file through "vboxmanage modifyhd centos6.1.vdi --resize 102400"
  2. Verify in VirtualBox GUI that disk size is now indeed 100 GB
  3. Download Parted Magic ISO file and boot VM into Parted Magic
  4. In Parted Magic, fire up Partition Editor
  5. In Partition Editor, see ~ 50 GB of "unallocated" space
  6. In Partition Editor, resize /dev/sda2 (managed by LVM in my case) to use up all unallocated space, effectively increasing its size by 50 GB
  7. Shut down VM
  8. Boot VM into CentOS 6.1 and use lvm tools to grow existing volumes.

However, I fail at step 5. Partition Editor shows /dev/sda's size to still be 50 GB, NOT 100 GB. There is no "unallocated" space I could use to grow /dev/sda2's size. This is consistent with the output of fdisk -l, run either in Parted Magic or CentOS:

[root@dev ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes  
255 heads, 63 sectors/track, 6527 cylinders  
Units = cylinders of 16065 * 512 = 8225280 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes  
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disk identifier: 0x0006702c

Device Boot Start End Blocks Id System  
/dev/sda1 * 1 32 256000 83 Linux  
Partition 1 does not end on cylinder boundary.  
/dev/sda2 32 6528 52171776 8e Linux LVM

In step 2 above, I verified that VirtualBox' GUI does indeed show my VM's virtual hard drive to be 100 GB in size. Could someone explain why neither fdisk nor Parted Magic see those extra 50 GB?

share|improve this question

OK, turns out that modifyhd --resize does not work as expected if the VM to be resized uses snapshots. A user is supposed to know that in this case modifyhd --resize is to be run against the latest snapshot, not the original vdi file. Something that isn't mentioned in the docs and that doesn't strike me as being obvious either. Two days lost, sigh.

share|improve this answer
Thanks a lot, saved me time! – snitko Jan 23 '13 at 4:40
freakin knew it had something to do with snapshots... any resolution? – Brock Hensley Sep 17 '13 at 18:19
Well, thanks for spending 2 days to figure it out. You saved me a bunch of time. – sybind Nov 30 '15 at 8:36

For those looking how to merge snapshots in VirtualBox to allow expanding virtual disk:

Select your snapshot (if you have multiple, start from the most recent snapshot at the bottom, NOT CURRENT STATE) and click Delete. This will MERGE the data into your CURRENT STATE and leave you with your current state with no snapshots (repeat until all snapshots are merged into Current State).

You would then see the unallocated space in the OS and be able to resize, and take a new snapshot afterwards to resume using snapshots.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .