Wiping / shrinking vdi to minimum

Discussions related to using VirtualBox on Windows hosts.
Post Reply
dataKEKS
Posts: 29
Joined: 3. Jul 2007, 14:51
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows and Linux
Location: Germany - BW
Contact:

Wiping / shrinking vdi to minimum

Post by dataKEKS »

Hey forum!

I have a maybe a little bit strange question which i don´t know how answer, but maybe you have an idea: I´m using Vitualbox for software testing on and with Windows, but from time to time i have the problem that my disk space is going low. Because all my test are running based on an Active Directory i would be the easiest way for me to reset vdi files of currently unused clients to zero because the can be reinstalled with all i need by guid based network installation.

The manually way to fix my problem would be to backup manually every vdi file before installing the client and if need to wipe it for getting the disk space back i would just have to overwrite the large vdi with the nacked which is only round about 3MB large.

Is that the only way for my problem or is there any other way, maybe with the commandline tool vboxmange, to do the job? I don´t to delete the hole VM because its GUID is stored in the Active Directory and helps me to correct reasing in my testnetworking.


Best regards
Norbert
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: Wiping / shrinking vdi to minimum

Post by scottgus1 »

reset vdi files of currently unused clients to zero because the can be reinstalled
I suspect that the reinstallation will cause some GUID or other identifier to be different and your reinstalled guest will appear to be a different PC to AD and not be the old one.

Two suggestions:

1. Hard disk space is cheap. 1TB drives for $50, 2TB for $72. Get a bigger or second drive.

2. Use CloneVDI (see top of Windows Hosts forum) Compact while cloning and keep the old UUID. Save the clone and delete the original vdi after backing up to two or more external drives. Compacted vdi's will get bigger again, which may lead you back to suggestion 1.
dataKEKS
Posts: 29
Joined: 3. Jul 2007, 14:51
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows and Linux
Location: Germany - BW
Contact:

Re: Wiping / shrinking vdi to minimum

Post by dataKEKS »

Hey scottgus1!

My Problem is that we are talking about a Notebook with a 1TB SSD which still isn´t big enough from time to time and right now i don´t to replace it with a bigger one...

The GUID won´t Change if i use the same VM, that´s why i would like to reset just the vdi file to its minimum size of about 3MB. When i than the vm back operational it would install automatically by using my WDS server...

Any idea for a solution without manual file copy?


Norbert
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: Wiping / shrinking vdi to minimum

Post by scottgus1 »

What I would do then is:

Backup everything in case my advice doesn't work :)
Delete the old vdi disk file.
Attach a brand new vdi file to the guest as the main drive. Size it appropriately. Call it "clientdisk.vdi".
In the guest folder, make a copy of "clientdisk.vdi" and rename the copy as "clientdisksource.vdi"
Make a batch file in the guest folder with this command in it:

Code: Select all

del clientdisk.vdi
copy clientdisksource.vdi clientdisk.vdi
You can add code to test if the guest is shut down before running the del & copy commands, and you can put in confirmation key presses to be sure you do this only by intentional decision if you want.
When you want to reset the client disk, shut down the guest and run the batch file.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Wiping / shrinking vdi to minimum

Post by Martin »

This may be a valid use case for a (single) snapshot.
After creating your small VM disk add a snapshot and revert to this state after testing.
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: just about all that run

Re: Wiping / shrinking vdi to minimum

Post by loukingjr »

I think Martin is onto something.
OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
Post Reply