Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My Dynamic VDI has occupied 56.2 GB space on the NTFS partition with Windows 7 Host. I am running a Ubuntu Server on the machine and it only occuipies 4.1 GB

Command: df -h Shows

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             2.0T  4.1G  1.9T   1% /
none                  4.0K     0  4.0K   0% /sys/fs/cgroup
udev                  235M  4.0K  235M   1% /dev
tmpfs                  50M  512K   49M   2% /run
none                  5.0M     0  5.0M   0% /run/lock
none                  246M  4.0K  246M   1% /run/shm
none                  100M     0  100M   0% /run/user
/dev/sdb1             2.0T   11G  1.9T   1% /var/dev
/home/starx/.Private  2.0T  4.1G  1.9T   1% /home/starx

How to shrink this 56.2 GB to 4.1 GB which is the real size?

share|improve this question
add comment

1 Answer 1

The trick is to fill the unused space with zeros, then ask VB to shrink the disk.

Eg: as root in Linux: dd if=/dev/zero bs=1024k of=/bigfile; rm -f /bigfile

Then shut the machine down and run: VBoxManage modifyhd diskfile.vdi --compact

With most of the disk zero-filled it should shrink down to something close to 4GB.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.