VirtualBox: Snapshots filling up disk, what to do

2015/01/08 at 09:01

So this has happened to me again. I didn’t pay attention to VirtualBox snapshots filling up my „vm“ partition. Yesterday, less than 2 GB were left, so I eventually thought of deleting snapshots.

vbox-snapshotsIn VirtualBox (VBox), deleting a snapshot means merging it with the originally created virtual disk image (VDI) file (in my case, Suse13.vdi). But that works only if there’s enough space on the partition for that operation. As I found, to merge a 10 GB snapshot file into a 15 GB original VDI file, you need at least 5 GB free space for the temporary files that VBox creates. Unfortunately, there’s no way to instruct VBox to use space on another partition for those temporary files.

What I found after a lot of googling was that most people revert to cloning the virtual machine (VM), then discarding the original VM (that is, deleting the original VDI file and all the snapshot files), then creating a new VM using the cloned VDI. Similar problem here, since there’s no way to tell VBox to create the VDI clone on a different partition, you’re stuck when there’s not enough space on your disk. For that reason, you can’t use the graphical VBox interface, but you can use the command-line interface. On Linux, that would be a command like this:

vboxmanage clonevdi linux/Suse13.vdi /mnt/goobay1/Suse13clone.vdi

For me, that created a VDI clone on another partition — so far, so good. Unfortunately, that clone wouldn’t boot. Not sure if that could be fixed — I gave up fiddling to get it working after half an hour.

Eventually, I found a solution on the Net that was too obvious to find out myself: Simply move the snapshot files to another partition, create symbolic links in the original location, then merge the snapshot files. D’uh. It goes like this (on Unix-style operating systems):

(1) Find where the snapshot files are. They’re normally near your VDI file, in a folder called Snapshots.

(2) Move the snapshot files with commands like this:

Atlas/vm/linux/Suse13/Snapshots> mv {eadb26a3-df2b-4481-be35-abbc5fdc27a4}.vdi /mnt/goobay1/MyLinuxSnapshotsNew/

(3) Create symbolic links:

Atlas/vm/linux/Suse13/Snapshots> ln -s /mnt/goobay1/MyLinuxSnapshotsNew/\{eadb26a3-df2b-4481-be35-abbc5fdc27a4\}.vdi .

In the example above, that „shrunk“ the file size from 9 GB to 75 bytes, thus freeing up 9 GB on the VM’s partition. I did likewise for another snapshot file, which together freed up 25 GB, more than enough to eventually delete (merge) the snapshot files. (After a successful merge, VBox will delete what it thinks is the snapshot file, but that’s actually the symbolic link. To free up space on your „remote“ partition, you’ll then manually have to delete the snapshot file.)

Important: Make sure your VM is shut down properly. Don’t suspend it or even leave it running!

Important: Before deleting (merging) the snapshots from the VBox graphical interface, make sure your VM is happy with the symbolic links, and still starts up. If it doesn’t, you can still remove the symbolic link, and move back the original snapshot file. (This won’t solve the problem of not having enough disk space, but at least it will leave your VM working.) Starting up the VM when one or more snapshot files are on a „remote“ partition may take a little longer than usual; don’t worry, that’s expected.

Takeaway: Don’t use VBox snapshots, unless you know what you’re doing (which I obviously didn’t). From now, what I do is to simply copy the VDI file from time to time, which gives me a backup in case the VDI file gets borked for some reason.

Good luck!


Entry filed under: Uncategorized. Tags: , , .

Happy New Year, and happy new Free Software Foundation video 2015 im Rückblick

Januar 2015
« Dez   Jan »

Aktuelle Beiträge

Enter your email address to follow this blog and receive notifications of new posts by email.

Schließe dich 208 Followern an

%d Bloggern gefällt das: