VirtualBox - reduce max-size of dynamic .vdi hard disk

9

2

I'm trying to reduce the maximum capacity of a .vdi file (hard disk) for one of my VMs.

I set it as dynamically-allocated with a maximum capacity of 25GB. I want to reduce this to 10GB.

NOTE: I do not want to compact the size of the .vdi file on my host machine. Then I could just use VBoxManage modifyhd --compact /path/to/my/vdi. However, although this reduces the footprint of the .vdi file on my host machine, the guest will still report a 25GB hard drive.

What I want to do is reduce the maximum capacity of the .vdi such that the guest reports a 10GB hard drive (I have already adjusted my partitions within the guest such that my partitions only take up 10GB total, and the other 15GB comes up as unallocated space).

What I have tried

I tried using the same command one uses to increase the size of the disk:

$ VBoxManage modifyhd Arch\ Linux\ Aug\ 2012\ Clone.vdi --resize 10240
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

It seems not to be supported (and the .vdi is definitely a dynamically-allocated .vdi, not a fixed-size one).

cheers.

mathematical.coffee

Posted 2012-09-04T04:38:14.157

Reputation: 248

I'm having the same issue. any update on this question? Is it still impossible now? – Hoàng Long – 2018-03-06T03:58:40.617

Does this answer help you? https://askubuntu.com/a/799645

– Moobie – 2018-03-06T05:25:10.353

Answers

11

Correct. You cannot downsize a VDI file, even if it does have unallocated disk space. At least not with the current version of VirtualBox. The only thing --resize can do at the moment is to increase the size of a VDI file.

Ansgar Wiechers

Posted 2012-09-04T04:38:14.157

Reputation: 4 860

awww, ok. I guess since I only let my partitions take up 10GB total and since it's dynamically sized, I can hope to always have an on-disk file of <= 10GB (with compacting) – mathematical.coffee – 2012-09-04T23:48:16.920

Well, you could always use the method I suggested here.

– Ansgar Wiechers – 2012-09-04T23:55:28.887