(this is similar to my How to tell virsh: save state of VM and vdisk, but not attached disk? but for VirtualBox and raw devices)

How do I tell VirtualBox to NOT preserve the state of raw attached devices when snapshotting? Details:

  • I created a VMDK on the host machine as follows:

VBoxManage internalcommands createrawvmdk -filename sdb.vmdk -rawdisk /dev/sdb

and attached it to the guest.

  • /dev/sdb now shows up as a pure device file on the guest.

  • My clever idea: mount /dev/sdb, and any changes I make there will be preserved across snapshots, since VirtualBox isn't going to save the state of /dev/sdb

  • I was wrong. By default, VirtualBox will save the state of /dev/sdb: if you revert to an earlier snapshot, anything you did on /dev/sdb will be wiped out.

  • In other words, my cunning plan failed.

  • Is there any way to make it work? I realize I could mount /dev/sdb on the host and then have the guest mount it or sshfs it or something, but is there a VirtualBox option that says "do not preserve/restore /dev/sdb state when snapshotting"?

  • I'm trying to use a VM to determine how I want to install CentOS 7.2, and, ideally, I'd like the guest to be as close to a real system as possible.

I'd like to thank @gilles for his excellent answer, but it turns out that it doesn't quite work.

When I shutdown, detach /dev/sdb, take a snapshot and then later restore the snapshot and re-attach /dev/sdb, I see this (click for full size):

enter image description here

Basically, VirtualBox refuses to touch /dev/sdb, even if I attach it. Rather, it uses differencing disks to store any changes I make, and these changes are reverted when I restore snapshots.

You can actually see the differencing disks in Media Manager:

enter image description here

but I can't find a way to do anything useful with them.

I'm leaving my upvote and checkmark for gilles answer, but will go back to using more normal methods to mount /dev/sdb on the guest.

1 Answer 1


You must unmount the device before making the snapshot. Otherwise, when resuming, the state of the device would not match the state of the disk cache in the guest kernel, which would result in massive corruption.

After you've unmounted the device, detach it from the virtual machine before making the snapshot.

  • Actually, I do my snapshots after shutting down the system, so all I'd have to do is detach /dev/sdb. Not a bad idea... I just have to be careful to remember to do it each time before snapshotting, and then reattaching before rebooting.
    – user2267
    Dec 11, 2016 at 15:18

You must log in to answer this question.