adding storage while vm is running

Discussions related to using VirtualBox on Linux hosts.
Post Reply
mMerlin
Posts: 9
Joined: 18. Sep 2015, 20:46

adding storage while vm is running

Post by mMerlin »

How can I configure a storage controller port to be hot pluggable, and currently empty, so that media can be inserted (and ejected) while the vm is running? I am looking at storageattach with --hotpluggable=on, but have not found a way to set that without any media currently attached.

Code: Select all

VBoxManage storageattach "«my vm name»" --storagectl "SATA" --port 2 --hotpluggable=on --type hdd --medium none
(with the vm powered off) fails with

Code: Select all

VBoxManage: error: No storage device attached to device slot 0 on port 2 of controller 'SATA'
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 412 of file VBoxManageStorageController.cpp
And without that, storageattach while the vm is running fails with

Code: Select all

VBoxManage: error: The machine is not mutable (state is Running)
Is it possible to set up a multiple GB fdd (.vdi?) and use that instead? Or have a vdi file that can be attached as usb storage? Should I be using a different storage controller?
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: adding storage while vm is running

Post by fth0 »

According to the documentation, there are two functionalities that may or not be what you want: Oracle VM VirtualBox Expert Storage Management and Storage Settings - Hot-pluggable.
mMerlin
Posts: 9
Joined: 18. Sep 2015, 20:46

Re: adding storage while vm is running

Post by mMerlin »

hot pluggable is precisely what I am trying to use. But I have not figured out how to actually make it work. A hint from that though may provide a workable path. The vm cannot be 'running', it must be 'paused', when changing the storage. Not really the way hot swap works for physical computers. It should be possible to eject, umount, and/or other os level commands to make sure that the media is not being access, then remove it from the storage controller, then put some other media in it's place, then get the guest os to see the replacement. With the VBoxManage commands, it is possible to skip the 'empty' step. Go straight from one media file to another.

I'll try some more testing.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: adding storage while vm is running

Post by fth0 »

AFAIU the VirtualBox documentation and the workflow you described, I think you'll need the combination of both VirtualBox functionalities, but I never tried them myself. Please let us know what you find out. ;)
Post Reply