6

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?

1
  • In the future.. for anyone reading this old post.. there was an easier way to solve this. IT'S LINUX.. You can mount just about anything anywhere you choose. Just add a NEW disk, rsync your data from wherever you want.. blow away the old folder and mount the drive back in its place. Snapshots aren't a problem in this scenario. Commented Oct 2, 2019 at 20:06

2 Answers 2

10

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.

2
  • freakin knew it had something to do with snapshots... any resolution? Commented Sep 17, 2013 at 18:19
  • 1
    Well, thanks for spending 2 days to figure it out. You saved me a bunch of time.
    – sybind
    Commented Nov 30, 2015 at 8:36
2

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.

You must log in to answer this question.

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