Auto Mounting an Unpartitioned iSCSI LUN at System Startup


by Muhammad Sharfuddin


Administrators who know how to manually edit the /etc/fstab file, and create a file system(reiserfs, ext3) manually from the command line utility(mkfs.reiserfs / mkfs.ext3 etc), and also know how to configure the iSCSI initiator and target properly.


  1. an iSCSI target configured (in my example I have configured a SLES 10 SP2 x864).
  2. an iSCSI client(initiator) configured (in my example I have configured a SLES 10 SP2 i586 ).
  3. on iSCSI client the filesystem has been created on the iSCSI LUN (entire disk), without creating a partition on iSCSI LUN, i.e creating the file system onto the whole LUN (entire disk), instead of first creating a partition on the LUN, then creating a file system on the partition.
  4. on iSCSI client, in /etc/fstab proper information (line) has been written to automatically mount the iSCSI LUN on system startup/boot.


Unpartitioned iSCSI LUN(s) are not mounted automatically at system startup/boot.


I sometimes (very rare) found that unpartitioned iSCSI LUNs mounted automatically at system startup, but this is very rare.


Nothing obvious (it might be a bug in SLES 10 SP2), but one thing I can say for sure is that since using YaST, we can not make a file system on an unpartitioned disk(LUN), so it automatically means that such a setup is at least not supported.


Either use partitioned LUNs, or, if you think that you should use the unpartitioned LUN (entire disk), then create a file ‘after.local’ under the “/etc/init.d/” directory, and append “mount -a” in the /etc/init.d/after.local.

Here is the example.

/etc/fstab of iSCSI-initiator(client)

cat /etc/fstab |grep iscsi

/dev/disk/by-path/ /tdata reiserfs auto,hotplug 1 2

Here you can see, I am mounting the unpartitioned LUN(…:2c59a403-7e5c-4ae0-84d6-103a8be06200-lun-0), and not the partitioned LUN(:2c59a403-7e5c-4ae0-84d6-103a8be06200-lun-0-part1)

Now, as I said earlier, that this iSCSI LUN won’t mount automatically at system startup, that’s why we will use /etc/init.d/after.local. Here is the output of the ‘/etc/init.d/after.local’ that mounts it automatically at system startup

cat /etc/init.d/after.local

mount -a

Now, reboot your iSCSI client machine, and you will find that the iSCSI LUN(s) are automatically mounted successfully at system startup.

But, I still don’t recommend the above approach/method to mount the iSCSI LUNs (either partitioned or unpartitioned)… because when you shutdown your machine (or whenever you stop the iSCSI-initiator service(/etc/init.d/open-iscsi stop)) you will notice/find the following message on your console:

Stopping iSCSI initiator service: FATAL: Module iscsi_tcp is in use.

The above FATAL message is obvious, because during the system shutdown process, the iSCSI-initiator(client) service stops very early, while all of the mounted file systems (including the iSCSI LUNs) are unmounted in the very last stage of shutdown process. We always see the above FATAL error whenever the system is going to shutdown while iSCSI LUNs (partitioned or unpartitioned(entire disk)) are mounted.

Preferred solution for mounting partitioned and unpartitioned (entire disk) iSCSI LUN(s)

To avoid the “FATAL: Module iscsi_tcp is in use” message, and to mount the unpartitioned iSCSI LUNs (entire disk) automatically, I preferred to use a script.

Here is the step by step method we use to mount the iSCSI LUNs.

To my iSCSI-client, two LUNs are available.

# lsscsi |grep IET
[3:0:0:0]    disk    IET      VIRTUAL-DISK     0     /dev/sdc
[4:0:0:0]    disk    IET      VIRTUAL-DISK     0     /dev/sdd

# ls -l /dev/disk/by-path/ |grep ip
lrwxrwxrwx 1 root root  9 Apr 22 13:56 -> ../../sdc
lrwxrwxrwx 1 root root  9 Apr 22 13:56 -> ../../sdd

In this example we will use the entire /dev/sdc(entire disk), and create a partition on /dev/sdd, i.e we will create file system on /dev/sdd1.

First we create a file system on /dev/sdc.

# mkreiserfs -f /dev/sdc
Note: I used the option ‘-f’ to make a file system on the entire disk

Then create a partition /dev/sdd1 and make a file system on it.

Append the following lines in /etc/fstab:

cat /etc/fstab |grep ip
/dev/disk/by-path/    /edata  reiserfs hotplug  1 2
/dev/disk/by-path/  /pdata reiserfs hotplug,noauto 1 2


/dev/disk/by-path/ is an entire disk(unpartitioned LUN)
/dev/disk/by-path/ is the partition.


/dev/sdd1(/dev/disk/by-path/ is the partition, it will be automatically mounted at the system startup, and since I want to avoid the “FATAL: Module iscsi_tcp is in use” message and also want to mount all of the iSCSI LUNs(either partitioned or unpartitioned) via a script, I used the noauto option, so that this LUN won’t mount automatically.

Now after making the file system and making proper editing in /etc/fstab, here is the runlevel script that mounts all of the iSCSI LUNs, and also unmount the iSCSI LUNs before the iSCSI-initiator service stop (i. no more “FATAL: Module iscsi_tcp is in use” message).

cat /etc/init.d/mount_iscsi_luns

# /etc/init.d/mount_iscsi_luns
# Provides:         mount_iscsi_luns
# Required-Start:   iscsi
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: mounts the iSCSI LUNs

. /etc/rc.status

# Reset status of this service

case "$1" in
        sleep 4
	echo -e "\nStart mounting the  iSCSI LUN(s)  \n"
        for i in `cat /etc/fstab | grep ^"/dev/disk/by-path/ip-" | awk {'print $2'}`
           cat /proc/mounts | grep "$i" > /dev/null
           if [ "$?" == "0" ]
              echo -e "\n $i already mounted ... skipping, and moving to next task"
              echo -e "\n Trying to mount $i \n"
              /bin/mount "$i"
              if [ "$?" == "0" ]
                 then cat /proc/mounts | grep "$i" ; echo -e "  ... $i mounted Successfully \n"
                 else echo -e "Unable to mount $i \n"

	# Remember status and be verbose
	rc_status -v
	echo -n " Unmounting  the  iSCSI LUN(s) "
        for i in `cat /proc/mounts | grep "/dev/disk/by-path/ip-"  | awk {'print $2'}`
           /bin/umount $i
           if [ "$?" == "0" ]
              then echo -e "\n iSCSI LUN($i) unmounted successfully"

	# Remember status and be verbose
	rc_status -v
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start

	# Remember status and be quiet
	echo -n "Checking mount status of iSCSI LUN(s) "
        cat /proc/mounts | grep  "/dev/disk/by-path/ip-"

	# "status" option and adapts its messages accordingly.
	rc_status -v
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1

Make this script executeable, via:

chmod +x /etc/init.d/mount_iscsi_luns

Make this script automatically run on system startup:

insserv mount_iscsi_luns

Now reboot your machine to check that both of the iSCSI LUNs are mounted, and you will also note that now you wont get “FATAL: Module iscsi_tcp is in use” message on system shutdown.

Done 😉

(Visited 1 times, 1 visits today)

Leave a Reply

Your email address will not be published.

No comments yet