{"id":22,"date":"2012-03-04T16:23:56","date_gmt":"2012-03-04T15:23:56","guid":{"rendered":"http:\/\/esxi-v34\/wordpress\/?p=22"},"modified":"2013-07-19T18:48:00","modified_gmt":"2013-07-19T16:48:00","slug":"setting-up-iscsi","status":"publish","type":"post","link":"\/wordpress\/freebsd\/setting-up-iscsi\/","title":{"rendered":"Setting up iSCSI"},"content":{"rendered":"<p>Should operate on a physical separate lan and <a href=\"\/wordpress\/network\/vlans\/\">VLAN 200<\/a> has been set aside for this.<\/p>\n<h3>Server<\/h3>\n<p>Install <code>net\/istgt<\/code> from ports and set <code>istgt_enable=\"YES\"<\/code> in <code>\/etc\/rc.conf<\/code>.<\/p>\n<p>iSCSI uses an addressing scheme called iqn which is built up by the reverse domainname along with the founding date. In this case the address is <code>iqn.2004-06.net.strahlert.home<\/code><\/p>\n<h4>\/usr\/local\/etc\/istgt\/auth.conf<\/h4>\n<ul>\n<li>Set up an authgroup for the iqn and the disks<\/li>\n<\/ul>\n<h4>\/usr\/local\/etc\/istgt\/istgt.conf<\/h4>\n<ul>\n<li>Set the iqn by modifying <strong>NodeBase<\/strong><\/li>\n<li>Set the IP of the server on <a href=\"\/wordpress\/network\/vlans\/\">VLAN 200<\/a> for the various <strong>Portal<\/strong> entries and set an appropriate <strong>Netmask<\/strong><\/li>\n<li>For each LUN, define a <strong>LogicalUnitX<\/strong> group\n<ul>\n<li>Set a unique <strong>TargetName<\/strong> and <strong>TargetAlias<\/strong><\/li>\n<li>Set <strong>LUN0<\/strong> pointing to the device. For <a href=\"\/wordpress\/tag\/zfs\/\">ZFS<\/a> volume usage; <code>LUN0 Storage \/dev\/zvol\/zpoolname\/volumename Auto<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code>[Global]\r\n  Comment \"Global section\"\r\n  # node name (not include optional part)\r\n  NodeBase \"iqn.2004-06.net.strahlert.home\"\r\n\r\n  # files\r\n  PidFile \/var\/run\/istgt.pid\r\n  AuthFile \/usr\/local\/etc\/istgt\/auth.conf\r\n\r\n  # directories\r\n  # for removable media (virtual DVD\/virtual Tape)\r\n  MediaDirectory \/var\/istgt\r\n\r\n  # syslog facility\r\n  LogFacility \"local7\"\r\n\r\n  # socket I\/O timeout sec. (polling is infinity)\r\n  Timeout 30\r\n  # NOPIN sending interval sec.\r\n  NopInInterval 20\r\n\r\n  # authentication information for discovery session\r\n  DiscoveryAuthMethod None\r\n\r\n  # reserved maximum connections and sessions\r\n  # NOTE: iSCSI boot is 2 or more sessions required\r\n  MaxSessions 16\r\n  MaxConnections 4\r\n\r\n  # maximum number of sending R2T in each connection\r\n  # actual number is limited to QueueDepth and MaxCmdSN and ExpCmdSN\r\n  # 0=disabled, 1-256=improves large writing\r\n  MaxR2T 32\r\n\r\n  # iSCSI initial parameters negotiate with initiators\r\n  # NOTE: incorrect values might crash\r\n  MaxOutstandingR2T 16\r\n  DefaultTime2Wait 2\r\n  DefaultTime2Retain 60\r\n  FirstBurstLength 262144\r\n  MaxBurstLength 1048576\r\n  MaxRecvDataSegmentLength 262144\r\n\r\n  # NOTE: not supported\r\n  InitialR2T Yes\r\n  ImmediateData Yes\r\n  DataPDUInOrder Yes\r\n  DataSequenceInOrder Yes\r\n  ErrorRecoveryLevel 0\r\n\r\n[PortalGroup1]\r\n  Comment \"SINGLE PORT TEST\"\r\n  Portal DA1 192.168.100.13:3260\r\n\r\n[InitiatorGroup1]\r\n  Comment \"Initiator Group1\"\r\n  InitiatorName \"ALL\"\r\n  Netmask 192.168.100.0\/24\r\n\r\n[LogicalUnit1021]\r\n  TargetName dustballL1\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/dustballL1 Auto\r\n\r\n[LogicalUnit1071]\r\n  TargetName coolmasterL1\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/coolmasterL1 Auto\r\n\r\n[LogicalUnit1501]\r\n  TargetName esxiL1\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/esxiL1 Auto\r\n\r\n[LogicalUnit1502]\r\n  TargetName esxiL2\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/esxiL2 Auto\r\n\r\n[LogicalUnit1503]\r\n  TargetName esxiL3\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/esxiL3 Auto\r\n\r\n[LogicalUnit1901]\r\n  TargetName esxi2L1\r\n  Mapping PortalGroup1 InitiatorGroup1\r\n  UnitType Disk\r\n  QueueDepth 64\r\n  LUN0 Storage \/dev\/zvol\/san\/volumes\/esxi2L1 Auto\r\n<\/code><\/pre>\n<h3>Client<\/h3>\n<h4>\/etc\/iscsi.conf<\/h4>\n<p>Sample:<\/p>\n<pre><code>nasse {\r\n        initiatorname   = iqn.2004-06.net.strahlert.home\r\n        targetname      = iqn.2004-06.net.strahlert.home:coolmasterL1\r\n        targetaddress   = 192.168.100.13:3260,1\r\n}<\/code><\/pre>\n<h4>\/usr\/local\/etc\/rc.d\/iscsi<\/h4>\n<pre><code>#!\/bin\/sh\r\n\r\n# PROVIDE: iscsi\r\n# REQUIRE: NETWORKING\r\n# BEFORE: mountcritremote\r\n# KEYWORD: shutdown\r\n\r\n. \/etc\/rc.subr\r\n\r\nname=\"iscsi\"\r\nstart_cmd=\"iscsi_start\"\r\nstop_cmd=\"iscsi_stop\"\r\nrcvar=\"iscsi_enable\"\r\nrequired_modules=\"iscsi_initiator:iscsi\"\r\n\r\niscsi_start()\r\n{\r\n        ${iscsi_command} -c ${iscsi_config} -n ${iscsi_nickname}\r\n        if [ -f ${iscsi_fstab} ]; then\r\n                devs=`sed -e '\/^#\/d' &lt; ${iscsi_fstab} | cut -f 1`\r\n                for xdev in $devs\r\n                do\r\n                        i=10\r\n                        echo \"Wait for $xdev\"\r\n                        while [ $i -ne 0 ]\r\n                        do\r\n                                [ -c $xdev ] && break\r\n                                sleep 1\r\n                                i=$(($i-1))\r\n                        done\r\n                done\r\n\r\n                echo \"mount -a -F ${iscsi_fstab}\"\r\n                mount -a -F ${iscsi_fstab}\r\n        fi\r\n}\r\n\r\niscsi_stop()\r\n{\r\n        if [ -f ${iscsi_fstab} ]; then\r\n                echo \"umount -a -F ${iscsi_fstab}\"\r\n                umount -a -F ${iscsi_fstab}\r\n        fi\r\n        killall -HUP ${iscsi_command}\r\n}\r\n\r\nload_rc_config $name\r\n\r\n: ${iscsi_enable=\"NO\"}\r\n: ${iscsi_command=\"iscontrol\"}\r\n: ${iscsi_nickname=\"idisk1\"}\r\n: ${iscsi_config=\"\/etc\/iscsi.conf\"}\r\n: ${iscsi_fstab=\"\/etc\/iscsi.fstab\"}\r\n\r\nrun_rc_command \"$1\"\r\n<\/code><\/pre>\n<h3>VirtualBox<\/h3>\n<p>VirtualBox has its own iSCSI initiator. To add a disk to a vm, use the following:<\/p>\n<p>Port begins with 0 for SATA controllers. The example below is for adding a second disk.<\/p>\n<pre><code>VBoxManage storageattach dustball-v30 --storagectl \"SATA Controller\" --port 1 --type hdd --medium iscsi --server coolmaster --target \"iqn.2004-06.net.strahlert.home:raid5-volume2\"<\/code><\/pre>\n<p>For volume management through zfs, see also <a href=\"\/wordpress\/zfs-2\/volume-management-in-zfs\/\" title=\"Volume management in ZFS\">Volume management in ZFS<\/a> and <a href=\"\/wordpress\/zfs-2\/copying-a-volume-across-a-server\/\" title=\"Copying a volume across a server\">Copying a volume across a server<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Should operate on a physical separate lan and VLAN 200 has been set aside for this. Server Install net\/istgt from ports and set istgt_enable=&#8221;YES&#8221; in \/etc\/rc.conf. iSCSI uses an addressing scheme called iqn which is built up by the reverse domainname along with the founding date. In this case the address is iqn.2004-06.net.strahlert.home \/usr\/local\/etc\/istgt\/auth.conf Set <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"\/wordpress\/freebsd\/setting-up-iscsi\/\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[31,3,15,2],"_links":{"self":[{"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/posts\/22"}],"collection":[{"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":20,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":112,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/posts\/22\/revisions\/112"}],"wp:attachment":[{"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.strahlert.net\/wordpress\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}