1

So I have a external SATA adapter and a VirtualBox Windows 10 VM. I regularly swap in and out hdds that I want the VM to be able to access. Now I can create the vmdk with no issue with VBoxManage internalcommands createrawvmdk -filename VMShare/external.vmdk -rawdisk /dev/$part.

Now I thought I'd be clever and write a script that just replaces each instance of external.vmdk when I swap in and out a new hdd. VirtualBox does not like this, and reports that the UUID {#} of the medium ~/VMShare/external.vmdk does not match the value {#} stored in the media registry (~/.config/VirtualBox/VirtualBox.xml).

Now I've tried messing with the xml files to match up the UUIDs but with no luck. I've also tried VBoxManage storageattach Windows --storagectl "SATA" --port 1 --device 0 --type hdd --medium none to wipe that spot clear, then reload the vmdk, but I get the same error. I suspect I need to refresh something somehow, but I'm really not sure which setting I need to hit next. Any thoughts?

1

Found the answer in the Arch wiki!

The specific command was VBoxManage closemedium disk VMShare/external.vmdk

Full code:

# remove old vmdk
echo "Removing old"
eval "VBoxManage storageattach Windows --storagectl "SATA" --port 1 --device 0 --type hdd --medium none"
eval "VBoxManage closemedium disk VMShare/external.vmdk"
eval "rm VMShare/external.vmdk"

# create new vmdk and add it
echo "Creating new"
eval "VBoxManage internalcommands createrawvmdk -filename VMShare/external.vmdk -rawdisk /dev/$part"
eval "VBoxManage storageattach Windows --storagectl "SATA" --port 1 --device 0 --type hdd --medium VMShare/external.vmdk"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.