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.

I have a Virtualbox VM, with a .vdi that is taking 49gb in the host machine.

I may have used that much space inside the VM once, but now I'm only really using about 6gb.

I tried this command for virtualbox:

vboxmanage modifyhd /path/to/disk.vdi --compact

It started working 0%..10%.....100%. But nothing really happened, the .vdi was still 49gb.

Then I run 'df -h' in the VM and found this:

root@mypc# df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/mypc-root       2.0T   38G  1.9T   2% /
udev                        1.3G  4.0K  1.3G   1% /dev
tmpfs                       502M  784K  501M   1% /run
none                        5.0M     0  5.0M   0% /run/lock
none                        1.3G  160K  1.3G   1% /run/shm
/dev/sda1                   228M   31M  185M  15% /boot
/home/someuser/.Private     2.0T   38G  1.9T   2% /home/someuser

I don't know why it is using 38gb there.

I cleaned the Trash but it didn't help.

Any ideas on what else I can do?

The VM has Ubuntu 12, with encrypted LVM and home (that's the .Private dir). The host has Windows 7.

UPDATE

I was able to free space for /dev/sda1, but not for /dev/mapper/mypc-root. Zerofree starts and never ends, though I can tell the disk has stopped writting because it stops doing noise after a minute.

Here's the output for 'df -ih'

root@mypc:/home/someuser# df -ih
Filesystem                 Inodes IUsed IFree IUse% Mounted on
/dev/mapper/mypc-root        128M  208K  128M    1% /
udev                         311K   495  310K    1% /dev
tmpfs                        314K   428  314K    1% /run
none                         314K     4  314K    1% /run/lock
none                         314K     7  314K    1% /run/shm
/dev/sda1                    122K   230  122K    1% /boot
/home/someuser/.Private      128M  208K  128M    1% /home/someuser
share|improve this question
1  
Just curious: What is the output of df -ih ? –  Steven Monday May 27 '12 at 1:52
    
@StevenMonday There, I updated my post. And learned something new =) –  HappyDeveloper May 27 '12 at 5:12

2 Answers 2

up vote 8 down vote accepted

From the manual:

For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Execute sdelete -c in the guest to zero the free disk space before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems.

share|improve this answer
    
Thanks, this is probably the right answer. I created a sub-question here: superuser.com/questions/429199/how-to-umount-its-busy –  HappyDeveloper May 26 '12 at 20:19
    
Link to sdelete: technet.microsoft.com/en-us/sysinternals/bb897443 (download: zip file). –  Rob W May 27 '12 at 17:47

I think the core of your problem is that your root filesystem (/) is 2TB in size. With a filesystem that large, the relatively small overhead (inodes and such) is still quite large (>32GB, in your case).

If you want to shrink your virtual disk, you'll need to shrink your root filesystem first.

share|improve this answer

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.