I'm going to be describing this process using Fedora, but any Linux that is using iscsiadm should use the same sort of configurations. To start off make sure you have the proper packages installed.
# yum install -y iscsi-initiator-utils
Now you can easily see what iscsi targets are available on your portal (server):
# iscsiadm -m discovery -t st -p 10.20.0.2 10.20.0.2:3260,1 iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416 # iscsiadm -m node -l Logging in to [iface: default, target: iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416, portal: 10.20.0.2,3260] Login to [iface: default, target: iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416, portal: 10.20.0.2,3260]: successful
The first command will search for all targets available, the second will then login (-l) to all the found targets. If you only need to login to a specific target you can use the following:
# iscsiadm -m node --target "iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416" --portal "10.20.0.2:3260" -l Logging in to [iface: default, target: iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416, portal: 10.20.0.2,3260] Login to [iface: default, target: iqn.1986-03.com.sun:02:bf1479ba-a71d-c9d7-ab45-d51a1dca3416, portal: 10.20.0.2,3260]: successful
Once you have logged in to your target(s) you'll see them as a disk if you run fdisk -l
:
# fdisk -l Disk /dev/sdc: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xae668fde Device Boot Start End Blocks Id System /dev/sdc1 1 26108 209712478+ 8e Linux LVM
I've already partitioned my target with fdisk
but you may want to do the same. My primary use for iSCSI is to serve up a single large volume (zvol) and then I use LVM to give me volumes to use with my virtual machines.