{"id":1189,"date":"2013-12-20T10:16:07","date_gmt":"2013-12-20T15:16:07","guid":{"rendered":"https:\/\/infotechguy.net\/?p=1189"},"modified":"2025-02-22T13:12:51","modified_gmt":"2025-02-22T18:12:51","slug":"linux-fibre-channel-scsi-target-using-scst","status":"publish","type":"post","link":"https:\/\/infotechguy.net\/?p=1189","title":{"rendered":"Linux &#8212;  Fibre Channel SCSI Target using SCST"},"content":{"rendered":"<p>Fibre channel or Fiber Channel is also another way to present SCSI devices over a network medium using a complete different protocol suite then my previous article on <a title=\"Creating an iSCSI LUN on Linux to be used with VMware 5.1(ESXi)\" href=\"https:\/\/infotechguy.net\/iscsi-using-logical-lun-with-hyper-v-5-1\/\">iSCSI<\/a>. With Fiber Channel transfer speeds and protocol delivery is much faster than iSCSI. The fundamental difference between the two is iSCSI uses TCP\/IP protocol suite to deliver SCSI messages, and Fiber Channel uses Fiber channel to deliver SCSI message. This means that you will have to have network equipment that is Fiber Channel capable, such as Fiber Channel switches, Fiber Channel HBA (similar to TCP\/IP NICs), etc. For the purposes of this article I will not go into how Fiber Channel works, or how it does it&#8217;s job of delivering SCSI messages two and from SCSI initiators and SCSI targets. This article will step through how to turn a Linux machine into a Fiber channel SCSI Target. There are a few things you will need to even attempt this:<\/p>\n<ul>\n<li>A Linux machine running Kernel 3.2+<\/li>\n<li>SCST and SCSTAdmin (see below steps)<\/li>\n<li>A separate machine that will act as a Fiber channel initiator, this can be another Linux machine, or an ESX host, etc<\/li>\n<li>At least two(2) Fiber channel HBA&#8217;s with one physical WWN port each installed in both machines<\/li>\n<li>A OM2 or 3 Multi-mode Fiber cable with connectors capable of being used with the HBAs<\/li>\n<li>Enough disk space to create a Virtual Disk so we may present it as a LUN<\/li>\n<li>And lastly, some excitement!! you are about to enter the new world of Fiber Channel!!<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>Preparing the builds<\/h2>\n<ol>\n<li>\n<h4>Identify card Qlogic card<\/h4>\n<p>You may see these types of errors on boot or in your messages log.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">dmesg | grep Fibre\r\ndmesg | Fiber<\/pre>\n<\/li>\n<li>\n<h4>Download firmware and copy to firmware directory<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">wget http:\/\/ldriver.qlogic.com\/firmware\/ql2400_fw.bin\r\ncp ql2400_fw.bin \/lib\/firmware\/<\/pre>\n<p><strong>OR<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># preferred\r\nwget http:\/\/ftp.us.debian.org\/debian\/pool\/non-free\/f\/firmware-nonfree\/firmware-qlogic_0.36+wheezy.1_all.deb\r\ndpkg -i  firmware-qlogicf_0.36+wheezy.1_all.deb<\/pre>\n<p><strong>Check if already exists<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ls \/lib\/firmware\/ | grep ql*<\/pre>\n<\/li>\n<li>\n<h4>Remove the current qla2xxx module<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">rmmod qla2xxx\r\necho blacklist qla2xxx &gt;\/etc\/modprobe.d\/blacklist-qla2xxx.conf\r\nupdate-initramfs -u\r\nreboot<\/pre>\n<p>Check if module is running after reboot:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">lsmod | grep ql*<\/pre>\n<\/li>\n<li>\n<h4>Download dependencies to build scst and Patch the kernel<\/h4>\n<p><b>Build Dependencies<\/b><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev gcc libncurses5-dev linux-headers-$(uname -r) lsscsi patch subversion<\/pre>\n<\/li>\n<li>\n<h4>Get Kernel and SCST Source:<\/h4>\n<p><b>Kernel Source:<\/b><br \/>\n&lt;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mkdir \/tmp\/KernelSource\r\ncd \/tmp\/KernelSource\r\napt-get source linux-source-3.2\r\n\r\n#Make an easy symbolic link\r\nln -s linux-3.2.51 ..\/Linux<\/pre>\n<p><b>SCST Source:<\/b><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd \/tmp\/\r\nsvn co https:\/\/svn.code.sf.net\/p\/scst\/svn\/trunk scst<\/pre>\n<\/li>\n<li>\n<h4>Patching the Kernel Source pre-build:<\/h4>\n<p><strong>Now we patch the kernelsource<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd Linux\r\npatch -p1 &lt; {your_scst_source_directory}\/scst\/kernel\/scst_exec_req_fifo-3.2.patch\r\npatch -p1 &lt; {your_scst_source_directory}\/scst\/iscsi-scst\/kernel\/patches\/put_page_callback-3.2.patch<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/5ozj8tbwh\/scst_patched.png\" alt=\"\" \/><\/li>\n<\/ol>\n<h2>Build the newly patched Kernel<\/h2>\n<ol>\n<li>\n<h4>Enabling the SCST Target Module Source<\/h4>\n<p>Before we run <strong>menuconfig <\/strong>to select the items to build for our new kernel, we have to replace the current <strong>qla2xxx module<\/strong> (pre-packaged with the linux source code we downloaded) with <strong>SCST qla2x00t target module<\/strong>. Reason being, the default <strong>qla2xxx <\/strong>is only an <em>Initiator enabled<\/em>. I could not figure out a way to manually switch the module to <em>Target enabled<\/em> it without rebuilding the module (which will will do below). So, we will rename the current qlax2xxx source directory and symbolically link the SCST qla2x00t module source directory respectively. This will allow in menuconfig to enable this module to be built during kernel compile.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mv {your_kernel_source}\/drivers\/scsi\/qla2xxx {your_kernel_source}\/drivers\/scsi\/qla2xxx_orig\r\nln -s {your_scst_source}\/scst\/qla2x00t {your_kernel_source}\/drivers\/scsi\/qla2xxx<\/pre>\n<\/li>\n<li>\n<h4>Enabling modules to be built with menuconfig<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#Now we run menuconfig\r\nmake menuconfig<\/pre>\n<p><strong>Make sure using CFQ I\/O scheduler<br \/>\n<\/strong><em>&#8220;Enable the block layer&#8221; &#8211;&gt; &#8220;IO Schedulers&#8221; &#8211;&gt; Default I\/O scheduler<\/em><br \/>\n<img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/z94ddqydd\/cfq_enabled.png\" alt=\"\" \/><\/p>\n<p><strong>Change Preemption Model to Server Mode:<br \/>\n<\/strong><em>Processor type and features&#8221; &#8211;&gt; Preemption Model &#8211;&gt; No Forced Preemption (Server)<\/em><br \/>\n<img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/q7pu050g1\/nopremp.png\" alt=\"\" \/><\/p>\n<p><strong>Last but not least make sure the SCST qla2xxx target mode is enabled and will be built.<\/strong><br \/>\n<em>&#8220;Device Drivers&#8221; &#8211;&gt; &#8220;SCSI device support&#8221; &#8211;&gt; &#8220;SCSI low level drivers&#8221; &#8211;&gt; &#8220;Qlogic 2xxx target mode support&#8221;<\/em><br \/>\n<img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/5vd8bwl1d\/qlogic_Target.png\" alt=\"\" \/><br \/>\n<em><strong>NOTICE:<\/strong> You will not see this option if <strong>step 1-&#8220;Enabling the SCST Target Module Source&#8221;<\/strong> above was not performed.<\/em><\/li>\n<li>\n<h4>Start the build (This may take some time, grab a beer!)<\/h4>\n<p>(Following <a href=\"http:\/\/www.tomlecluse.be\/blog\/20110902\/scst-and-scstadmin-ubuntu-1104\" target=\"_blank\" rel=\"noopener noreferrer\">Tom&#8217;s kernel build suggestions<\/a>)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">export CONCURRENCY_LEVEL=5  \/\/for Quad Core Processors\r\nmake-kpkg clean\r\nfakeroot make-kpkg --initrd --append-to-version=-scst-enabled kernel-image kernel-headers<\/pre>\n<p><strong>Two(2) .deb files will be created in the parent directory, image and headers. Install them.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">dpkg -i linux-image-3.2.51-scst-enabled_3.2.51-scst-enabled-10.00.Custom_amd64.deb \r\ndpkg -i linux-headers-3.2.51-scst-enabled_3.2.51-scst-enabled-10.00.Custom_amd64.deb \r\nreboot #or coldreboot if debian<\/pre>\n<p><strong>Upon reboot you should see new GRUB options:<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/wt2jzwgap\/grub_scst_enabled.png\" alt=\"\" \/><\/li>\n<li>\n<h4>Build SCST.<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd {scst_source_directory}\r\nmake 2release\r\nmake all\r\nBUILD_2X_MODULE=y CONFIG_SCSI_QLA_FC=y CONFIG_SCSI_QLA2XXX_TARGET=y make all install<\/pre>\n<\/li>\n<li>\n<h4>Enabling the new modules on boot<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vi \/etc\/modules\r\n#ensure you have this\r\nscst\r\nqla2xxx_scst\r\nqla2x00tgt\r\nscst_vdisk\r\nscst_user\r\nscst_disk\r\n<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">reboot #or coldreboot if debian<\/pre>\n<p><em><strong>NOTICE: <\/strong>A reboot is not necessary to get the modules loaded. You can manually load them 1-by-1 using modprobe {module name}. I like to be thorough and make sure they are loading on boot, just in case I ever have to reboot my Fibre Channel Targets will come back up.<\/em><br \/>\n<img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/9p6ol22dd\/qla2xxx_scst_loading.png\" alt=\"\" \/><br \/>\nCheck to see if all modules loaded on startup:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">lsmod | grep scst<\/pre>\n<\/li>\n<li>\n<h4>Build SCSTadmin<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd {your_scst_source}\/scstadmin\r\nmake\r\nmake install\r\n\r\n#check install\r\nscstadmin<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Collecting current configuration: done.\r\n\r\nNo valid operations specified.\r\n<\/pre>\n<\/li>\n<\/ol>\n<h2>Create VDISKS and Configuring SCST and LUNs<\/h2>\n<ol>\n<li>\n<h4>Creating VDISKs<\/h4>\n<p>Use dd to create a image file filled of 0&#8217;s<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">cd \/opt\/RAIDMOUNT\/LUNs\r\ndd if=\/dev\/zero of=LinuxLUN01.img bs=1M count=1000000\r\ndd if=\/dev\/zero of=WindowsLUN01.img bs=1M count=1000000<\/pre>\n<\/li>\n<li>\n<h4>Make scst.conf<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">i \/etc\/scst.conf<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">HANDLER vdisk_fileio {\r\n\tDEVICE LinuxDisk {\r\n\t\tfilename \/opt\/RAIDMOUNT\/LUNs\/LinuxLUN04.img\r\n\t}\r\n\tDEVICE WindowsDisk {\r\n\t\tfilename \/opt\/RAIDMOUNT\/LUNs\/WindowsLUN12.img\r\n\t}\r\n}\r\nTARGET_DRIVER qla2x00t {\r\n\tTARGET 21:00:00:1b:32:1b:d2:35 {\r\n\t\tHW_TARGET\r\n\r\n\t\tenabled 1\r\n\t\trel_tgt_id 1\r\n\r\n\t\tGROUP host1 {\r\n\r\n\t\t\tLUN 4 LinuxDisk\r\n\t\t\tLUN 12 WindowsDisk\r\n\r\n\t\t\tINIITATOR 10:00:00:00:c9:63:94:9e\t\r\n\t\t\tINITIATOR 10:00:00:00:c9:63:94:9f\r\n\t\t}\r\n\t}\r\n\r\n\tTARGET 21:01:00:1b:32:3b:d2:35 {\r\n\t\tHW_TARGET\r\n\r\n                enabled 1\r\n\t\trel_tgt_id 2\r\n\t\r\n\t\tGROUP host2 {\r\n\t\t\tLUN 4 LinuxDisk\r\n\t\t\tLUN 12 WindowsDisk\r\n\r\n\t\t\tINITIATOR 21:00:00:1b:32:13:e4:07\r\n                        INITIATOR 21:01:00:1b:32:33:e4:07\t\r\n       \t\t }\r\n\t}\r\n}\r\n<\/pre>\n<p><strong>TARGET<\/strong> &#8212; is the Port WWN of the HBA on our Linux SCSI Target<br \/>\n<strong>INITIATOR<\/strong> &#8212; is the Port WWN of the HBA on our SCSI Initiators<br \/>\n<strong>Group<\/strong> &#8212; is just a name to group together INITIATORS<br \/>\n<strong>LUN ID <\/strong>&#8212; Used to identify numerically a LUN uniquely, only up to 255 ( I believe), and these must be unique for each LUN per Target PWWN.<br \/>\nIn summary of the config above, I am presenting both LinuxLUN04 and WindowsLUN12 to both host1 and host2<\/li>\n<li>\n<h4>Issue a scstadmin reload<\/h4>\n<p><strong>Issue a scstadmin -conf \/etc\/scst.conf<br \/>\nDO NOT do a service scst restart<\/strong><\/li>\n<li>\n<h4>Check Initiator (in this case a ESX host)<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/s6.postimg.org\/8lhyvcsch\/esx_SCST.png\" alt=\"\" \/><\/li>\n<\/ol>\n<p><strong>Sources:<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/scst.sourceforge.net\/qla2x00t-howto.html\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/scst.sourceforge.net\/qla2x00t-howto.html<\/a><\/li>\n<li><a href=\"http:\/\/www.tomlecluse.be\/blog\/20110902\/scst-and-scstadmin-ubuntu-1104\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.tomlecluse.be\/blog\/20110902\/scst-and-scstadmin-ubuntu-1104<\/a><\/li>\n<li><a href=\"http:\/\/www.howtoforge.com\/how-to-create-a-fiber-channel-san-using-scst-with-qlogic-hba-on-linux-debian-6\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.howtoforge.com\/how-to-create-a-fiber-channel-san-using-scst-with-qlogic-hba-on-linux-debian-6<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Fibre channel or Fiber Channel is also another way to present SCSI devices over a network medium using a complete different protocol suite then my previous article on iSCSI. With Fiber Channel transfer speeds and&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":4240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[110],"class_list":["post-1189","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-san"],"_links":{"self":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/1189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1189"}],"version-history":[{"count":3,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions"}],"predecessor-version":[{"id":4271,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/1189\/revisions\/4271"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/media\/4240"}],"wp:attachment":[{"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}