Google wasn't being too helpful. I'm just curious what the easiest way to shrink a VDI file is.
I've already defraged and zero'd the unused space. Anyway to shrink the VDI in place now that I've done these steps?
Way to shrink a VDI with least amount of hassle?
-
MarkCranness
- Volunteer
- Posts: 875
- Joined: 10. Oct 2009, 06:27
- Primary OS: MS Windows 7
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP
Re: Way to shrink a VDI with least amount of hassle?
Cleanup > Defrag > CloneVDI (with 'Compact drive while copying' checked - zeroes space for you).
To do 'in-place' (will rename the old file) set Source and Destination filename the same (also set 'Keep old UUID' if using in-place).
If your guest is Linux-like, then likely use the 'Keep old UUID' option (ask).
To do 'in-place' (will rename the old file) set Source and Destination filename the same (also set 'Keep old UUID' if using in-place).
If your guest is Linux-like, then likely use the 'Keep old UUID' option (ask).
-
mpack
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Mostly XP
Re: Way to shrink a VDI with least amount of hassle?
I would suggest that you edit your profile to indicate your normal host and guest OS types, as that would allow us to answer questions like yours more specifically.DrD wrote:I've already defraged and zero'd the unused space. Anyway to shrink the VDI in place now that I've done these steps?
Mark's answer is probably accurate, but I should mention that zeroing the empty space in the guest is not necessary if you use CloneVDI and the guest has a common filesystem (NTFS, FAT, or EXT2/3/4). A defrag may bring some benefits, but if you want the least possible hassle then you can skip that step too - or at least you don't need to do it every time.
-
JshWright
- Volunteer
- Posts: 119
- Joined: 13. Sep 2007, 00:33
- Primary OS: Debian Lenny
- VBox Version: OSE self-compiled
- Guest OSses: Many...
Re: Way to shrink a VDI with least amount of hassle?
If you've zero'd the empty space, then all you need to do is run:
Code: Select all
VBoxManage modifyhd /path/to/your.vdi --compactJoin us in the VirtualBox IRC channel: #vbox on FreeNode
http://www.virtualbox.org/wiki/IRC
http://www.virtualbox.org/wiki/IRC
-
DrD
- Posts: 31
- Joined: 12. Jan 2009, 00:47
- Primary OS: Mac OS X other
- VBox Version: OSE other
- Guest OSses: Linux Mint, Win XP, Win 7
Re: Way to shrink a VDI with least amount of hassle?
That last part was useful for my windows partition, thank you.JshWright wrote:If you've zero'd the empty space, then all you need to do is run:Code: Select all
VBoxManage modifyhd /path/to/your.vdi --compact
Now I am having a rather tough time with my Ubuntu install. I don't know how to zero the space first. I tried zerofree, which was in the ubuntu repositories. I tried to use it on my Ubuntu 9.04 ext3 partition, by following this guide:
http://ubuntuforums.org/showthread.php?t=908128
I get as far as the last part where I actually run the darn thing. Device was /dev/sda1. I re-mounted it with this command, with no issues:
mount -n -o remount,ro -t ext3 /dev/sda1 /
But when I run:
zerofree /dev/sda1
Nothing happens. It just gets to the next line and sits there. No errors. Nothing. I even left it for over an hour. Still nothing. Had to CTRL - C to get back to a prompt.
On a less objective note, this whole process pisses me off. Everything's convoluted; half the things I read just don't work. I have a massive 12.8 GB vdi file with only < 3 GB of used space on it.
-
mpack
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Mostly XP
Re: Way to shrink a VDI with least amount of hassle?
Don't work? Perhaps, or perhaps just finger trouble. Convoluted? and I would add - slow? Absolutely. Why do you think I wrote CloneVDI?, and why do you think I made sure it worked independantly of VBoxManage?DrD wrote:On a less objective note, this whole process pisses me off. Everything's convoluted; half the things I read just don't work.
You may still want to consider CloneVDI. I believe you could run it under Wine on an OS X host, failing that you could even run it inside a Windows guest, if you can give it access to the VDIs in a network shared folder. I would warn against attempting to run it inside the guest whose VDI you are cloning, but there's probably no need as I don't think that's even possible (you would get a sharing violation).
-
huffring
- Posts: 2
- Joined: 18. Sep 2009, 10:39
- Primary OS: Ubuntu other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: WinXP, CentOS
Re: Way to shrink a VDI with least amount of hassle?
Try "zerofree -v /dev/sda1" next time. The "-v" stands for verbose and shows you the progress.JshWright wrote: But when I run:
zerofree /dev/sda1
Nothing happens. It just gets to the next line and sits there. No errors. Nothing. I even left it for over an hour. Still nothing. Had to CTRL - C to get back to a prompt.