0

I want to attach an iSCSI block device to my vagrant virtual machine, it is not a real device, i just want to simulate one using a file.

for example, If i want to add normal disk device, i may use the following:

config.vm.provider "virtualbox" do | p |
  unless File.exist?(disk)
    p.customize ['createhd', '--filename', disk, '--size', 1 * 1024]
  end
  p.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk]
end

In this code example, I simulate a new hard drive using a file...

The question is, what should be changed to make this acts like an iSCSI device. Actually, I am using vagrant to test my chef recipe for configuring block storage on my servers .

Thanks

Joseph
  • 3,085
  • 3
  • 23
  • 33

1 Answers1

2

You can do that -

Look at the specific virtualbox doc section on storageattach

--medium iscsi: For virtual hard disks only, this allows for specifying an iSCSI target. In this case, more parameters must be given

When "iscsi" is used with the --medium parameter for iSCSI support -- see Section 5.10, “iSCSI servers” --, additional parameters must or can be used:

--server The host name or IP address of the iSCSI target; required.

--target Target name string. This is determined by the iSCSI target and used to identify the storage resource; required.

--tport TCP/IP port number of the iSCSI service on the target (optional).

--lun Logical Unit Number of the target resource (optional). Often, this value is zero.

--username, --password Username and password (initiator secret) for target authentication, if required (optional).

the following command would attach a iSCSI drive

VBoxManage storageattach OneExample --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium iscsi --server 10.0.0.1 --target "<what you have setup on your NAS>" --tport 3260

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • what is target? does it mean the device name in the /dev filesystem? – Joseph Jun 02 '16 at 19:56
  • no, target is not from the VM, its where is your iSCSI target, if you setup a NAS most probably you have in the console somewhere a `iSCSI Target Management page` – Frederic Henri Jun 02 '16 at 20:01
  • Sorry, I do not understand what it is... I just want it to write to a file, like the example i showed in the question... – Joseph Jun 02 '16 at 20:42
  • to be clear, I do not have a real iSCSI device, I just want to simulate one for my testing to pass... just like the example i provided, there is no real hard drive, it uses a file to simulate it – Joseph Jun 02 '16 at 20:45
  • well, not sure you can do that for iSCSI device, target is mandatory to attach a iSCSI device on VirtualBox – Frederic Henri Jun 03 '16 at 06:21