Issue with deleting huge snapshot

Discussions related to using VirtualBox on Windows hosts.
Post Reply
genesis1967
Posts: 1
Joined: 27. May 2011, 17:58
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu

Issue with deleting huge snapshot

Post by genesis1967 »

I have a 120GB snapshot which I need to delete because my laptop is 99% full. But when I ask VirtualBox to delete the snapshot, it works on it for quite a while, then runs out of memory and chokes. I know VirtualBox has to do merging of files and the like, and it needs some free space to do this. How much free space do I need in order for the deletion of the snapshot to work?

Could I instead put this snapshot, the main .vdi file, and the VirtualBox software, on my 500GB external drive and then have VirtualBox on that drive work on deleting the snapshot? I tried that actually, but when I try to change the snapshot location from my laptop hard drive (C:\...) to my external hard drive, VirtualBox says I can't change the location of the snapshot. What do I do?

Thanks,
genesis1967
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: Issue with deleting huge snapshot

Post by mpack »

See the CloneVDI tool (sticky at top of this forum). Read the release notes, specifically the bit about cloning snapshot files.
Dili
Posts: 13
Joined: 10. May 2010, 17:36
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Linux

Re: Issue with deleting huge snapshot

Post by Dili »

i'm experiencing the same issue. here's my setup:

i have a 2TB fixed-size VDI image that's in a 2TB drive. needless to say, the 2TB drive is ~100% full. the drive is mounted to a folder on another drive at path "D:\VMs\HDDs\MO\". i was experimenting with snapshots and created one for fun. i now want to delete the snapshot, which has grown to 100GB, but every time i try to delete it i get the following error:
Failed to delete the snapshot Snapshot 1 of the virtual machine Surfer7.

Unable to merge storage 'D:\VMs\HDDs\MO\MO.vdi' - not enough free storage space. .

Result Code: E_OUTOFMEMORY (0x8007000E)
Component: SessionMachine
Interface: IMachine {480cf695-2d8d-4256-9c7c-cce4184fa048}
how can i merge the 100GB snapshot into the original 2TB VDI? am i doomed because the drive that holds the original VDI is full?
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: Issue with deleting huge snapshot

Post by mpack »

A snapshot of a fixed size virtual drive? That's the worst of all worlds. The usual reason given for using a fixed size drive is performance (note I said usual reason given, not that the reason is valid). That's based on an assumption that dynamic drives need more seeks. Snapshots are always dynamic, so you get all the perceived downsides of dynamic plus the space hoggage of fixed... like I said, the worst of all possible choices.

If the drive is full then there's not a lot that can be done, except clone the snapshot using CloneVDI as already indicated above.
Dili
Posts: 13
Joined: 10. May 2010, 17:36
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Linux

Re: Issue with deleting huge snapshot

Post by Dili »

thanks for the reply, mpack!

i'll admit it wasn't a smart decision. i was new to snapshots at the time and didn't foresee the impacts it would have.

but i believe i've found a solution; shrink the size of the original 2TB VDI. the image itself has ~800GB of free space so i should be able to save at least 100GB. i would then be able to delete/merge the snapshot into the original since the physical drive will have enough space freed from compacting the VDI.

i'll let you know how it goes
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: Issue with deleting huge snapshot

Post by mpack »

The safest solution is the one I mentioned, though I didn't mention my assumption that since the source drive is full, you would need to use another drive to receive the clone. It would probably also be a good idea to turn on the "compact" option for the clone.

I don't exactly know how you intend to shrink a fixed size drive which has a snapshot attached, so I'll certainly be interested to hear how you did that.
Dili
Posts: 13
Joined: 10. May 2010, 17:36
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Linux

Re: Issue with deleting huge snapshot

Post by Dili »

i decided to do a test run of merging the snapshot before attempting it on my 2TB fixed-size VDI. the test was successful. here are the steps i took:
  • Used a test VM with only an OS VDI attached
  • Created a 20GB fixed-sized VDI and attached it to the VM
  • Added 10 1GB random contents files (files 1-10) to the 20GB VDI using Random Data File Creator (RDFC): http://www.bertel.de/software/rdfc/index-en.html
  • Took a snapshot of the VM
  • Added 5 more 1GB files (files 11-15) to the 20GB VDI
  • Delete files 4 and 8 (which are physically stored in the original 20GB VDI) and files 13 and 14 (which are physically stored in the snapshot VDI)
    This is to try and mimic the free sector sparsity of the 2TB VDI I'll be trying to merge
  • Compacted the original 20GB VDI: VBoxManage.exe modifyhd D:\VMs\Surfer7.1\NewVirtualDisk1.vdi --compact
    Original size: 20.0 GB (21,474,836,480)
    11.0GB (11,905,929,216) used, 8.90GB (9,565,757,440) free
    Compacted size: 10.0 GB (10,737,418,240)
    Compaction ratio: 50%
  • Used CloneVDI to merge the snapshot VDI into the original turning on compacting and converting to a dynamic disk
  • Removed the 20GB VDI from the VM including removing its snapshot VDI entry from the <snapshot> entry in the VM's .vbox config file
  • Deleted/merged the snapshot via Virtualbox
  • Created a new VM
  • Attached the merged 20GB VDI clone to the new VM
  • Powered-on the new VM
  • Confirmed the snapshot was properly merged into the original VDI by verifying files 1-3, 5-7, 9-12 and 15 were present in 20GB VDI
I will now attempt to do the same procedure on the 2TB fixed-sized VDI. I will also defrag and run sdelete on it to ensure smallest possible compacted size.
Last edited by Dili on 1. Feb 2014, 23:43, edited 3 times in total.
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: Issue with deleting huge snapshot

Post by mpack »

Your "modifyhd --compact" step is redundant. The merged VDI created by CloneVDI should also be incorporated into a new VM, not the original, as getting rid of snapshot crud from the original VM is quite hard - and impossible given the scenario posed in this thread (i.e. no diskspace left for merging).
Dili
Posts: 13
Joined: 10. May 2010, 17:36
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Linux

Re: Issue with deleting huge snapshot

Post by Dili »

thanks for the feedback, mpack! creating a new VM instead of playing around with settings of the old is a much better idea! i've modified my previous post to account for these new steps

as for the modifyhd --compact step, i don't have any spare drives big enough to fit merging the snapshot so i'm forced to free up space on the 2TB drive by compacting the original VDI. hopefully, it will free up enough space to be able to house the merged clone
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: Issue with deleting huge snapshot

Post by mpack »

Your "modifyhd --compact" step will be ineffective for most people, that's why I said it's redundant. For one thing this command doesn't really support snapshot chains - it will only eliminate zero blocks from the selected VDI, and there are unlikely to be many of those if you haven't done an sdelete step - which would expand the most recent snapshot to max size, so probably isn't a good idea in this scenario. Also, you really shouldn't be modifying the base VDI in a snapshot chain - it's supposed to be frozen and treated as read only.

I don't know how you got the compaction results you reported, but it'll just be luck if this did something useful and didn't damage the VM.
Dili
Posts: 13
Joined: 10. May 2010, 17:36
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win7, Linux

Re: Issue with deleting huge snapshot

Post by Dili »

thanks again for the feedback, mpack. just so you know, i did run sdelete before compacting and was able to significantly reduce the file size of the VDI. still, it didn't free up enough space on the physical 2TB drive to store the merged clone:

Original VDI file size: 1.81TB (1,993,946,177,536)
981GB (1,053,882,552,320) used, 875GB (940,052,865,024) free
Compacted size: 979GB (1,051,756,601,344)
Compaction Ratio: 52%
Free space on 2TB physical drive: 883.5GB (948,640,141,312)

here's what i've decided to do instead:
  • create a new dynamic disk of the same size (1.81TB) on the 2TB drive
  • move most of the files over from the original VDI
  • run sdelete and compact the original VDI again to further bring down its size
  • move the rest of the files over to the new dynamic disk.
Post Reply