VirtualBox How To Add iSCSI Storage using VBoxManage

#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


Tags:

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,

Latest Articles

  • Linux named / bind how to dump, view and clear the cache!
  • Centos 6 / 7 / 8 How To Change Default nameservers in /etc/resolv.conf when using DHCP / dhclient
  • Adobe Acrobat Reader for Linux to use and view XFA Fillable Forms
  • Debian Linux Mint Ubuntu iptables save and restore settings automatically onboot and reboot
  • Why SMART is not smart at all and doesn't properly predict disk errors that cause a kernel panic or crash
  • scp: ambiguous target error and solution
  • VirtualBox How To Add iSCSI Storage using VBoxManage
  • iSCSI on Centos 7 Configuration and Setup Guide for Initiator and Target
  • Python and BeautifulSoup4's BS4's Decompose Method To Remove Unwanted Inner Tags
  • httpd AH00534: httpd: Configuration error: No MPM loaded. solution
  • bash script to remove modules from httpd.conf that are not actually installed
  • bash scripting how to create a function
  • Centos 7 PHP MySQL Not Working Solution
  • Bash How To Cut or Split Natively And Get The LAST Field
  • Bash Script How To Manipulate Text/Strings By Searchig and Replacing Natively
  • How Does Cisco CUCM (Cisco Unified Communication Manager) Work?
  • What DNS Options Does Active Directory Offer in Windows Server 2008,2012,2016 ?
  • syntax error, unexpected T_SL in PHP Solution
  • grep regular expression match number range between specific numbers
  • bash how to print out lines of text within a range from the first occurrence