VirtualBox UUID mismatch

Today I experienced a fine VirtualBox error when I tried to start one of my virtual machines. I know it’s not good to run my machines under root privileges, but that’s still something I need to figure out. The error message gives a pointer to the machine it’s storage medium, as you can see below:

VBoxManage startvm vm04-zca8 --type headless Waiting for VM "vm04-zca8" to power on... VBoxManage: error: UUID {e4676691-0855-4cd9-bcb0-060067659b14} of the medium 'vm04-zca8/zca-8.0.0.0-1147-system.vmdk' does not match the value {d2d3284b-6ccb-452b-8567-1a35842eb866} stored in the media registry ('/root/.VirtualBox/VirtualBox.xml') VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Medium, interface IMedium, callee

You can use the following command to discover which disks are attached to a specific virtual machine:

VBoxManage showvminfo vm04-zca8 --details

Now you know which disks are attached you can check the status of the disks by using the next command:

VBoxManage showhdinfo vm04-zca8/zca-8.0.0.0-1147-system.vmdk UUID: d2d3284b-6ccb-452b-8567-1a35842eb866 Accessible: no Access Error: UUID {e4676691-0855-4cd9-bcb0-060067659b14} of the medium 'vm04-zca8/zca-8.0.0.0-1147-system.vmdk' does not match the value {d2d3284b-6ccb-452b-8567-1a35842eb866} stored in the media registry ('/root/.VirtualBox/VirtualBox.xml') Logical size: 0 MBytes Current size on disk: 0 MBytes Type: normal (base) Storage format: VMDK Format variant: dynamic default In use by VMs: vm04-zca8 (UUID: 51c0dbc8-532c-4b55-a1e0-71c872a05ef3) Location: vm04-zca8/zca-8.0.0.0-1147-system.vmdk

Detach and remove disk from the virtual machine:

VBoxManage storageattach vm04-zca8 --storagectl "SCSI Controller" --port 0 --device 0 --medium none

VBoxManage closemedium disk vm04-zca8/zca-8.0.0.0-1147-system.vmdk

Attach the disk:

VBoxManage storageattach vm04-zca8 --storagectl "SCSI Controller" --port 0 --device 0 --type hdd --medium vm04-zca8/zca-8.0.0.0-1147-system.vmdk

Now the machine will start again:

VBoxManage startvm "vm04-zca8" --type headless Waiting for VM "vm04-zca8" to power on... VM "vm04-zca8" has been successfully started.