Is there a way to make virtual HD smaller?

Discussions about using Windows guests in VirtualBox.
Post Reply
bamim2
Posts: 78
Joined: 4. Jan 2011, 20:48
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7 Pro 32-bit, WinXP, Ubuntu 10, Win2003, BSD, Win7Pro, Win2008, Win2003, Solaris 10

Is there a way to make virtual HD smaller?

Post by bamim2 »

I have a VHD that I made from a physical HD using disk2vhd.exe from SysInternals. If you haven't check this guy's work out, you REALLY need to. The physical HD I used was 1TB, but I had partitioned it to 130GB (boot)/30GB/780GB. The virtual drive I made came out partitioned as Dynamically Allocated. It's now, 104GB actual size, but 930GB virtual. I would like to know if anyone knows how I can shrink the virtual drive down about 150GB without losing the data of course?
Jeff_59
Posts: 35
Joined: 17. Apr 2014, 18:06

Re: Is there a way to make virtual HD smaller?

Post by Jeff_59 »

Hello Bamim2,

Can you please tell us why you need to shrink the virtual drive size. Also, i don't know if it will help you,
but did you try CloneVDI (Mpack software)?

Let us know. Thanks

Regards,

Jeff_59
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: Is there a way to make virtual HD smaller?

Post by mpack »

You can't reduce drive capacities with CloneVDI - or with VBoxManage for that matter.

What you should do is use a GParted live CD to shrink and move the partitions. Then compact the disk with CloneVDI. This will not reduce the drive capacity, but it will reduce the host disk space the drive currently occupies, and the fact that the partitions are smaller will ensure that the unpartitioned spaces won't be used again.

It's awkward that you split the drive into the three partitions. That may make resizing them tricky and slow - you'll have to see.
bamim2
Posts: 78
Joined: 4. Jan 2011, 20:48
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7 Pro 32-bit, WinXP, Ubuntu 10, Win2003, BSD, Win7Pro, Win2008, Win2003, Solaris 10

Re: Is there a way to make virtual HD smaller?

Post by bamim2 »

I've used your software (which is VERY nice, by the way THANK YOU) on other virtual drives to make them larger & it's simple to use & worked great. That said, I looked at your software to shrink this drive, but found that it didn't have that capability.

To Compact the drive, do I just basically run the drive through the "Compact drive while copying" feature? I wasn't sure if that would actually do anything more than say, "defrag" or something. Since you're kind enough to respond to my question, does your 'Compacting' feature do something different than "defrag"? Would defragmenting the drive help?

My VD has 2 empty partitions that I can easily make into one that's about 900GB. The partition with stuff on it is 100GB & it's 45% free. So, if I use GParted to shrink the partition from 100GB down to about 80GB, that should be big enough. Do I just use GParted while the Virtual drive is up & running in VB, just like it was on a regular HDD?

Thank you both for your help & knowledge. I greatly appreciate 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: Is there a way to make virtual HD smaller?

Post by mpack »

"Compact" eliminates host disk space assigned to data which the guest filesystem regards as deleted. VirtualBox can't do this automatically because it works at a hardware level, whereas this feature requires knowledge of the guest filesystem, i.e. a software feature. For this reason only selected guest filesystems are supported, namely FATx, NTFS and EXTx. Plus, if VirtualBox did this automatically then undelete would be impossible inside a guest.

The compaction feature has nothing to do with defrag. CloneVDI will defrag the image block order regardless of any settings.

You should adjust the partition sizes as I described earlier, and only then create a compacted clone using CloneVDI.
bamim2
Posts: 78
Joined: 4. Jan 2011, 20:48
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7 Pro 32-bit, WinXP, Ubuntu 10, Win2003, BSD, Win7Pro, Win2008, Win2003, Solaris 10

Re: Is there a way to make virtual HD smaller?

Post by bamim2 »

Thank you. I'll do that.
bamim2
Posts: 78
Joined: 4. Jan 2011, 20:48
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7 Pro 32-bit, WinXP, Ubuntu 10, Win2003, BSD, Win7Pro, Win2008, Win2003, Solaris 10

[Solved] Re: Is there a way to make virtual HD smaller?

Post by bamim2 »

Just wanted to add a note here to say thank you again & in the event that anyone looks at this in the future. I did what you said & after using GPartEd & cloning & compacting my drive, it's about 14GB smaller than it was. As seen by the Host OS.
Post Reply