Seriously, how to compact a vdi?
Seriously, how to compact a vdi?
I have been delaying this question for some time thinking I was doing something wrong... I have tried many scenarios and I can't compact a VDI.
I use Ubuntu Gutsy as host, VirtualBox 1.5.2. I have XP/NTFS as guest, and the machine/disk never had a snapshot.
From windows explorer, the disk has 4.6Gb occupied. I run defrag, then JkDefrag to compact everything on the beginning of the disk. The file had 7Gb in size then.
Then I run SDELETE -Z, and the file went to ~15Gb.
The drive map from windows defrag and from jkdefrag shows a huge empty area on the end of the disk.
Tried to run VBoxManage modifyvdi <file> compact and there was absolutely no change on the file size. Not even one byte.
I have been seeing many posts and bug tickets open about this, but never saw an answer.
Is this really a bug? Am I doing something wrong?
Thanks in advance.
I use Ubuntu Gutsy as host, VirtualBox 1.5.2. I have XP/NTFS as guest, and the machine/disk never had a snapshot.
From windows explorer, the disk has 4.6Gb occupied. I run defrag, then JkDefrag to compact everything on the beginning of the disk. The file had 7Gb in size then.
Then I run SDELETE -Z, and the file went to ~15Gb.
The drive map from windows defrag and from jkdefrag shows a huge empty area on the end of the disk.
Tried to run VBoxManage modifyvdi <file> compact and there was absolutely no change on the file size. Not even one byte.
I have been seeing many posts and bug tickets open about this, but never saw an answer.
Is this really a bug? Am I doing something wrong?
Thanks in advance.
You are doing something wrong.
From the User Manual:
http://www.feyrer.de/g4u/nullfile-1.02.pas
http://www.feyrer.de/g4u/nullfile-1.02.exe
From the User Manual:
I use this nice tiny program for "nullifying" my paritions within the virtual machine.8.13 VBoxManage modifyvdi
The modifyvdi command can be used to compact disk images, i.e. remove blocks
that only contains zeroes. For this operation to be effective, it is required to zero out
free space in the guest system using a suitable software tool.
http://www.feyrer.de/g4u/nullfile-1.02.pas
http://www.feyrer.de/g4u/nullfile-1.02.exe
Re: Seriously, how to compact a vdi?
Oh sorry, I've just seen:
Does it zero out with null or with random values?nvivo wrote:Then I run SDELETE -Z, and the file went to ~15Gb.
Re: Seriously, how to compact a vdi?
From what I have read, it writes zero, and it is the recomendation from the people here.Ingo wrote:Oh sorry, I've just seen:Does it zero out with null or with random values?nvivo wrote:Then I run SDELETE -Z, and the file went to ~15Gb.
And it seems I'm not the only one... There are open tickets with no response about if this is going to be fixed or not.
http://www.virtualbox.org/ticket/28
http://www.virtualbox.org/ticket/709
http://forums.virtualbox.org/viewtopic.php?t=2218
http://forums.virtualbox.org/viewtopic.php?t=2246
I have read the manual and I know what it says.
But have anyone actually used it in real life?
Well, that finally works! Thanks.Ingo wrote:I've just tested the nice tiny program nullfile-1.02.exe and my VDI was shrunken from 3.2GB to 1.6GB.
It works. Give it a try.
Just recovered 35Gb of space =)
Have anyone tried to compile this on linux guests? From this ticket ( http://www.virtualbox.org/ticket/28 ), dd doesn't seem to work...
Also, this info should be on the manual.
Or better, there should be a tool included in the guest additions that does this. I believe that VMWare "Shrink" option that can shrink the disk while running the VM does something similiar, right?
Have you tried to restore the VDI afterwards?
Install Windows Vista in two minutes!
http://www.youtube.com/watch?v=FVbf9tOGwno
http://www.youtube.com/watch?v=FVbf9tOGwno
Try zerofree. See also here: Tip: (Better) Shrinking of Ext(2/3) partitionsnvivo wrote: Have anyone tried to compile this on linux guests? From this ticket ( http://www.virtualbox.org/ticket/28 ), dd doesn't seem to work...
-
- Posts: 428
- Joined: 2. May 2010, 14:19
- Primary OS: Fedora other
- VBox Version: PUEL
- Guest OSses: Windows, Linux, other Unixes
- Location: Artem S. Tashkinov
- Contact:
Re: Seriously, how to compact a vdi?
dd works both on linux and Windows hosts.
and after you've blanked your virtual HDD, stop VirtualBox and run this command to compact VDI storage file:
dd for windows can be downloaded here: http://www.chrysocome.net/dd
Code: Select all
dd if=/dev/zero of=EMPTY bs=1M
rm/del EMPTY
Code: Select all
VBoxManage modifyhd Disk.vdi --compact
-
- Volunteer
- Posts: 7639
- Joined: 7. Jun 2007, 21:53
Re: Seriously, how to compact a vdi?
CloneVDI works faster as every other solution.
German Howto (Linux): http://www.linuxforen.de/forums/showthread.php?t=236444
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
User Manual / Download Section: http://www.virtualbox.de/wiki/Downloads
FAQ: http://www.virtualbox.de/wiki/User_FAQ http://forums.virtualbox.org/viewtopic.php?t=8669
-
- Site Moderator
- Posts: 34369
- Joined: 6. Sep 2008, 22:55
- Primary OS: Linux other
- VBox Version: OSE self-compiled
- Guest OSses: *NIX
Re: Seriously, how to compact a vdi?
You can run CloneVDI in Linux but it requires that you install Wine.
-
- Posts: 15
- Joined: 4. Sep 2007, 23:41
- Location: Vienna, Austria; Germany; hello world :)
Re: Seriously, how to compact a vdi?
so to wrap it up
inside of your virtual machine
1) pick the defragment tool of your choice and configure it to pack data as close together as possible - leaving large areas of free space
(I used http://www.oo-software.com/free/en O&O Defrag Free Edition - a very potent free defrag utility )
2) zero the free space with http://technet.microsoft.com/en-us/sysi ... s/bb897443 sdelete
sdelete -c C:\ (on C:\)
or whatever other drive
outside of the virtual machine - on your host
3) VBoxManage modifyhd Disk.vdi --compact
disk worked like a charm and gained me 9 GiB worth of additional harddrive space on my /home partition - and that was only one of those harddisks
Thanks !
inside of your virtual machine
1) pick the defragment tool of your choice and configure it to pack data as close together as possible - leaving large areas of free space
(I used http://www.oo-software.com/free/en O&O Defrag Free Edition - a very potent free defrag utility )
2) zero the free space with http://technet.microsoft.com/en-us/sysi ... s/bb897443 sdelete
sdelete -c C:\ (on C:\)
or whatever other drive
outside of the virtual machine - on your host
3) VBoxManage modifyhd Disk.vdi --compact
disk worked like a charm and gained me 9 GiB worth of additional harddrive space on my /home partition - and that was only one of those harddisks
Thanks !
-
- Posts: 5
- Joined: 2. Dec 2010, 09:57
- Primary OS: MS Windows 7
- VBox Version: PUEL
- Guest OSses: Windows7, MSDOS, Windows95, DRDOS, WINDOWS98, LINUX
- Location: Spain
Re: Seriously, how to compact a vdi?
Thank you for your help!!
-
- Posts: 1
- Joined: 14. Feb 2011, 12:18
- Primary OS: Ubuntu other
- VBox Version: PUEL
- Guest OSses: Windows
Re: Seriously, how to compact a vdi?
I would suggest to you to not use sdelete, and to use instead a NullFile .NET program that I've writed, based on pascal NullFile version of Matthias Jordan.
It's really faster and contain full source code.
Here http://www.gammatwo.com/2011/01/16/null ... oing-disk/ you can find all.
Bye
P.S.: For defragging I use UltraDefrag , it's open source.
It's really faster and contain full source code.
Here http://www.gammatwo.com/2011/01/16/null ... oing-disk/ you can find all.
Bye
P.S.: For defragging I use UltraDefrag , it's open source.