Google does it work well. And i quickly find the commandline tool VBoxManage that comes with VirtualBox, but it is not as trivial to use. From the man page, it says something like this
VBoxManage modifyvm /path/to/image.vdi --compact
But of course, this does not work, complaining:
VBoxManage: error: Cannot register the hard disk '/path/to/image.vdi' {0bb60115-3e8c-4a52-b825-229166ec0c84} because a hard disk '/path/to/image.vdi' with UUID {0bb60115-3e8c-4a52-b825-229166ec0c84} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 210 of file VBoxManageDisk.cpp
What? line 210 of a c++ program has problem? That takes me google more and more pages to find the solution.
Here is it finally my steps to shrink.
- Defrag the Guest OS. In windows, one can use the built-in defragmentation tool to do the task. I do it a few times to move all files to the front.
- Set all the empty space to null. I use this tool http://www.feyrer.de/g4u/nullfile-1.02.exe. Put it in c:\ and run it. Some pages suggest to use sdelete from sysinternals. But it doesn't work for me.
- Run the command VBoxManage to compact it. VBoxManage modifyhd {0bb60115-3e8c-4a52-b825-229166ec0c84} --compact
- Done!
Note that I use the uuid instead of the path, i don't know why but only using uuid works.
0 comments:
Post a Comment