This short post show you, how to resize small vhd/vdi file to one bigger file. And this bigger file can be dynamic or fixed size on hard drive. I working on SSD disk, so it is very fast 🙂 I use comnad line in windows (start > run > cmd). And enter into virtualbox directory:
C:\Users\user>cd c:\ c:\>cd "Program Files\Oracle\VirtualBox"\
So, the input file is “e:\virtual_small.vhd” :
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo e:\virtual_small.vhd UUID: 617f112b-dac5-4e96-b435-437203992efa Parent UUID: base State: created Type: normal (base) Location: e:\virtual_small.vhd Storage format: VHD Format variant: fixed default Capacity: 15360 MBytes Size on disk: 15360 MBytes Encryption: disabled
So, input file is small and we want larger. We must clone it into new one file, dynamically allocated:
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd e:\virtual_small.vhd e:\virtual_dyn.vhd 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone medium created in format 'VHD'. UUID: b48eebd1-daa5-4020-9774-d5ca4b985b45 c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo e:\virtual_dyn.vhd UUID: b48eebd1-daa5-4020-9774-d5ca4b985b45 Parent UUID: base State: created Type: normal (base) Location: e:\virtual_dyn.vhd Storage format: VHD Format variant: dynamic default Capacity: 15360 MBytes Size on disk: 15245 MBytes Encryption: disable
Now, we can resize it to new size, perhaps 25000MB:
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd e:\virtual_dyn.vhd --resize 25000 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo e:\virtual_dyn.vhd UUID: fe1c2a26-39d4-4f31-b4da-bc688b4a3c22 Parent UUID: base State: created Type: normal (base) Location: e:\virtual_dyn.vhd Storage format: VHD Format variant: dynamic default Capacity: 25000 MBytes Size on disk: 15247 MBytes Encryption: disabled
And now, we can clone it into fixed size. Fixed size of this disk is better for performance on classic disk. Dynamic is better on SSD disks, because there is never-ending resize of this file and virtualbox must allocate new space if the virtual machine grows in lifetime. So dynamic file allocate its space at the beginning. It ok for me, because I don’t care about the space of this file on beginning.
c:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd e:\virtual_dyn.vhd e:\virtual_static.vhd --variant Fixed 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone medium created in format 'VHD'. UUID: 3ddb4a53-a767-478f-8dc7-f670610320ca c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo e:\virtual_static.vhd UUID: 3ddb4a53-a767-478f-8dc7-f670610320ca Parent UUID: base State: created Type: normal (base) Location: e:\virtual_static.vhd Storage format: VHD Format variant: fixed default Capacity: 25000 MBytes Size on disk: 25000 MBytes Encryption: disabled
Have a nice day.