{"id":617,"date":"2013-01-13T16:42:13","date_gmt":"2013-01-13T21:42:13","guid":{"rendered":"https:\/\/infotechguy.net\/?p=617"},"modified":"2025-02-22T11:28:25","modified_gmt":"2025-02-22T16:28:25","slug":"linux-iscsi-target-using-open-iscsi","status":"publish","type":"post","link":"https:\/\/infotechguy.net\/?p=617","title":{"rendered":"Linux &#8212; iSCSI Target using open-iscsi"},"content":{"rendered":"<p>I recently set up an iSCSI SAN for use with VMWare Server. The set up was basically a Linux Ubuntu Server target with 2 network links to a single VNWare Server as the integrator. I also included iSCSI multi-pathing by enabling it on the initiator (VMWare Server).<\/p>\n<p><strong>This is how I set up an Linux SAN Target with iSCSI, interfacing with VMWare 5.1. as the iSCSI Initiator.<\/strong><br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3538 aligncenter\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram-300x273.png\" alt=\"\" width=\"600\" height=\"546\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram-300x273.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram-1024x932.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram-768x699.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/i-SCSI-diagram.png 1280w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><br \/>\n<!--more--><\/p>\n<h3>Part 1: Setting up our iSCSI Target with Linux<\/h3>\n<ol>\n<li>Let&#8217;s set up our network interfaces that will be used for the SAN connection.\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vi \/etc\/network\/interfaces\n#closed circuit storage network\nauto eth0\niface eth0 inet static\n        address 192.168.255.101\n        netmask 255.255.255.252\n\nauto eth1\niface eth1 inet static\n        address 192.168.255.201\n        netmask 255.255.255.252\n\n<\/pre>\n<p><em>I chose two separate \/30 networks. If you remember a \/30 only has 2 usable host IPs. This ensures that our iSCSI Target and Imitator are the only IPs on the network. No use in using a larger network, as it will be wasted with our Point-to-Point Ethernet link.<\/em><\/li>\n<li>Creating LUNs. I decided to use a flat file for my LUN images. You can use other storage devices, such as a \/dev\/sdX devices,etc. I just thought it would be easier to keep track of the LUNs if they were files&#8230;not sure if this is best practice&#8230;anyway!\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">mkdir LUNs\ncd LUNs\ndd if=\/dev\/zero of=LUN02.img bs=1024k count=10000\n\n10000+0 records in\n10000+0 records out\n10485760000 bytes (10 GB) copied, 103.744 s, 101 MB\/s\n<\/pre>\n<p><em>This will create a zero&#8217;d LUN01.img file with the size of 10GBs<\/em><\/li>\n<li>Prepare the LUN, and partition it.\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">fdisk LUN01.img<\/pre>\n<p>Create a new partition 1, type fb (VMFS)<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3539\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8-300x262.png\" alt=\"\" width=\"600\" height=\"525\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8-300x262.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8-1024x895.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8-768x671.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI8.png 1280w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>On the iSCSI target, install the following packages:\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">apt-get install iscsitarget iscsitarget-dkms<\/pre>\n<p>This will install the necessary packages to run the iSCSI target service. Also install the following packages for troublshooting purposes. These packages can be used to impersonate an iSCSI initirator connection.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">apt-get install open-iscsi open-iscsi-utils<\/pre>\n<\/li>\n<li>Start the iSCSI Target service and make sure it starts successfully.\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/etc\/init.d\/iscsitarget start<\/pre>\n<\/li>\n<li>Edit the ietd.conf file to identify the LUNs you will advertise.\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vi \/etc\/ietd\/ietd.conf\nTarget  iqn.2001-04.com.example:storage.lun01\n        Lun 0 Path=\/{mount_location}\/LUNs\/LUN01.img,Type=fileio\n        Alias LUN01\n<\/pre>\n<\/li>\n<li>Restart the iSCSI Target Service:\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/etc\/init.d\/iscsitarget restart<\/pre>\n<\/li>\n<\/ol>\n<h3>Part 2: Setting up VMWare ESXi 5.1<\/h3>\n<ol>\n<li>Assuming you have installed VMWare and have two(2) Ethernet interfaces to use to hook into a SAN network. We will start by setting up the Network Adapters.<br \/>\nIP the two(2) Ethernet Network Adapters<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3540\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3-300x205.png\" alt=\"\" width=\"600\" height=\"410\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3-300x205.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3-1024x701.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3-768x526.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI3.png 1169w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3541\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI4-242x300.png\" alt=\"\" width=\"598\" height=\"741\" \/><\/a><br \/>\n<strong><strong>(Do this for both Network Adapters)<\/strong><\/strong>&nbsp;<\/li>\n<li>You should now see a iSCSI Storage Adapter Available.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3542\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI-300x124.png\" alt=\"\" width=\"600\" height=\"248\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI-300x124.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI-1024x422.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI-768x316.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI.png 1280w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>Right-Click on the iSCSI Adapter and go to Properties. Here we have to set the iSCSI Discovery Address.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI15.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3543\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI15-283x300.png\" alt=\"\" width=\"600\" height=\"636\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI15-283x300.png 283w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI15.png 754w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>Click on the iSCSI Adapter, you should see in the bottom pane the LUN being advertised by our iSCSI Target.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3544\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6-300x209.png\" alt=\"\" width=\"600\" height=\"418\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6-300x209.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6-1024x714.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6-768x535.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI6.png 1148w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><br \/>\nNOTICE: We have 2 paths going to our LUN?? (This is a good thing! We have to set up multipathing&#8230;but later!)<\/li>\n<li>Provision the LUN Storage to be used with VMWare.<br \/>\nUnder Storage, click on the far Right the &#8220;Add Storage&#8221; Link and follow the following prompts to provision the LUN for use with VMWare.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3545\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI9-300x234.png\" alt=\"\" width=\"600\" height=\"468\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI9-300x234.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI9-768x599.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI9.png 1025w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3546\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI10-300x234.png\" alt=\"\" width=\"600\" height=\"468\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI10-300x234.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI10-768x599.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI10.png 1025w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3547\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI11-300x234.png\" alt=\"\" width=\"600\" height=\"468\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI11-300x234.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI11-768x599.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI11.png 1025w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3548\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI12-300x234.png\" alt=\"\" width=\"600\" height=\"468\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI12-300x234.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI12-768x599.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI12.png 1025w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><br \/>\nWait for the drive to be provisioned.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3549\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13-300x64.png\" alt=\"\" width=\"600\" height=\"128\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13-300x64.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13-1024x217.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13-768x163.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI13.png 1280w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>You should now have a Storage LUN available for use with VMWare.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3550\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14-300x149.png\" alt=\"\" width=\"600\" height=\"298\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14-300x149.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14-1024x508.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14-768x381.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI14.png 1280w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<li>Set up Mutlipathing..<br \/>\nClick on the LUN under Storage. Right Click and go to Properties.<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3551\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16-300x209.png\" alt=\"\" width=\"601\" height=\"419\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16-300x209.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16-1024x714.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16-768x536.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI16.png 1147w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/a><br \/>\nNext, click on Manage Paths.Click on Manage Paths, in the following prompt, change<br \/>\n<a href=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3552\" src=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7-300x188.png\" alt=\"\" width=\"600\" height=\"376\" srcset=\"https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7-300x188.png 300w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7-1024x641.png 1024w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7-768x481.png 768w, https:\/\/infotechguy.net\/wp-content\/uploads\/2021\/03\/iSCSI7.png 1278w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/li>\n<\/ol>\n<h3>Part 3: Limiting iSCSI Access<\/h3>\n<p>You can limit the access of the iSCSI connection by editing the initiator.allow and\/or targets.allow.<\/p>\n<ul>\n<li>Edit the <strong>initiators.allow<\/strong>, this file limits the allowed initiators by either their IQN, IP, or IP Subnet.\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vi \/etc\/ietd\/initiators.allow\nALL ALL\n<\/pre>\n<\/li>\n<li>Edit the <strong>targets.allow<\/strong>, this file limits the allowed targets. (I&#8217;ve limited to the follow IPs so the only IPs used on the Target to those that are part of the Multipathing that we set up from above.)\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">vi \/etc\/ietd\/targets.allow\n#storage networks \/30s\nALL 192.168.255.101,192.168.255.201\n<\/pre>\n<\/li>\n<\/ul>\n<p><strong>Source:<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.howtoforge.com\/using-iscsi-on-ubuntu-10.04-initiator-and-target\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.howtoforge.com\/using-iscsi-on-ubuntu-10.04-initiator-and-target<\/a><\/li>\n<li><a href=\"http:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1002491\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1002491<\/a><\/li>\n<li><a href=\"http:\/\/www.tcpdump.com\/kb\/virtualization\/vmware-esx-server\/vmware-disk-alignment\/vmfs-liux.html\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.tcpdump.com\/kb\/virtualization\/vmware-esx-server\/vmware-disk-alignment\/vmfs-liux.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I recently set up an iSCSI SAN for use with VMWare Server. The set up was basically a Linux Ubuntu Server target with 2 network links to a single VNWare Server as the integrator. I&#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-617","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\/617","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=617"}],"version-history":[{"count":1,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/617\/revisions"}],"predecessor-version":[{"id":4177,"href":"https:\/\/infotechguy.net\/index.php?rest_route=\/wp\/v2\/posts\/617\/revisions\/4177"}],"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=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infotechguy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}