<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/default.xsl"?>
<fr:tree xmlns:fr="http://www.forester-notes.org" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xml="http://www.w3.org/XML/1998/namespace" root="false" base-url="/">
  <fr:frontmatter>
    <fr:authors>
      <fr:author>
        <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
      </fr:author>
    </fr:authors>
    <fr:date>
      <fr:year>2018</fr:year>
      <fr:month>11</fr:month>
      <fr:day>7</fr:day>
    </fr:date>
    <fr:date>
      <fr:year>2025</fr:year>
      <fr:month>8</fr:month>
      <fr:day>28</fr:day>
    </fr:date>
    <fr:uri>https://xw.is/001K/</fr:uri>
    <fr:display-uri>001K</fr:display-uri>
    <fr:route>/001K/</fr:route>
    <fr:title text="FreeBSD › FreeBSD fiber channel target"><fr:link href="/freebsd-index/" title="FreeBSD" uri="https://xw.is/freebsd-index/" display-uri="freebsd-index" type="local">FreeBSD</fr:link> › <fr:link href="/freebsd/" title="FreeBSD" uri="https://xw.is/freebsd/" display-uri="freebsd" type="local">FreeBSD</fr:link> fiber channel target</fr:title>
  </fr:frontmatter>
  <fr:mainmatter>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Prerequisites">Prerequisites</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>You need: <html:ul><html:li>A fiber channel card that supports target mode, e.g. QLogic QLE2462.</html:li>
    <html:li><fr:link href="/freebsd/" title="FreeBSD" uri="https://xw.is/freebsd/" display-uri="freebsd" type="local">FreeBSD</fr:link> with a kernel that supports your card, e.g <fr:link href="/freebsd-isp.4" title="isp(4)" uri="https://xw.is/freebsd-isp.4" display-uri="freebsd-isp.4" type="local">isp(4)</fr:link>.</html:li>
    <html:li>a ZFS zvol.</html:li></html:ul></html:p>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Create a ZFS zvol">Create a ZFS zvol</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>This will create a sparse 850GB ZFS zvol.</html:p>
        <html:pre>sudo zfs create -p -s -V 850g tank1/export/fc</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Enable ctld(8)">Enable <fr:link href="/ctld.8" title="ctld(8)" uri="https://xw.is/ctld.8" display-uri="ctld.8" type="local">ctld(8)</fr:link></fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:pre>sudo sysrc ctld_enable=YES</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Bring the device online">Bring the device online</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Use <fr:link href="/ctladm.8" title="ctladm(8)" uri="https://xw.is/ctladm.8" display-uri="ctladm.8" type="local">ctladm(8)</fr:link> to bring the devices online.</html:p>
        <html:pre>
sudo ctladm port -o on isp0
sudo ctladm port -o on isp1</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Check the WWN address">Check the WWN address</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>You'll get output like:</html:p>
        <html:pre>
z800:aram$ sudo ctladm port -l
Port Online Frontend Name     pp vp
0    YES    camsim   camsim   0  0  naa.50000009e370df01
1    YES    ioctl    ioctl    0  0
2    YES    tpc      tpc      0  0
3    YES    camtgt   isp0     0  0  naa.2100001b321cd5b6
4    YES    camtgt   isp1     0  0  naa.2101001b323cd5b6</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Configure ctl.conf(5)">Configure <fr:link href="/ctl.conf.5" title="ctl.conf(5)" uri="https://xw.is/ctl.conf.5" display-uri="ctl.conf.5" type="local">ctl.conf(5)</fr:link></fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>Use this config for <fr:link href="/ctl.conf.5" title="ctl.conf(5)" uri="https://xw.is/ctl.conf.5" display-uri="ctl.conf.5" type="local">ctl.conf(5)</fr:link>:</html:p>
        <html:pre>
lun fibre-channel {
	backend block
	device-id "5000c5001d5ba30b"
	serial "MGKSERIAL0001"
	option vendor "MGK"
	option product "FC Disk"
	option naa "600A0B80002682A8000067D95897A544"
	option removable "on"
	path /dev/zvol/tank1/export/fc
}

target naa.100000062b1b88c8 {
	auth-group no-authentication
	port mpt0
	port mpt1
	lun 0 fibre-channel
}</html:pre>
        <html:p>Make sure the WWN matches. Next, start the ctld daemon. The device-id is from a real Seagate FC disk, and the naa is from a real array. I think both are required by macOS to make multipathing work.</html:p>
        <html:pre>sudo service ctld start</html:pre>
        <html:p>Query the status, to see if everything is working correctly:</html:p>
        <html:pre>
z800:aram$ sudo ctladm devlist -v
LUN Backend       Size (Blocks)   BS Serial Number    Device ID
  0 block            1782579200  512 MYSERIAL   0     MYDEVID   0
      lun_type=0
      num_threads=14
      file=/dev/zvol/tank1/export/fc
      ctld_name=naa.2100001b321cd5b6,lun,0
      scsiname=naa.2100001b321cd5b6,lun,0</html:pre>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false">
      <fr:frontmatter>
        <fr:authors>
          <fr:author>
            <fr:link href="/aram/" title="Aram Hăvărneanu" uri="https://xw.is/aram/" display-uri="aram" type="local">Aram Hăvărneanu</fr:link>
          </fr:author>
        </fr:authors>
        <fr:date>
          <fr:year>2018</fr:year>
          <fr:month>11</fr:month>
          <fr:day>7</fr:day>
        </fr:date>
        <fr:date>
          <fr:year>2025</fr:year>
          <fr:month>8</fr:month>
          <fr:day>28</fr:day>
        </fr:date>
        <fr:title text="Initiator side">Initiator side</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <html:p>If using macOS, the mac should just "see" the target, no configuration required.</html:p>
      </fr:mainmatter>
    </fr:tree>
  </fr:mainmatter>
  <fr:backmatter>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="References">References</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Context">Context</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Backlinks">Backlinks</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Related">Related</fr:title>
      </fr:frontmatter>
      <fr:mainmatter>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/freebsd/</fr:uri>
            <fr:display-uri>freebsd</fr:display-uri>
            <fr:route>/freebsd/</fr:route>
            <fr:title text="FreeBSD">FreeBSD</fr:title>
            <fr:taxon>Software</fr:taxon>
            <fr:meta name="external">https://www.freebsd.org</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD).</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/ctl.conf.5</fr:uri>
            <fr:display-uri>ctl.conf.5</fr:display-uri>
            <fr:route>/ctl.conf.5</fr:route>
            <fr:title text="ctl.conf(5)">ctl.conf(5)</fr:title>
            <fr:taxon>Manual</fr:taxon>
            <fr:meta name="external">https://man.freebsd.org/cgi/man.cgi?query=ctl.conf&amp;sektion=5</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>CAM Target Layer / iSCSI target daemon configuration	file.</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/ctladm.8</fr:uri>
            <fr:display-uri>ctladm.8</fr:display-uri>
            <fr:route>/ctladm.8</fr:route>
            <fr:title text="ctladm(8)">ctladm(8)</fr:title>
            <fr:taxon>Manual</fr:taxon>
            <fr:meta name="external">https://man.freebsd.org/cgi/man.cgi?query=ctladm&amp;sektion=8</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>CAM Target Layer control utility.</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/ctld.8</fr:uri>
            <fr:display-uri>ctld.8</fr:display-uri>
            <fr:route>/ctld.8</fr:route>
            <fr:title text="ctld(8)">ctld(8)</fr:title>
            <fr:taxon>Manual</fr:taxon>
            <fr:meta name="external">https://man.freebsd.org/cgi/man.cgi?query=ctld&amp;sektion=8</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>CAM Target Layer	/ iSCSI	target daemon.</html:p>
          </fr:mainmatter>
        </fr:tree>
        <fr:tree show-metadata="true" expanded="false" toc="false" numbered="false">
          <fr:frontmatter>
            <fr:authors />
            <fr:uri>https://xw.is/freebsd-isp.4</fr:uri>
            <fr:display-uri>freebsd-isp.4</fr:display-uri>
            <fr:route>/freebsd-isp.4</fr:route>
            <fr:title text="isp(4)">isp(4)</fr:title>
            <fr:taxon>Manual</fr:taxon>
            <fr:meta name="external">https://man.freebsd.org/cgi/man.cgi?query=isp&amp;sektion=4</fr:meta>
          </fr:frontmatter>
          <fr:mainmatter>
            <html:p>Qlogic FibreChannel SCSI Host Adapters driver</html:p>
          </fr:mainmatter>
        </fr:tree>
      </fr:mainmatter>
    </fr:tree>
    <fr:tree show-metadata="false" hidden-when-empty="true">
      <fr:frontmatter>
        <fr:authors />
        <fr:title text="Contributions">Contributions</fr:title>
      </fr:frontmatter>
      <fr:mainmatter />
    </fr:tree>
  </fr:backmatter>
</fr:tree>
