vdi file too big, cannot clone and use
Posted: 12. May 2016, 22:23
I have searched and tried many things, but I can't seem to find a problem close enough to mine to help me solve this. There are some that are almost close enough to help, but mine seems to be unique.
I have a separate partition for my virtual machine, which I run Windows 7 on. My host OS is opensuse Leap 42.1, and the desktop is Plasma 5.
My dedicated virtualbox partition size was 114G. My virtual hard drive is supposed to be only 80gb, and only about 50gb is being used on it. However, for some reason my vdi files with snapshots grew to fill the entire partition. Then the machine shut down while I was in the middle of an operation, and I could not get it to work again. It had corrupted something in the vdi file.
Fortunately, I had a backup saved on another drive, which is a mirror image drive for all my files. So, I removed the old machine, removed the configurations files (in the ~/.config/VirtualBox/ directory), and removed the old vdi files and snapshots. Then I copied the backup files back into the right places of the old machine, configurations, and also the old vdi files and snapshots. Voila. I was able to get my old Windows7 virtual machine back up and running again.
So then I thought, I need to shrink the size of the vdi file, and at the same time give it more room to grow. I used gparted to extend my 114G partition to 127G. That went fine, and I can still run Windows in VirtualBox.
Then I looked at all the different options to try and shrink the vdi file. I opened windows and ran defragment on the hard drive, and then ran sdelete to zero out unused blocks.
Then I closed the VM and back in linux I went to the directory where the vdi file is stored (with the snapshots) and ran the following:
I could not figure out how to tell virtualbox that this file only exists in one location, where I am trying to shrink it. But I could not figure that out.
So I thought I would try and remove my snapshots, but I got this error when I tried to delete a snapshot:
I have plenty of room to expand in this partition now, as it is now 127gb, and the total of all the virtual machine files is only 114gb. But it won't let me do it.
So, next thing to try. I decided to use the clonevdi tool. It is a windows based tool, so I copied my vdi file to another directory, and opened up my virtual machine. From there I ran clonevdi, and was able to shrink the Win2015su.vdi file, and then try and create a new machine using that file as the hard disk. However, it won't open. It gives me a blue screen on startup, and it won't repair with the windows startup repair utility.
I tried the same thing, using clonevdi on the latest snapshot vdi file, that has the format {UUID}.vdi. It cloned and compacted it, but the same thing - wouldn't start up, and windows startup repair wouldn't make it work.
So I need help. Can someone please help me to do one of the following 2 things:
a) tell virtualbox that it is mistaken to believe that there is another vdi file with the same UUID, so that I can compact the original vdi file and then make things work more effectively.
-OR-
b) use clonevdi to compact the current state vdi file, along with all the snapshots, into one file with a separate UUID (I already can make the separate UUID, but I can't figure out how to get them all together into one), so that I can try running that machine.
Option A is preferable, because my windows vm seems to run just fine as long as I don't add a bunch of stuff to the OS.
Any help is appreciated - thanks in advance.
G.O.
PS - I am running VirtualBox 5.0.16.
I have a separate partition for my virtual machine, which I run Windows 7 on. My host OS is opensuse Leap 42.1, and the desktop is Plasma 5.
My dedicated virtualbox partition size was 114G. My virtual hard drive is supposed to be only 80gb, and only about 50gb is being used on it. However, for some reason my vdi files with snapshots grew to fill the entire partition. Then the machine shut down while I was in the middle of an operation, and I could not get it to work again. It had corrupted something in the vdi file.
Fortunately, I had a backup saved on another drive, which is a mirror image drive for all my files. So, I removed the old machine, removed the configurations files (in the ~/.config/VirtualBox/ directory), and removed the old vdi files and snapshots. Then I copied the backup files back into the right places of the old machine, configurations, and also the old vdi files and snapshots. Voila. I was able to get my old Windows7 virtual machine back up and running again.
So then I thought, I need to shrink the size of the vdi file, and at the same time give it more room to grow. I used gparted to extend my 114G partition to 127G. That went fine, and I can still run Windows in VirtualBox.
Then I looked at all the different options to try and shrink the vdi file. I opened windows and ran defragment on the hard drive, and then ran sdelete to zero out unused blocks.
Then I closed the VM and back in linux I went to the directory where the vdi file is stored (with the snapshots) and ran the following:
Code: Select all
> vboxmanage modifyhd Win2015su.vdi --compact
VBoxManage: error: Cannot register the hard disk '/home/virt/VirtualBox VMs/Windows/Win2015su.vdi' {88c39387-e94e-4e89-8c97-a91c96bbf9e7} because a hard disk '/home/george/VirtualBox VMs/VirtualBox VMs/Windows/Win2015su.vdi' with UUID {88c39387-e94e-4e89-8c97-a91c96bbf9e7} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp
So I thought I would try and remove my snapshots, but I got this error when I tried to delete a snapshot:
Code: Select all
Failed to delete the snapshot afterTOS of the virtual machine Windows.
Unable to merge storage '/home/george/VirtualBox VMs/VirtualBox VMs/Windows/Win2015su.vdi' - not enough free storage space. .
Result Code: NS_ERROR_OUT_OF_MEMORY (0x8007000E)
Component: SessionMachine
Interface: IMachine {f30138d4-e5ea-4b3a-8858-a059de4c93fd}
So, next thing to try. I decided to use the clonevdi tool. It is a windows based tool, so I copied my vdi file to another directory, and opened up my virtual machine. From there I ran clonevdi, and was able to shrink the Win2015su.vdi file, and then try and create a new machine using that file as the hard disk. However, it won't open. It gives me a blue screen on startup, and it won't repair with the windows startup repair utility.
I tried the same thing, using clonevdi on the latest snapshot vdi file, that has the format {UUID}.vdi. It cloned and compacted it, but the same thing - wouldn't start up, and windows startup repair wouldn't make it work.
So I need help. Can someone please help me to do one of the following 2 things:
a) tell virtualbox that it is mistaken to believe that there is another vdi file with the same UUID, so that I can compact the original vdi file and then make things work more effectively.
-OR-
b) use clonevdi to compact the current state vdi file, along with all the snapshots, into one file with a separate UUID (I already can make the separate UUID, but I can't figure out how to get them all together into one), so that I can try running that machine.
Option A is preferable, because my windows vm seems to run just fine as long as I don't add a bunch of stuff to the OS.
Any help is appreciated - thanks in advance.
G.O.
PS - I am running VirtualBox 5.0.16.