How to Connect to an iSCSI Storage Target on Ubuntu Server

Internet Small Computer Systems Interface (iSCSI) is a networking standard that allows servers to access remote block-level storage over a standard TCP/IP network. Unlike NFS or SMB which share files, iSCSI shares raw disk space (a Logical Unit Number, or LUN) that the operating system formats and treats exactly like a local physical hard drive. Connecting an Ubuntu server to an iSCSI target (like a TrueNAS server or an enterprise SAN) requires the open-iscsi initiator package.

Step 1: Install the iSCSI Initiator

First, update your package repository and install the necessary software:

sudo apt update
sudo apt install open-iscsi

Once installed, the iSCSI daemon (iscsid) will start automatically.

Step 2: Discover the iSCSI Target

Before you can connect, you must ask the storage server what storage LUNs it is making available. This process is called “discovery”.

Assuming your storage server’s IP address is 192.168.1.100, run the following command:

sudo iscsiadm -m discovery -t sendtargets -p 192.168.1.100

The output will list the Target Qualified Name (IQN) of the available storage. It will look something like this: 192.168.1.100:3260,1 iqn.2005-10.org.freenas.ctl:target0. Copy that IQN string; you will need it for the next step.

Step 3: Log In to the Target

Now that your server knows the IQN of the target, you can initiate the connection (log in).

sudo iscsiadm -m node -T iqn.2005-10.org.freenas.ctl:target0 -p 192.168.1.100 --login

If successful, the terminal will confirm the login was successful. The Ubuntu kernel has now attached a new virtual SCSI drive.

Step 4: Verify the New Drive

To see the newly attached block storage, list all connected block devices:

lsblk

You should see a new, unformatted drive at the bottom of the list, usually designated as /dev/sdb or /dev/sdc, depending on how many physical drives your server has. You can now use fdisk to partition this drive, mkfs.ext4 to format it, and add it to your /etc/fstab to mount it permanently, exactly as if you had plugged a physical SATA drive into the motherboard.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.