How To Create A Fiber Channel SAN Using SCST With QLogic HBA On Linux Debian 6
I created this how-to as none of the other instructions on the internet work correctly. This is done specifically for Ubuntu and Debian and is based on the 2.6.32 although with some common sense this should work with any distro and any kernel.
You should have a basic Linux understanding copy pasting everything probably won't work.
First make sure you are able to see the boot menu and change boot options.
nano /etc/default/grub
# out hidden boot and timeout and save:
update-grub
Install pre-requisites for build:
apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev gcc libncurses5-dev linux-headers-$(uname -r) lsscsi patch subversion
apt-get build-dep --no-install-recommends linux-image-$(uname -r)
Make sure QLogic firmware is available:
ls /lib/firmware/ | grep ql*
If missing then download firmware from http://ldriver.qlogic.com/firmware/
# (for debian to install firmware)
mkdir /root/tmp
cd /root/tmp
wget http://ftp.au.debian.org/debian/pool...ueeze1_all.deb
dpkg -i firmware-qlogic_0.28+squeeze1_all.deb
ls /lib/firmware/ | grep ql*
Download SCST Trunk including the QLogic Target Drivers:
cd /root
svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk scst
Unload the system default drivers:
rmmod qla2xxx
echo blacklist qla2xxx >/etc/modprobe.d/blacklist-qla2xxx.conf
Download and install your kernel source and link the /usr/src/linux:
cd /usr/src
apt-get install linux-source-2.6
tar xjf linux-source-2.6.32.tar.bz2
ln -s /usr/src/linux-source-2.6.32 Linux
Patch source kernel to prepare to load SCST QLogic drivers (I'm sure theres more to it):
cd /usr/src/linux-source-2.6.32
patch -p1 < /root/scst/scst/kernel/scst_exec_req_fifo-2.6.32.patch
Copy running config file to be used in new kernel:
cp -vi /boot/config-`uname -r` .config
Backup kernel original QLogic drivers and link to SCST QLogic drivers.
mv /usr/src/linux/drivers/scsi/qla2xxx /usr/src/linux/drivers/scsi/qla2xxx_orig
ln -s ~/scst/trunk/qla2x00t /usr/src/linux/drivers/scsi/qla2xxx
Make menuconfig and ensure QLogic target mode is selected following the below route.
make menuconfig
Device Drivers->SCSI device support->SCSI low level drivers->Qlogic 2xxx target mode support
Make the build faster if you have multiple cores:
export CONCURRENCY_LEVEL="number of CPU cores plus 1"
Build the kernel into a deb package:
cd /usr/src/linux
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-scst kernel-image kernel-headers
Install new kernel:
cd /usr/src/
dpkg -i linux-image-2.6.32-scst_2.6.32-scst-10.00.Custom_amd64.deb
dpkg -i linux-headers-2.6.32-scst_2.6.32-scst-10.00.Custom_amd64.deb
In Ubuntu you may need to update the RAM disk before reboot. Google the process but I think it is:
update-initramfs -u
reboot
Boot into newly installed kernel.
Select a build mode that suits your needs, e.g. optimal performance or debugging SCST. The default mode is debug mode. Here is how to switch to release mode:
cd /root/scst
make 2release
Now build the SCST kernel modules.
cd /root/scst/scst/src
make all
make install
Build the QLogic target driver as follows:
cd /root/scst
BUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y \
make -s -C qla2x00t/qla2x00-target install
ls -l /lib/modules/`uname -r`/extra/qla2*
Insert the kernel modules with the 'modprobe' program and add to startup modules:
nano /etc/modules
Add the below text to the bottom and save /etc/modules:
scst qla2xxx_scst qla2x00tgt scst_vdisk scst_user scst_disk
Manually load the modules or reboot.
modprobe scst
modprobe qla2xxx_scst
modprobe qla2x00tgt
modprobe scst_vdisk
modprobe scst_user
modprobe scst_disk
Locate and record Target WWN(s):
cat /sys/class/fc_host/host*/port_name
Install SCST Admin:
cd /root/scst/scstadmin
make
make install
Configure QLogic Device, Create Group, Create Virtual Disk, Create LUN and group it all together.
scstadmin -enable_target "target WWN" -driver qla2x00t
scstadmin -add_group "group name" -driver qla2x00t -target "target WWN"
scstadmin -add_init "initiator wwn" -driver qla2x00t -target "target wwn" -group "group name"
scstadmin -add_init "additional initiator wwn" -driver qla2x00t -target "target wwn" -group "group name"
Create and use virtual Drive as LUN - will take ages, using disk1 located at /mnt/ as example file path.
dd if=/dev/zero of="file path" bs="size in kb" count=512
ls -l /mnt/disk1
file /mnt/disk1
scstadmin -open_dev "VD Name being disk1" -handler vdisk_fileio -attributes filename=/mnt/disk1
scstadmin -add_lun "lun ID" -driver qla2x00t -target "Target WWN" -group "group name" -device "VD Name being disk1"
scstadmin -write_config /etc/scst.conf
Still working on issue where script /etc/init.d/scst does not run on boot. To get around this I simply isntalled sudo and added a command to /etc/rc.local.
apt-get install sudo
nano /etc/rc.local
Add the below command to the bottom of the file but before the end 0:
sudo scstadmin -config /etc/scst.conf
Here is an example /etc/scst.conf file:
HANDLER vdisk_fileio {
DEVICE VDisk01 {
filename /vdisk/VDisk01
}
}
TARGET_DRIVER qla2x00t {
TARGET 21:00:00:1b:32:08:6d:ea {
HW_TARGET
enabled 1
rel_tgt_id 1
GROUP esxi {
LUN 0 VDisk01
INITIATOR 20:00:00:1b:32:08:a7:c3
INITIATOR 21:00:00:1b:32:08:a7:c3
}
}
TARGET 21:01:00:1b:32:28:6d:ea {
HW_TARGET
enabled 0
}
}