Configure iSCSI client

Now, that you install the required software to use any iSCSI disk available (still not the case ? so go here ) on the network, it's time to configure the software and discover these new devices.

Discover the available target on a remote host

# iscsiadm --mode discovery --type sendtargets --portal IP_ADDRESS_OF_REMOTE_HOST_PROVIDING_ISCSI_TARGET

This will probably produce an output like this one :,1

Login to the iSCSI target to use it as local device block

# iscsiadm --mode node --target NAME_OF_ISCSI_TARGET --portal IP_ADDRESS_OF_REMOTE_HOST_PROVIDING_ISCSI_TARGET --login

if you use the output that I showed you above, you will have to use this command :
# iscsiadm --mode node --target --portal --login

Here, I supposed that is the server that provides iSCSI target.
And now, you can check what reference your system gives to this new block device on your system, so, let's check it out with the command :
# dmesg

You have to search in the output1 of the last command something like that :
scsi0 : iSCSI Initiator over TCP/IP
  Vendor: Openfile  Model: Virtual disk      Rev: 0   
  Type:   Direct-Access                      ANSI SCSI revision: 04
SCSI device sda: 30752768 512-byte hdwr sectors (15745 MB)
sda: Write Protect is off
sda: Mode Sense: 77 00 00 08
SCSI device sda: drive cache: write through
SCSI device sda: 30752768 512-byte hdwr sectors (15745 MB)
sda: Write Protect is off
sda: Mode Sense: 77 00 00 08
SCSI device sda: drive cache: write through
 sda: unknown partition table
sd 0:0:0:0: Attached scsi disk sda

As you can see on the last line, there is an attached scsi disk, named :

sda: unknown partition table

Note that there isn't also a partition table(line above the last one), so you have to create a partition table.
After that, create any file system type ( Ext2, Ext3, ReiserFS) and you can mount the device as a normal one.
As easy as that, enjoy it ! But remember, that your device can only be joined accross your network, so you can be limited by the speed transfer of your interface, router or switch by instance. Take it into account…

How to dettach an iSCSI target

List the available iSCSI device on the host with :

iscsiadm --mode node

Here was my output :,1,1,1,1

As you can see, I had some iSCSI target. In this last output, we can spot the ip address from which we get the iSCSI device, and the name of this iSCSI device (first and second field of each line). These are really important for us.
So, if I want to remove the iSCSI target with the name :

provided by ip address :

you have to do that :

iscsiadm --mode node --target --portal --op delete

As easy as that ! Let's check it, by still executing this command :
iscsiadm --mode node

We are ok, we don't see anymore the iSCSI device.

Note :
This error could appear, if you try to delete an iscsi target only with his name :

iscsiadm: —record required for delete operation

You have to remove an iSCSI target with his portal address. I manage once to remove an iSCSI target only with his name, and not his associated ip address. I guess, it worked because on this system, I did a discover on only one IP address.

How to list the available iSCSI target

If you simply want to known which iscsi target are available on the host, do that :

# iscsiadm --mode node
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License