--- layout: post title: Fibrechannel SAN under Linux --- ## Requirements * a qLogic qla2xxx fibrechannel HBA for the target (server) * another FC-HBA (can be anything, i used emulex because cheaper) for the initiator (client) * a LC-LC fibre cable ## Setup Connect the two FC HBAs with the LC-LC cable. Install the qlogic driver (qla2xxx) and targetcli (targetcli-fb in some cases) on the server. Then configure the qla driver by creating `/etc/modprobe.d/qla2xxx.conf` with the following content: `options qla2xxx qlini_mode="disabled"` This disables the HBAs initiator mode and allows us to create a target. A reboot is required for these changes to take effect. Next we need to get our HBAs WWN (compareable to MAC-Addresses on ethernet interfaces) to be able to target our initiator(s). To get your WWN run `more /sys/class/fc_host/host?/port_name`. If you have multiple HBAs or multiple ports run `more /sys/class/fc_host/host?/port_state` to identify the active port. As a last step, we need to configure the target. To enter the configuration utility, run `targetcli`. You can type `ls` to get an overview of all features, run `help` in any subdirectory to get specific info about which commands can be used here and how to use them. First we need to set up a backstore by either choosing a block device or using an image file on disk as our storage. Run `cd backstores` and then change into the subdir you want (eg `cd fileio`). Then run `create [size]`. This creates our backstore wich we then need to target. Go to `/qla2xxx` and `create `. Next we need to specify a lun (targetted backstore) by `cd /luns` and then `create /backstores/`. Finally we need to allow access by creating an access control entry by `cd /qla2xxx//acls` and then `create `. After a reboot of the initiator machine, the device should show up as a blockdevice with `lsblk` and should behave like any other blockdevice. To permanently save your config go to `/` and type `saveconfig`. Your config could look something like this: ![Config]({{ site.baseurl }}/images/fcsan_config.png)