Reduce virtual VM size

Discussions related to using VirtualBox on Windows hosts.
Post Reply
martin123
Posts: 61
Joined: 21. Nov 2020, 11:30

Reduce virtual VM size

Post by martin123 »

Hi All,

I want to reduce the virtual size of the VM, but it won't work!
As you can see from the screenshot, the size is too big, and I want to reduce it.

I've tried these three commands:

Code: Select all

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifymedium M:\VirtualBox VMs\VM.vdi --resize 65000
I got this message: synthax error.

Code: Select all

VBoxManage modifyhd VM.vdi --resize 65000
or

Code: Select all

VBoxManage modifymedium "M:\VirtualBox VMs\VM.vdi" --resize 65000
I got this message: VBoxManage is not recognized.

How can I do it correctly?
Attachments
reduce VM size.png
reduce VM size.png (5.85 KiB) Viewed 553 times
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Reduce virtual VM size

Post by scottgus1 »

On a Windows host, "vboxmanage" isn't findable by Windows out of the box. You can try one of these:
  • Add the install path to "vboxmanage" (default "C:\Program Files\Oracle\Virtualbox") to the host's PATH system variable
  • direct the command prompt to the install folder with cd "C:\Program Files\Oracle\Virtualbox" before running "vboxmanage"
  • use Mpack's vboxmanage batch file: viewtopic.php?f=25&t=85626
Per the manual https://www.virtualbox.org/manual/ch08. ... difymedium "vboxmanage modifymedium" and synonyms do not shrink, they only expand.

You've commanded a 1TB disk to shrink to 65000MB, which is not possible.

You could make a new 65000MB disk file then use 3rd-party cloning software in a VM to clone the 1TB drive to the 65kMB disk file with appropriate partition adjustments.

You can also reduce the partition sizes in the 1TB disk so they only take up 65000MB of the 1TB space. The partitions will never get bigger than their size, and a disk with partitions totaling 65000MB won't get bigger than 65000MB (plus a few MB overhead), even if there's nominal several hundreds of GB available in the disk partition table.
martin123
Posts: 61
Joined: 21. Nov 2020, 11:30

Re: Reduce virtual VM size

Post by martin123 »

Thank you, @scottgus1, for your reply,

In fact, the VM comes from a VHD to VDI conversion.
The C: partition in the VM actually appears for 75go of which 52.36go is occupied.

The rest is unallocated and therefore does not appear. It only appears when you launch a partition manager.

Thanks for teaching me that "vboxmanage modifymedium" doesn't reduce, but rather extends the size.

So, I'll just leave it like that, or maybe create a VM clone with the indicated size of 65000.

Have a nice day,
Post Reply