Page 1 of 1

Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 09:44
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

Re: Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 13:41
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.

Re: Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 16:01
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

Re: Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 16:22
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.

Re: Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 16:23
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.

Re: Wiping / shrinking vdi to minimum

Posted: 29. Oct 2015, 16:27
by loukingjr
I think Martin is onto something.