iSCSI is one of these emerging protocols that is gaining more and more adoption thanks to the existence of fast IP networks everywhere. If you are just a geek like me that wants to try it out, you can setup Openfiler with a bunch of cheap disks, and voila, you've got yourself an inexpensive SAN. If you are more serious about it, then you can consider more sophisticated SANs connected through 1gb Ethernet or 10gb Ethernet.
When it comes to using Linux as the iSCSI initiator, there is information scattered all over the place, I will list down the steps that worked in my specific environment.
-
Edit /etc/iscsi/iscsid.conf to set
node.startup = manual
This will disable Linux from connecting automatically every time the machine boots.
- Run target discovery:
iscsiadm -m discovery -p <portal_IP> -t sendtargets
Where portal_ip is the address of the SAN.
- This will list all the volumes that are available from the device, we need to configure automatic reconnection for the targets we are interested. For this we need to run
iscsiadm -m node -T <target_name> -p <data_ip> --op update n node.startup -v automatic
target_name is the name of the iSCSI target we want to connect to, it is normally of the form iqn....
data_ip is the ip address of the data port on the SAN, normally this is the same address as the portal_IP
- Restart iSCSI
/etc/init.d/iscsi restart
- From this point, the disk can be treated as a regular direct attached storage device, we can format it, use it as a raw device, etc.
You may notice that the device name can be different between boots, sometimes /dev/sdb, sometimes /dev/sdc... For cases like that, if we want to add an entry in /etc/fstab, we need to use a persistent naming convention. We can refer to it by its id. The devices located in /dev/disk/by-id/ are symlinks that the OS makes for those devices.