I have a "windows XP" guest in a Linux host.
I have already run defrag in Win XP.
This is how it looks at the moment:
36 GB free of 76 GB.
The VDI itself is about 67 GB.
I have done the steps ...
-Run in a cmd windows in your guest "sdelete c: -z"
and
-Run "VBoxManage modifymedium <path.VDI> --compact' from the Host
But my VDI has still the same size! ?
How can I now get a VDI of about 46 GB.
Thank you.
[solved] How to shrink my VDI HD
[solved] How to shrink my VDI HD
Last edited by Plagrö on 30. Sep 2020, 10:43, edited 1 time in total.
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: How to shrink my VDI HD
Compact does not change the VDI's final size. It only dumps no-longer-used sectors out of the guest disk file on the host drive.
Your guest disk shows 76GB size with 36GB free. The guest disk file on the host drive is 67GB, and it can increase to the full 76GB. After compacting, your guest disk file should have been about 40GB (76 - 36) on the host drive. Did this happen?
If it did, then the compact command worked.
If it did not, please try Mpack's CloneVDI. CloneVDI does not require 'sdelete' zero-filling, and has the extremely important benefit of making a compacted copy of the disk file, rather than working on the original and possibly bunging it up. I strongly recommend CloneVDI instead of the vboxmanage 'compact' command.
If your guest disk file did shrink to ~40GB, and you now want it to not increase past 46GB, you must change the partition size inside the XP guest. Shrink the guest OS's C drive partition to 46GB and the guest disk file on the host won't get bigger than 46GB.
Virtualbox does not come with a tool to edit guest OS partitions. XP also does not have a way to edit its partitions. The bootable 'Gparted' ISO can be used as a boot ISO on the XP guest's CD drive to edit the C drive partition to a smaller size. Web-search 'Gparted' for a download and instructions. Explaining Gparted usage is beyond the scope of the Virtualbox forum.
Your guest disk shows 76GB size with 36GB free. The guest disk file on the host drive is 67GB, and it can increase to the full 76GB. After compacting, your guest disk file should have been about 40GB (76 - 36) on the host drive. Did this happen?
If it did, then the compact command worked.
If it did not, please try Mpack's CloneVDI. CloneVDI does not require 'sdelete' zero-filling, and has the extremely important benefit of making a compacted copy of the disk file, rather than working on the original and possibly bunging it up. I strongly recommend CloneVDI instead of the vboxmanage 'compact' command.
If your guest disk file did shrink to ~40GB, and you now want it to not increase past 46GB, you must change the partition size inside the XP guest. Shrink the guest OS's C drive partition to 46GB and the guest disk file on the host won't get bigger than 46GB.
Virtualbox does not come with a tool to edit guest OS partitions. XP also does not have a way to edit its partitions. The bootable 'Gparted' ISO can be used as a boot ISO on the XP guest's CD drive to edit the C drive partition to a smaller size. Web-search 'Gparted' for a download and instructions. Explaining Gparted usage is beyond the scope of the Virtualbox forum.
Re: How to shrink my VDI HD
Thank you.
I think I'll start all over again.
Do we have to defrag the VDI in the guest first before running CloneVDI? Or does CloneVDI do that anyway?
I think I'll start all over again.
Do we have to defrag the VDI in the guest first before running CloneVDI? Or does CloneVDI do that anyway?
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: How to shrink my VDI HD
Defrag gets any little chunks of files together. It should not affect the final size outcome of CloneVDI or vboxmanage compacted disk files. If the disk file is stored on an SSD, then Defrag is unnecessary at any time. If your XP guest is on an SSD and has any automatic defragging going on, disable it, it will reduce the lifespan of the SSD.
-
fth0
- Volunteer
- Posts: 5690
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to shrink my VDI HD
I beg to differ:scottgus1 wrote:Defrag gets any little chunks of files together. It should not affect the final size outcome of CloneVDI or vboxmanage compacted disk files.
The VDI format uses blocks of 1 MiB (MB for mpack
If you let Defrag consolidate the free space, you'll probably note the difference. The defragmentation may take some hours, though.
Re: How to shrink my VDI HD
I read this:scottgus1 wrote:Compact does not change the VDI's final size. It only dumps no-longer-used sectors out of the guest disk file on the host drive.
If it did not, please try Mpack's CloneVDI. forum.
But I did not find any exe in the zip: (?)Q. How do I install it?
A. It came as a .zip, just create a folder and unzip the contents into it. After that you can
optionally create a shortcut to link your desktop to the CloneVDI.exe file inside the target
folder.
additional question:
Is CloneVDI 32 bit or 64 bit? I must know it, because I have to know if I must make a 32 bit wine prefix or a 64 bit wine prefix.
Thank you.
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: How to shrink my VDI HD
It appears that you got hold of the source code somehow. This is the link the the zipped EXE: download/file.php?id=37667
I suspect CloneVDI is 32-bit. Since you're using Wine, see viewtopic.php?f=7&t=22437.
I suspect CloneVDI is 32-bit. Since you're using Wine, see viewtopic.php?f=7&t=22437.
Re: How to shrink my VDI HD
Thank you. I was successful with this tool.
Ye, it's 32 bit.
Ye, it's 32 bit.
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: [solved] How to shrink my VDI HD
Great! Glad you're up and running.
Good point, thanks! Defrag would put the sectors together, which might move them out of and thereby empty a block, letting the block get deleted, resulting in a possibly smaller compact.fth0 wrote:blocks of 1 MiB (MB for mpack ), which represent 2048 consecutive sectors of 512 bytes each.