Skip to main content

snapshot operation failed / VERR_FILE_NOT_FOUND

Today a virtual machine would not start, something about a missing disk. Oh, right...I had a raw disk assigned to the VM which is now gone. So, I just get rid of the disk and start the VM anyway, right?

$ VBoxManage list hdds 
[...]
UUID:        fa9fb372-3ea5-4849-8fe6-b60989b6948e
Parent UUID: base
Format:      VMDK
Location:   ../disk3.vmdk
State:       inaccessible
Type:        immutable

$ VBoxManage closemedium disk fa9fb372-3ea5-4849-8fe6-b60989b6948e
ERROR: Cannot close medium '../disk3.vmdk' because it has 1 child media
Details: code NS_ERROR_FAILURE (0x80004005), component Medium, interface
         IMedium, callee nsISupports
Context: "Close()" at line 1617 of file VBoxManageDisk.cpp
Ah, indeed. I had taken a snapshot of the VM as well when the raw disk was still attached. So let's delete the snapshot and/or the parent disk, OK?
$ VBoxManage snapshot foo delete 505f9e2d-3d63-468e-8a86-b883ab9a10be
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...
Progress state: NS_ERROR_FAILURE
Error: snapshot operation failed. Error message: Could not open the 
         medium '../disk3.vmdk'.
VD: error VERR_FILE_NOT_FOUND opening image file '../disk3.vmdk' (VERR_FILE_NOT_FOUND)

$ VBoxManage closemedium disk 701e85eb-548a-4b1f-b515-cc8dae424234
ERROR: Medium '../Snapshots/{701e85eb-548a-4b1f-b515-cc8dae424234}.vmdk' is attached 
            to 1 virtual machines
Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), component Medium, interface
          IMedium, callee nsISupports
Context: "Close()" at line 1617 of file VBoxManageDisk.cpp
Well, that's not working then. However, we can change the backing store of disk3.vmdk to something that does exist:
$ grep RW ../disk3.vmdk 
RW 63 FLAT "disk3-pt.vmdk" 0
RW 8129 ZERO 
RW 7736320 FLAT "/dev/disk3s1" 0

$ touch /tmp/foo

$ grep RW ../disk3.vmdk 
RW 63 FLAT "disk3-pt.vmdk" 0
RW 8129 ZERO 
RW 7736320 FLAT "/tmp/foo" 0
And now we can delete the snapshot and the disk; the VM should start afterwards:
$ VBoxManage snapshot foo delete 505f9e2d-3d63-468e-8a86-b883ab9a10be

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

$ VBoxManage closemedium disk fa9fb372-3ea5-4849-8fe6-b60989b6948e