#to show all
VBoxManage list vms
#show ONLY running vms
VBoxManage list runningvms
VBoxManage storageattach test --storagectl "SATA" --port 0 --device 0 --type hdd --medium iscsi --server 192.168.1.91 --target "iqn.2018-12.local.abcrandom.target:sdb" --initiator "iqn.1982-01.ca.bla.tld:abc123" --tport 3260 --lun 1
iSCSI disk created. UUID: 3bbdd942-f3b0-4bc9-8f22-b0118f6f11ec
--server = the IP address of the iSCSI target server
--target = the target on the iSCSI srever
--initiator = your initiator name (eg. the equivalent of /etc/iscsi/initiator.iscsi)
--lun 1 (or whatever LUN number
Troubleshooting
If the disk creates successfully but VBox says it is inacessible it means you have probably specified something wrong in the flags above. Eg. a typo in your target, initiator, forgetting your LUN
UUID Already Exists
VBoxManage storageattach test --storagectl "SATA" --port 0 --device 0 --type hdd --medium iscsi --server 192.168.1.91 --target "iqn.1982-01.ca.bla.tld:abc123"
VBoxManage: error: Cannot register the hard disk '192.168.1.91|iqn.1982-01.ca.bla.tld:abc123' {16b201f8-da53-499c-86ec-753a8b940e58} because a hard disk '192.168.1.91|iqn.1982-01.ca.bla.tld:abc123' with UUID {8cd2dd6e-9b69-488c-81f6-22fa96da0a2f} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "CreateMedium(Bstr("iSCSI").raw(), bstrISCSIMedium.raw(), AccessMode_ReadWrite, DeviceType_HardDisk, pMedium2Mount.asOutParam())" at line 608 of file VBoxManageStorageController.cpp
#list all hdds
vboxmanage list hdds
UUID: 8cd2dd6e-9b69-488c-81f6-22fa96da0a2f
Parent UUID: base
State: inaccessible
Type: normal (base)
Location: 192.168.1.91|iqn.1982-01.ca.bla.tld:abc123
Storage format: iSCSI
Capacity: 0 MBytes
Encryption: disabled
#let's delete it
vboxmanage closemedium disk 8cd2dd6e-9b69-488c-81f6-22fa96da0a2f --delete
#uh oh iSCSI disks can't be deleted this way
vboxmanage closemedium disk 8cd2dd6e-9b69-488c-81f6-22fa96da0a2f --delete
VBoxManage: error: Medium format 'iSCSI' does not support storage deletion
VBoxManage: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MediumWrap, interface IMedium, callee nsISupports
VBoxManage: error: Context: "DeleteStorage(pProgress.asOutParam())" at line 1603 of file VBoxManageDisk.cpp
VBoxManage: error: Failed to delete medium. Error code Unknown Status -2135228407 (0x80bb0009)
Sometimes just using closemedium before works:
vboxmanage closemedium disk 8cd2dd6e-9b69-488c-81f6-22fa96da0a2f
Either way after the above you should be able to retry to connect your iSCSI disk
virtualbox, iscsi, vboxmanage, vms, runningvms, storageattach, storagectl, quot, sata, hdd, medium, server, iqn, abcrandom, sdb, initiator, ca, bla, tld, abc, tport, lun, disk, uuid, bbdd, bc, ec, ip, srever, eg, equivalent, etc,