10

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.

2
  • I'm having the same issue. any update on this question? Is it still impossible now? Commented Mar 6, 2018 at 3:58
  • Does this answer help you? askubuntu.com/a/799645
    – Moobie
    Commented Mar 6, 2018 at 5:25

2 Answers 2

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.

3
  • 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) Commented Sep 4, 2012 at 23:48
  • Well, you could always use the method I suggested here. Commented Sep 4, 2012 at 23:55
  • Is it still the same case as of Feb 2021, that downsizing max size is impossible ?
    – Peter
    Commented Feb 12, 2021 at 8:02
0

Please image that you are the guest to see what is happening if the size your vdi is reduced: a disk comes up saying that it was 25 GB. You format the disk, possibly with some partitions. Ok, suppose it just one single partition. Then you make some operations on the disk/partition, coping, deleting, modifying, moving, whatsoever, for several days. Then you go to sleep (the guest is powered off). You wake up (the guest is powered on), you would simply work on the disk/partition as usual, never noticing that the size of the disk/partition has ever been reduced! Guest what, at some point the operation beyond the size would fail, and you (the guest os) would regularly think: oh, the disk is failed because some blocks get damaged.

That is the story. You could surely reduce the size, but the guest does not know it and is going to fail in the end. There is no way to notify the guest (unless, in windows, you the os compact the disk).

You must log in to answer this question.

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