{"id":401,"date":"2018-08-18T14:40:06","date_gmt":"2018-08-18T11:40:06","guid":{"rendered":"http:\/\/kifarunix.com\/?p=401"},"modified":"2024-03-10T16:39:00","modified_gmt":"2024-03-10T13:39:00","slug":"how-to-install-and-configure-iscsi-storage-server-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-iscsi-storage-server-on-ubuntu-18-04\/","title":{"rendered":"How to Install and Configure iSCSI Storage Server on Ubuntu 18.04"},"content":{"rendered":"\n<p>In this tutorial we are going to learn how to install and configure iSCSI storage server on Ubuntu 18.04. Well, iSCSI, an acronym for <strong>Internet Small Computer System Interface<\/strong>, is a Storage Area Network protocol that is used by the organizations to facilitate online storage management. It relies on TCP\/IP networks to send SCSI commands between the <strong>initiator<\/strong> (client) and the <strong>target<\/strong> (server) that provide block-level access to the storage devices which can either be LVM logical volumes, complete disks, files or partitions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing iSCSI Storage Server on Ubuntu<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"key-concepts-in-i-scsi\">Key Concepts in iSCSI<\/h3>\n\n\n\n<p>Below are key concepts used in iSCSI network storage;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><strong>iSCSI Initiator<\/strong><\/code>: The client-side software that enables a device to connect to an iSCSI storage target and use its resources.<\/li>\n\n\n\n<li><strong><code>iSCSI Target<\/code><\/strong>: The server-side software that presents the storage resources to the initiator as if they were local disks.<\/li>\n\n\n\n<li><strong><code>LUN (Logical Unit Number)<\/code><\/strong>: A unique identifier that represents a specific logical volume or portion of a physical disk on the iSCSI target.<\/li>\n\n\n\n<li><strong><code>iSCSI Portal<\/code><\/strong>: The IP address and TCP port number combination that the iSCSI initiator uses to connect to the iSCSI target.<\/li>\n\n\n\n<li><strong><code>Initiator IQN (iSCSI Qualified Name)<\/code><\/strong>: The unique identifier assigned to the iSCSI initiator to establish a connection with the iSCSI target.<\/li>\n\n\n\n<li><code><strong>CHAP (Challenge-Handshake Authentication Protocol)<\/strong><\/code>: A security mechanism used for authentication between the iSCSI initiator and target to ensure that only authorized initiators can access the storage.<\/li>\n\n\n\n<li><strong><code>SCSI (Small Computer System Interface)<\/code><\/strong>: A standard protocol used by the operating system to communicate with storage devices, including iSCSI storage.<\/li>\n\n\n\n<li><code><strong>MPIO (Multipath I\/O)<\/strong><\/code>: A technique used to create redundant paths between the initiator and target to ensure high availability and load balancing.<\/li>\n\n\n\n<li><strong><code>Jumbo Frames<\/code><\/strong>: A technique used to increase the packet size in iSCSI networks to improve performance.<\/li>\n\n\n\n<li><code><strong>Portal<\/strong><\/code>: A portal is a network interface on a target that listens for iSCSI initiator connection requests.<\/li>\n\n\n\n<li><code><strong>TPG (Target Portal Group)<\/strong><\/code>: a group of portals on the target side that share the same target portal group tag (TPGT). By grouping portals into a TPG, the target can present a single iSCSI target to initiators, even if there are multiple interfaces or network paths to the target. TPGs can be used to provide load balancing, failover, and increased throughput.<\/li>\n\n\n\n<li><strong>ACL<\/strong>: Access Control List that lists iSCSI clients to be granted access to the storage device.<\/li>\n<\/ul>\n\n\n\n<p>Read more on <code>man targetcli<\/code>.<\/p>\n\n\n\n<p>In our deployment, we will be using Ubuntu 18.04 server as the iSCSI target and Ubuntu 18.04 Desktop as the iSCSI initiator.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-i-scsi-required-packages\">Install iSCSI Required Packages<\/h3>\n\n\n\n<p>To set up an iSCSI target, we need to install an administration tool called <strong>targetcli<\/strong> which provides the default interface for managing the target.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt -y install targetcli-fb<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-i-scsi-target\">Configure iSCSI Target on Ubuntu<\/h3>\n\n\n\n<p>After installing targetcli, let us configure iSCSI target.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-the-backend-storage-devices\">Create the backend storage devices<\/h4>\n\n\n\n<p>In our storage server, we have attached two disks and created two logical volumes;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nNAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\n...\n<strong>sdb                8:16   0    4G  0 disk \n\u2514\u2500vol01-lv_san01 253:2    0    4G  0 lvm  \nsdc                8:32   0   15G  0 disk \n\u2514\u2500vol02-lv_san02 253:3    0   15G  0 lvm<\/strong>\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-i-scsi-backstore-block-storage\">Create iSCSI Backstore\/Block Storage<\/h4>\n\n\n\n<p>iSCSI backstore is a virtual disk or LUN (Logical Unit Number) that represents the storage space that is exported to the iSCSI initiators. There are several types of backstores that can be used in iSCSI, such as file-based backstores like iSCSI target files, or block-based backstores like LVM volumes or physical disks.<\/p>\n\n\n\n<p>To create iSCSI target backstore, launch the targetcli utility by typing <strong>targetcli<\/strong> on terminal<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>targetcli<\/code><\/pre>\n\n\n\n<p>This will open an interactive prompt;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\ntargetcli shell version 2.1.53\nCopyright 2011-2013 by Datera, Inc and others.\nFor help on commands, type 'help'.\n\n\/>\n<\/code><\/pre>\n\n\n\n<p>Next, create new backstore for the iSCSI disk using logical volumes created above as the backend storage device.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/backstores\/block create iscsi_disk_01 \/dev\/vol01\/lv_san01<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/backstores\/block create iscsi_disk_02 \/dev\/vol02\/lv_san02<\/code><\/pre>\n\n\n\n<p>If you run ls command, you should now be able to see created block storage;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\no- \/ ......................................................................................................................... [...]\n  o- backstores .............................................................................................................. [...]\n  | o- block .................................................................................................. [Storage Objects: 2]\n  | | o- iscsi_disk_01 ....................................................... [\/dev\/vol01\/lv_san01 (4.0GiB) write-thru deactivated]\n  | | | o- alua ................................................................................................... [ALUA Groups: 1]\n  | | |   o- default_tg_pt_gp ....................................................................... [ALUA state: Active\/optimized]\n  | | o- iscsi_disk_02 ...................................................... [\/dev\/vol02\/lv_san02 (15.0GiB) write-thru deactivated]\n  | |   o- alua ................................................................................................... [ALUA Groups: 1]\n  | |     o- default_tg_pt_gp ....................................................................... [ALUA state: Active\/optimized]\n  | o- fileio ................................................................................................. [Storage Objects: 0]\n  | o- pscsi .................................................................................................. [Storage Objects: 0]\n  | o- ramdisk ................................................................................................ [Storage Objects: 0]\n  o- iscsi ............................................................................................................ [Targets: 0]\n  o- loopback ......................................................................................................... [Targets: 0]\n<\/code><\/pre>\n\n\n\n<p>NB iscsi_disk_nn is the name of the backing storage device. You can call it a name of your choice.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-i-scsi-file-based-backstore\">Create iSCSI File-based Backstore<\/h4>\n\n\n\n<p>If you want, you can also create a file-backed block device. To do this, navigate to fileio directory and create for example, a 1GiB sized file residing on the home directory. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/backstores\/fileio create iscsi_file01 \/home\/disk_file 1GiB<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ls \/backstores\/fileio<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\no- fileio ..................................................................................................... [Storage Objects: 1]\n  o- iscsi_file01 ................................................................ [\/home\/disk_file (1.0GiB) write-back deactivated]\n    o- alua ....................................................................................................... [ALUA Groups: 1]\n      o- default_tg_pt_gp ........................................................................... [ALUA state: Active\/optimized]\n\/>\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-an-iqn-for-the-i-scsi-target\">Create an IQN for the iSCSI target<\/h4>\n\n\n\n<p>Next, you need to create an IQN for the iSCSI targets.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi create iqn.2023-05.com.kifarunix-demo:target00<\/code><\/pre>\n\n\n\n<p>When IQN is created, by default a Target Portal Group will be created.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Created target iqn.2023-05.com.kifarunix-demo:target00.\nCreated TPG 1.\nGlobal pref auto_add_default_portal=true\nCreated default portal listening on all IPs (0.0.0.0), port 3260.<\/code><\/pre>\n\n\n\n<p>As you can see, iSCSI target creates a portal that listens on all interfaces on port 3260\/tcp.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-ac-ls-for-the-tpg\">Configure ACLs for the TPG<\/h4>\n\n\n\n<p>Target Portal Group (TPG) Access Control List (ACL) defines which initiators are allowed to access the storage resources exposed by the target. The TPG ACL is used to provide access control at the Target level. It specifies the initiator names that are allowed or denied access to the target.<\/p>\n\n\n\n<p>When a new session is established, the initiator&#8217;s name is checked against the TPG ACL. If the initiator name is found in the ACL, access is granted, and the session is established. If the initiator name is not found in the ACL, access is denied, and the session is terminated.<\/p>\n\n\n\n<p>To create an ACL for the TPG1 above;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/acls create iqn.2023-05.com.kifarunix-demo:poc<\/code><\/pre>\n\n\n\n<p>This creates a node ACL that allows poc server to access the target\u2019s IQN just created.<\/p>\n\n\n\n<p>If you want to add multiple clients, specify them comma separated;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/acls create iqn.2023-05.com.kifarunix-demo:poc,iqn.2023-05.com.kifarunix-demo:another-server<\/code><\/pre>\n\n\n\n<p>If you want to use IPs instead;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/acls create 192.168.1.100,192.168.1.101<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-chap-authentication\">Configure CHAP Authentication<\/h4>\n\n\n\n<p>Configure CHAP Authentication by creating initiators\u2019 users, that will be allowed to access backend storage, and their passwords.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/acls\/iqn.2023-05.com.kifarunix-demo:poc set auth userid=kifarunix-admin<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/acls\/iqn.2023-05.com.kifarunix-demo:poc set auth password=password<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-lu-ns-for-the-i-scsi-disk\">Create LUNs for the iSCSI disk<\/h4>\n\n\n\n<p>Create the <strong>LUNs<\/strong> needed to associate a block device with a specific TPG. For our case, we will use <strong>iscsi_disk_01<\/strong> block and <strong>iscsi_file01<\/strong> file created above to create a LUN.<\/p>\n\n\n\n<p>Any new LUN created will be mapped to each ACL that is associated with the TPG.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/luns create \/backstores\/block\/iscsi_disk_01<\/code><\/pre>\n\n\n\n<p>Output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Created LUN 0.\nCreated LUN 0-&gt;0 mapping in node ACL iqn.2023-05.com.kifarunix-demo:poc<\/code><\/pre>\n\n\n\n<p>File based LUN;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/luns create \/backstores\/fileio\/iscsi_file01<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-i-scsi-target-portal\">Create iSCSI Target Portal<\/h4>\n\n\n\n<p>Optionally, to configure a target to offer services on specific address, create a portal for that address. Remember the IP address used must be fixed. To do this, Navigate to portals and create it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/portals create 192.168.57.45<\/code><\/pre>\n\n\n\n<p>If you get the error, <strong><code>Could not create NetworkPortal in configFS<\/code><\/strong>, it is because you already have portal that listens on all IPs;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/portals ls<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>o- portals ............................................................................................................ &#91;Portals: 1]\n  o- <strong>0.0.0.0:3260<\/strong> ............................................................................................................. &#91;OK]\n\/&gt;<\/code><\/pre>\n\n\n\n<p>Thus, to change this, delete the portal;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/portals delete 0.0.0.0 3260<\/code><\/pre>\n\n\n\n<p>And re-create the portal;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/iscsi\/iqn.2023-05.com.kifarunix-demo:target00\/tpg1\/portals create 192.168.57.45<\/code><\/pre>\n\n\n\n<p>Output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Using default IP port 3260\nCreated network portal 192.168.57.45:3260.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"open-i-scsi-portal-on-firewall\">Open iSCSI Portal on Firewall<\/h4>\n\n\n\n<p>Exit the targetcli utility<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/&gt; <strong>exit<\/strong>\nGlobal pref auto_save_on_exit=true\nConfiguration saved to \/etc\/target\/saveconfig.json<\/code><\/pre>\n\n\n\n<p>check whether port 3260 is listening;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -altnp | grep 3260<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>LISTEN     0      256    192.168.57.45:3260                     *:*<\/code><\/pre>\n\n\n\n<p>Open iSCSI portal on firewall;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ufw allow 3260\/tcp<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"running-i-scsi-target-service\">Running iSCSI Target Service<\/h4>\n\n\n\n<p>Start iSCSI target and enable it to run when the system boots.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now target<\/code><\/pre>\n\n\n\n<p>Check status;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status target<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-the-i-scsi-initiator\">Configure the iSCSI Initiator<\/h3>\n\n\n\n<p>Follow these simple steps to configure an iSCSI Initiator.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-i-scsi-initiator-utilities\">Install iSCSI Initiator Utilities<\/h4>\n\n\n\n<p>Run the command, install iSCSI Initiator utilities<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt -y install open-iscsi<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"set-the-i-scsi-initiator-name\">Set the iSCSI Initiator Name<\/h4>\n\n\n\n<p>Edit the file <strong><code>\/etc\/iscsi\/initiatorname.iscsi<\/code><\/strong> configuration and add the name of the initiator;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/iscsi\/initiatorname.iscsi<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>InitiatorName=iqn.2023-05.com.kifarunix-demo:poc<\/code><\/pre>\n\n\n\n<p>Save and exit the file<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"configure-authentication\">Configure Authentication<\/h4>\n\n\n\n<p>Open the <code>\/etc\/iscsi\/iscsid.conf<\/code> config and update the iSCSI credentials created before, under CHAP settings section;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/iscsi\/iscsid.conf<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n# *************\n# CHAP Settings\n# *************\n\n# To enable CHAP authentication set node.session.auth.authmethod\n# to CHAP. The default is None.\n<strong>node.session.auth.authmethod = CHAP<\/strong>\n\n# To configure which CHAP algorithms to enable set\n# node.session.auth.chap_algs to a comma seperated list.\n# The algorithms should be listen with most prefered first.\n# Valid values are MD5, SHA1, SHA256\n# The default is MD5.\n#node.session.auth.chap_algs = SHA256,SHA1,MD5\n\n# To set a CHAP username and password for initiator\n# authentication by the target(s), uncomment the following lines:\n<strong>node.session.auth.username = kifarunix-admin\nnode.session.auth.password = password<\/strong>\n<\/code><\/pre>\n\n\n\n<p>Save the file and exit.<\/p>\n\n\n\n<p>Restart the iscsid service<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart iscsid open-iscsi<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"perform-i-scsi-target-discovery\">Perform iSCSI Target Discovery<\/h4>\n\n\n\n<p>You can discover available targets using the <strong>iscsiadm<\/strong> command. When iscsiadm is operating on discovery mode, three arguments are passed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong style=\"color: initial;\">sendtargets<\/strong><span style=\"color: initial;\"> <\/span><strong style=\"color: initial;\">type<\/strong><span style=\"color: initial;\"> \u2014 specifies how to find the targets.<\/span><\/li>\n\n\n\n<li><strong style=\"color: initial;\">portal<\/strong><span style=\"color: initial;\"> \u2014 tells the iscsiadm the IP address and port to address so as to perform discovery. Default port is 3260.<\/span><\/li>\n\n\n\n<li><strong style=\"color: initial;\">discover<\/strong><span style=\"color: initial;\"> \u2014 tells the iscsid service to perform a discovery.<\/span> <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo iscsiadm -m discovery -t st -p &#91;IP address of the iSCSI server]<\/code><\/pre>\n\n\n\n<p>So, to perform an iSCSI discovery, from the initiator run the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iscsiadm -m discovery -t sendtargets -p 192.168.57.45<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>192.168.57.45:3260,1 iqn.2023-05.com.kifarunix-demo:target00<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"view-i-scsi-target-details\">View iSCSI Target Details<\/h4>\n\n\n\n<p>To view the iSCSI target details, run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo iscsiadm -m node -T &#91;target IQN] -p &#91;IP address of the iSCSI server] --login<\/code><\/pre>\n\n\n\n<p>Replace <code>[target IQN]<\/code> with the IQN of the target and <code>[IP address of the iSCSI server]<\/code> with the IP address of the iSCSI server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iscsiadm -m node -T iqn.2023-05.com.kifarunix-demo:target00 -p 192.168.57.45 --login<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Logging in to &#91;iface: default, target: iqn.2023-05.com.kifarunix-demo:target00, portal: 192.168.57.45,3260] (multiple)\nLogin to &#91;iface: default, target: iqn.2023-05.com.kifarunix-demo:target00, portal: 192.168.57.45,3260] successful.<\/code><\/pre>\n\n\n\n<p>Once the connection is established, both session and node details can be checked as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iscsiadm -m session -o show<\/code><\/pre>\n\n\n\n<p><span style=\"color: initial;\"> <\/span>Output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tcp: &#91;1] 192.168.57.45:3260,1 iqn.2023-05.com.kifarunix-demo:target00 (non-flash)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>iscsiadm --mode node -P 1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Target: iqn.2023-05.com.kifarunix-demo:target00\n\tPortal: 192.168.57.45:3260,1\n\t\tIface Name: default<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"mounting-the-i-scsi-devices\">Mounting the iSCSI Devices<\/h4>\n\n\n\n<p>List the available iSCSI devices using the <strong>lsscsi<\/strong> command<span style=\"color: initial;\">;<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsscsi<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n&#91;3:0:0:0]    disk    LIO-ORG  iscsi_disk_01    4.0   \/dev\/sdb \n&#91;3:0:0:1]    disk    LIO-ORG  iscsi_file01     4.0   \/dev\/sdc<\/code><\/pre>\n\n\n\n<p>Our iSCSI device is denoted by <strong>\/dev\/sdb, \/dev\/sdc<\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"create-filesystem-on-i-scsi-disk\">Create Filesystem on iSCSI Disk<\/h4>\n\n\n\n<p>As you can see that the that the block device and fileio targets shared are now available to the initiator as&nbsp;<strong>sdb<\/strong>&nbsp;and&nbsp;<strong>sdc<\/strong>&nbsp;respectively and can now be used as if they were locally mounted.<\/p>\n\n\n\n<p>To make these devices usable, we need to partition them, create filesystems on them and mount them.<br>To partition the devices, you can use any partitioning system you are comfortable with. In our case we used parted in a scripted format as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>parted -s \/dev\/sdb \"mklabel msdos\"\nparted -s \/dev\/sdb \"mkpart primary 0% 100%\" <\/code><\/pre>\n\n\n\n<p>Create an EXT4 <span style=\"color: initial;\">filesystem<\/span> on the new iSCSI disk.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkfs.ext4 \/dev\/sdb1<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"mount-i-scsi-disk-on-client\">Mount iSCSI Disk on Client<\/h4>\n\n\n\n<p>Create a mount point say at&nbsp;<strong>\/mnt\/<\/strong>&nbsp;directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/mnt\/iscsi_disk<\/code><\/pre>\n\n\n\n<p>Mount the backstore;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount -t ext4 \/dev\/sdb1 \/mnt\/iscsi_disk\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>df -hT -P \/dev\/sdb1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Filesystem     Type  Size  Used Avail Use% Mounted on\n\/dev\/sdb1       ext4   4.0G   33M  4.0G   1% \/mnt\/iscsi_disk<\/code><\/pre>\n\n\n\n<p>To be able to mount it on boot, add this entry on <code>\/etc\/fstab<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"\/dev\/sdb1 \/mnt\/iscsi_disk ext4 _netdev  0 2\"  &gt;&gt; \/etc\/fstab<\/code><\/pre>\n\n\n\n<p>Big up! You have successfully configured an iSCSI target (server) and shared&nbsp; a block device to an iSCSI client.<\/p>\n\n\n\n<p>That concludes our guide on how to installing and configuring iSCSI storage server on Ubuntu.<\/p>\n\n\n\n<p>More information on;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/linux.die.net\/man\/8\/iscsiadm\" target=\"_blank\" rel=\"noreferrer noopener\">man iscsiadm<\/a><\/li>\n\n\n\n<li>man iscsi-target<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/setup-replicated-glusterfs-volume-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">Setup Replicated GlusterFS Volume on Ubuntu<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-install-and-configure-iscsi-storage-server-on-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">How Install and Configure iSCSI Storage server on CentOS<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we are going to learn how to install and configure iSCSI storage server on Ubuntu 18.04. Well, iSCSI, an acronym for Internet<\/p>\n","protected":false},"author":1,"featured_media":16561,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[39,79,64],"tags":[82,6663,6662,80,6661,81,67],"class_list":["post-401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-storage","category-iscsi","category-ubuntu-18-04","tag-initiator","tag-install-iscsi-initiator-on-ubuntu","tag-install-iscsi-target-on-ubuntu","tag-iscsi","tag-iscsi-portal-port-3260","tag-target","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/401"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=401"}],"version-history":[{"count":11,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":20949,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/401\/revisions\/20949"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/16561"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}