0

I've a Debian 8.5 guest in Ubuntu 22.04 Host, and a while ago i expanded space from host terminal stopping guest with VBoxManage modifyhd --resize option in a direct way, booting guest and expanding partition size with gparted.

But when i've needed to reduce the space again, then i reduce a partition size in host, in my case booting with gparted live iso because the partition is system type, leaving free space at the end of the disk, but when i've tried again VBoxManage modifyhd but this time with --compact option, has not reduced its size.

Finally to solve it, i created a new partition on the disk from gparted, and after installing the zerofree utility (with: sudo apt install zerofree), i've applied it to the new empty ext4 partition (with: zerofree -v /dev/sda3), to later delete said empty partition. After that the compact command worked, and the VDI file was reduced.

I don't know if there is an easier way to do it, but i'm sharing it in case it helps someone. Thanks and hugs! @tximikel

1 Answer 1

0

You can use ntfsresize to do that.

But first you will have to mount the VDI as a loop device, or attach it to a VM and run the program inside the VM. Here's a guide how to use vdfuse or other software to do that: How to mount a VirtualBox .vdi disk on Linux?

Alternately you can use any Defrag program and use the "optimize free space" option. Windows has one built in, just look for "defrag" in the menu.

My favorite is MyDefrag (http://www.mydefrag.net) - it shows a visual layout of the drive.

You must log in to answer this question.

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