Debian / Ubuntu Linux Connect to an iSCSI Volume

Q. How do I format and connect to an iSCSI Volume under Debian / Ubuntu Linux?

A. You need to install open-iscsi package for high performance, transport independent iSCSI implementation under Debian / Ubuntu Linux. This package is also known as the Linux Open-iSCSI Initiator. You need Linux operating system with kernel version 2.6.16, or later. See REHL 5 / CentOS 5 / Fedora Linux specific instructions here.

Install Open-iSCSI Initiator

Type the following command at a shell prompt:
$ sudo apt-get install open-iscsi

Open-iSCSI default configuration

You need to soft-link (path fix) few two files to autologin work i.e. fix file paths for iscsiadm, enter:
ln -s /etc/{iscsid.conf,initiatorname.iscsi} /etc/iscsi/
Default configuration file could be located at /etc/iscsi/iscsid.conf or ~/.iscsid.conf. Open /etc/iscsi/iscsid.conf file:
# vi /etc/iscsi/iscsid.conf
Set node.session.auth.username, node.session.auth.password and other parameter as follows:
node.startup = automatic
node.session.auth.username = MY-ISCSI-USER
node.session.auth.password = MY-ISCSI-PASSWORD
discovery.sendtargets.auth.username = MY-ISCSI-USER
discovery.sendtargets.auth.password = MY-ISCSI-PASSWORD
node.session.timeo.replacement_timeout = 120
node.conn[0].timeo.login_timeout = 15
node.conn[0].timeo.logout_timeout = 15
node.conn[0].timeo.noop_out_interval = 10
node.conn[0].timeo.noop_out_timeout = 15
node.session.iscsi.InitialR2T = No
node.session.iscsi.ImmediateData = Yes
node.session.iscsi.FirstBurstLength = 262144
node.session.iscsi.MaxBurstLength = 16776192
node.conn[0].iscsi.MaxRecvDataSegmentLength = 65536

Save and close the file. Restart open-iscsi service:
# /etc/init.d/open-iscsi restart
Now you need to run a discovery against the iscsi target host:
# iscsiadm -m discovery -t sendtargets -p ISCSI-SERVER-IP-ADDRESS
If is iSCSI server IP address, enter:
# iscsiadm -m discovery -t sendtargets -p
# iscsiadm --mode discovery --type sendtargets --portal
Note down the record id (such as found by the discovery. You need the same for login. Login, must use a node record id found by the discovery:
# iscsiadm --mode node --targetname --portal --login
Finally restart the service again:
# /etc/init.d/open-iscsi restart

Format iSCSI Volume

Now you should see an additional drive on the system such as /dev/sdc. Use /var/log/messages file to find out device name:
# tail -f /var/log/messages
If your device name is /dev/sdc, enter the following command to create a partition:
# fdisk /dev/sdc
Next format partition:
# mkfs.ext3 /dev/sdc1
Mount file system:
# mkdir /iscsi
# mount /dev/sdc1 /iscsi

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 38 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
38 comments… add one
  • Alan Jul 9, 2008 @ 17:26

    Doesnt work for me mate,

    All the commands are entered without error but no device is found in /var/log/messages or dmesg.

    fdisk -l does not show it either.

    This is what I get (etch amd64)

    # iscsiadm -m discovery -t sendtargets -p,1,2

    but no drive found , any suggestions ?



  • Josef Jul 14, 2008 @ 22:53

    I think these instructions leave out a step. Particularly the logging in or mounting of the drive. Theoretically the “node.startup = automatic” and then iscsid restart should log into the drive for you. For whatever reason, though, the init.d file doesn’t read the config file, so any edits to that (at least for me) were useless. You can manually log into the drives with the following command:

    iscsiadm -m node -T -p -l

    also since it doesn’t read the config file you would need to manually edit any other settings for the target such as authmethod or login credentials.

    iscsiadm -m node -T -p

    alone can be used to show the config and

    iscsiadm -m node -T -p -o update -n node.session.auth.authmethod -v CHAP

    can be used to edit those settings.

  • 🐧 nixCraft Jul 15, 2008 @ 9:29


    I just reconfigured my Debian box using same info posted here without a problem. There is a small debian only fix, for file paths, enter:
    ln -s /etc/{iscsid.conf,initiatorname.iscsi} /etc/iscsi/

    Hope this solves problem for both of you. Let me know…

  • debel Jul 25, 2008 @ 13:45

    should i change the “initiatorname.iscsi” to something else and if yes where do i get the initiotor name?

  • 🐧 nixCraft Jul 25, 2008 @ 14:12


    initiatorname.iscsi is file name and it need to copy in /etc/iscsi directory.


  • tuxim Sep 3, 2008 @ 17:29

    Thanks a lot for this “as simple than usefull” tutorial.

  • TP Oct 5, 2008 @ 23:55

    I am experiencing the same issue, not able to find a newly generated device after loging into the target. Os is fedora on vmware workstation.
    Any suggestions? cat /proc/partitions only show sda, sda1, sda2 and dm1, dm2.
    Nothing in the var/log/messages file either.
    Any help would greatly be appreciated!

  • rgr Oct 29, 2008 @ 13:30

    amd64 doesn’t work with iscsi on debian. use another kernel (686 or so) and it should work.

  • Mr Zog Dec 12, 2008 @ 21:31

    No offense, but you don’t really -explain- anything.

    For example, is node.session.auth.username a user on the initiator or the target?

    Maybe we should assume that this user/password must exist on both initiator and target.

    And should the discovery.sendtargets.auth.password be the same as the
    node.session.auth.password ?

    What is session versus discovery?

  • 🐧 nixCraft Dec 12, 2008 @ 22:02

    This article is about iSCSI initiator client configuration and not about setting up target. So username and password mentioned here are about iSCSI initiator client configuration.

    > Maybe we should assume that this user/password must exist on both initiator and target.
    Username / password must exits on target. In /etc/iscsi/iscsid.conf you setup login information for target.

    > And should the discovery.sendtargets.auth.password be the same as the
    node.session.auth.password ?

    It can be or can not be… It depends upon your local configuration. Ask your storage admin about passwords.

    node.session.* => used to set a CHAP username and password for initiator authentication by the target(s).

    discovery.sendtargets.* => used to set a discovery session CHAP username and password for the initiator authentication by the target(s).

  • Chris Kehayias Jan 15, 2009 @ 21:13

    Thanks so much this worked for me right out of the gate. I have connect my Ubuntu Server VM to an OpenFiler SAN on another machine… Worked like a champ!

  • Martijn Mar 2, 2009 @ 12:07

    Worked like a dream, hooked up my OpenFiler iSCSI target without a problem and attached 2 Ubuntu installations to it for backup purposses. Thank you!

  • Chris Kehayias Mar 19, 2009 @ 12:11

    I am having issues after every restart where the open-iscsi isn’t starting up correctly. It is fixable by issuing /etc/init.d/open-iscsi restart, but that really isn’t a great solution. Any suggestions?

  • EE Apr 21, 2009 @ 13:11

    iscsi works perfectly with amd64 on debian. rgr’s message above caused me a couple of hours of wasted time!

  • Jon May 29, 2009 @ 16:11

    A nice guide. Thanks. :)

  • D.Sain Jun 1, 2009 @ 21:31

    One step I’ve noticed with the Ubuntu machines I’ve setup is that the target isn’t connected automatically on restart of the service. To correct this I’ve edited the target’s defaults file (/etc/iscsi/nodes/iqn*.sometargetname/ipaddress,node,1/default). In here I’ve changed node.conn[0].startup to automatic.

    This can also be setup with:
    ./iscsiadm -m node -T -p \
    -o update -n node.conn[0].startup -v automatic
    however sometimes I get an error (-5) with this although it in the docs at Sometimes it works. If not, edit the file.

  • D.Sain Jun 1, 2009 @ 21:35

    I should say, however this is the document I always go to for my Deb setups. Kudos to the author for saving us hours of work.

  • Ilia umudumov Aug 31, 2009 @ 12:04

    I do olready everything end it’s work fine I have some problems with isci enterprise tool but what is my #1 problem after restart I lost my partitions how I can correct this problem?

  • Scott Sep 3, 2009 @ 14:46

    This worked like a charm for me. Thank you very much.
    Ubuntu 9.04, 2.6.28-11-server

  • shixer Sep 25, 2009 @ 3:40

    Just what I needed, , thanks!

  • Mr. Scary Dec 14, 2009 @ 15:23

    Dr. Sain, thanks for that change (-o update -n node.conn[0].startup -v automatic)! I was blocked by that in the past. Now trying again and found your comment. This is such a hack. Shouldn’t that be covered by the line ‘node.startup = automatic’ in /etc/iscsi/iscsid.conf?

  • omidm Jan 30, 2010 @ 22:50

    I am having problem to mount my iscsi targets. I already have two internal disks /dev/sda and /dev/sdb, and the iscsi is being supplied by qnap-ts459. I have following all that is in this article, but I still cannot see any additional disks either via fdisk -l or in /var/adm/emssages. When checking the provider/targets on qnap, I can see there is a connection to that target, but I cannot see it on my ubuntu 9.10. Also when I initially start iscsid (via /etc/init.d/open-iscsi), I get ln: /bin/init/rw/sendsigs.omit.d: no such a directory. I have to create this directory manually to get rid of this message. Any help wold be appreciated.


    • Horn Sep 30, 2010 @ 14:25

      I have similar problem with “sendsigs.omit.d” file. this message disappears after manually creating this file but after reboot I need to do it once again. I am newbie in Linux and need your suggestion, should I add this file creation by my hands (is it typically for Linux world?) or it is issue which could be solved by correct service settings?

  • Romulus May 24, 2010 @ 3:54

    Thanks for this. Works great!

    Except…my target changes between /dev/sdc1 and /dev/sdd1 between reboots and is appears to be a random choice.

    Is there anyway to “lock” the target to the same /dev node so I can put it in my fstab to mount on boot up?



    • Tmp Aug 28, 2010 @ 1:47

      Use UUIDs in place of absolute device paths.

      pbarker@eccles:~$ sudo blkid /dev/sda1
      /dev/sda1: UUID=”1abd1d95-8926-49f6-817b-482f02f6c6cc” SEC_TYPE=”ext2″ TYPE=”ext3″
      pbarker@eccles:~$ grep 1abd1d95-8926-49f6-817b-482f02f6c6cc /etc/fstab
      UUID=1abd1d95-8926-49f6-817b-482f02f6c6cc / ext3 relatime,errors=remount-ro 0 1

  • patchy May 26, 2010 @ 17:08

    Just what I needed, , thanks!

  • Dalsim Aug 11, 2010 @ 13:13

    Hi, this looks good.

    I am trying to get my Networked DVD drive which is part of my NAS to work with my Ubuntu setup using an iscsi initiator. I have it working on Windows XP and Windows 7, now I am trying to get it working on Ubuntu. I will then have all computers on my network using one DVD drive.

    I tried the instructions above but when I try to save the iscsid.conf file I get the message:

    [ Error writing /etc/iscsi/iscsid.conf: Permission denied ]

    Is there a way around this? Or does anyone know how to get iscsi to work with a networked DVD drive?

    Any help would be appreciated.

    • Dalsim Aug 12, 2010 @ 10:10


      Well I managed to get a step further, but now I get the error below when I try to restart the iscsi service:

      * Starting iSCSI initiator service iscsid grep: /etc/iscsi/initiatorname.iscsi: Permission denied
      * Error: /etc/iscsi/initiatorname.iscsi does not contain a valid InitiatorName.
      * The iSCSI driver has not been correctly installed and cannot start.

      Has anyone encountered this or know how to configure it correctly?


      • matt Feb 17, 2011 @ 18:35

        I know this is old, but it may help someone else looking. I had this issue and simply forgot to run as sudo user.

        • EricStJean Apr 22, 2011 @ 8:59

          It helped me…

  • Nik Southworth Nov 18, 2010 @ 8:50


    I have three targets setup on my device but I only want my (debian) client to connect to one of them, when I restart the service however it attempts to login into all three and takes ages because the credentials are wrong for two of them.

    How do I specify which target to login to?

    • Tom Apr 14, 2011 @ 17:21

      I am having the same issue. Can anyone help!?

      There are 8 targets on my device, only want to connect to 1, but it is trying to connect to all 8, how can I tell it which target to log into?

  • Tony Miranda Dec 2, 2010 @ 18:45


    Is there anyway to load in the Initiator the new LUNs recently created in the Target ?
    The ‘open-iscsi restart’ doest the job, but not perfectly. When I restart the ‘open-iscsi’ I lost access to the the others LUNs that i was using before.

    Can’t I just reload/update without loosing access to the LUNs already in use ?


  • vigilon Dec 29, 2010 @ 19:48

    That is a very applicable info to our current project.

  • witek Feb 1, 2011 @ 8:19

    Works like a charm. Thanks.

    restarting iscsi wasn’t naccassary.

    Not tested reboot yet, but i see some configuration files automagically appeared in /etc/iscsi/nodes/ so I guess it should work. Eventually I will need to change node.startup = manual to node.startup = automatic, and of course put something into /etc/fstab :)

    IPv6 works without problem.

    PS. Generally you do not need to partition disk. One can create filesystem directly on disk, or put there other things (luks encryption, LVM, raid between multiple iscsi targets, etc) . It is even recomended sometimes i.e for btrfs, or zfs, or when sector aligment can be problematic. It is also not needed if exported block device is already a partition of some block device. Partitioning in such situations is possible of course, but not needed.

  • Chris "OneSeventeen" Adams Mar 8, 2011 @ 22:01

    These instructions helped a TON!

    Quick WARNING:
    setting node.startup = automatic will make it automatically connect to ALL DISCOVERED TARGETS on the portal!

    For me, this was all 10 targets that were in production use! eeek!

    Here’s what the manual says: (via
    To automate login to a node, use the following with the record ID
    (record ID is the targetname and portal) of the node discovered in the
    discovery above:
    iscsiadm -m node -T targetname -p ip:port –op update -n node.conn[0].startup -v automatic

  • duonghanu Aug 26, 2012 @ 14:54

    perfect. thanks.

  • Satish Kale Jul 14, 2015 @ 20:12

    I am able to successfully setup the iscsi initiator on Debian distribution, however after login to session, ” fdisk -l ” shows all the partitions of target without creating them.
    And after performing mkfs.ext4(formatting) on those partition and mounting, i didn’t get respective data in mounted volume.

    Any help will be appreciated.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum