Recent Changes - Search:

Bob Brandt

Linux Projects


Server Projects

Desktop Projects

Novell Projects


VMware Projects


N900 (Maemo) Projects


Python Projects


OpenOffice.org Projects


Other Projects


PmWiki

edit SideBar

Workaround for iSCSI issues on SLES11

I have been using iSCSI with SLES10 for a while without any problems. And even though I have been using SLES11 for months, I never ran across this problem until recently. Turns out that using iSCSI with SLES11 (or SuSE 11.1) has a bit of a problem.

The problem is that you are unable to mount the iSCSI LUNs from within the /etc/fstab file when using the open-scsi software initiator. Now I am fully willing to admit that this "problem" is just due to my own stupidity, but from the research I have done online, I am not the only one to notice this problem.

The issue I had was that the system would try to mount the LUNs before the network was up and therefore failed. I tried a number of possible remedies but nothing worked:

  • Figuring out what remote_fs is and how to use it.
  • Moving the network_remote deamon script till after the iSCSI initiator was up.
  • Creating my own /etc/fstab.iscsi file.
  • Using the _netdev and auto options in the /etc/fstab file.

What other people have done is to create custom scripts. However my problem with these script is that they seemed sloppy. I needed a system that would handle both the iscsi initiator and the mounting of the filesystems in one go. And I also wanted a system that would work with the existing GNU utilities.

What I can up with was a wrapper script for the open-scsi deamon (see below). This handles both the software initiator and mounting of the filesystems - for both starting and stopping. This way I can be sure certain that the system will neither try to mount filesystems before the an iSCSI connection is established nor kill the iSCSI connection without first umounting the filesystems.

To make this script work it is necessary to slightly modify the iSCSI entries in the /etc/fstab file:

  • As you can see in the example below, the filesystem type is scsi,something . Since there is not a iscsi filesystem type it will mount the filesystem as something in this case ext3.
  • Since the filesystem will not be available when the system first mounts the filesystems, it will fail when if reaches the iSCSI line, so you need to add the nofail option to the end of the option line. (Note: on eariler systems nofail is not a vaild option so use _netdev)
  • Since the filesystem is not physically attached, it is probably best to make sure that all writes are synchronous, so add the sync and dirsync options as well.
/etc/fstab (an example)
/dev/system/swap     swap                 swap       defaults              0 0
/dev/system/root     /                    ext3       acl,user_xattr        1 1
/dev/sda1            /boot                ext3       acl,user_xattr        1 2
/dev/system/home     /home                ext3       acl,user_xattr        1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
UUID=81ff75b2-c311-46ea-b1b9-bade8b597624	/data	iscsi,ext3	acl,user_xattr,sync,dirsync,nofail,noatime        1 2
/etc/init.d/iscsi-mount
#!/bin/bash
#
# /etc/init.d/open-iscsi
#
### BEGIN INIT INFO
# Provides:          iscsi-mount
# Required-Start:    $network
# Should-Start:      iscsitarget
# Required-Stop:     $network
# Should-Stop:       iscsitarget
# Default-Start:     3 5
# Default-Stop:      
# Short-Description: iSCSI initiator daemon wrapper
# Description:       The iSCSI initator is used to create and
#                    manage iSCSI connections to a iSCSI Target.
#                    This wrapper also takes care of iSCSI 
#                    fstab entries.
#                    Created by Bob Brandt <projects@brandt.ie>
#                    
### END INIT INFO

ISCSISCRIPT=/etc/init.d/open-iscsi
MOUNTSCRIPT=/etc/init.d/iscsi-mount
RCSCRIPT=/sbin/rciscsi-mount
declare -i overallstatus=0

test -h $RCSCRIPT || ln -sf $MOUNTSCRIPT $RCSCRIPT

# Source LSB init functions
. /etc/rc.status

# Reset status of this service
rc_reset

iscsimount() {
	rc_reset
	echo -n "Mounting $1: "
	mount $1
	rc_status -v
	return $?
}

iscsiumount() {
	rc_reset
	echo -n "Umounting $1: "
	umount $1
	rc_status -v
	return $?
}

iscsicheck() {
	rc_reset
	echo -n "Verify if $1 is mounted: "
	mount | grep "on $1\b" > /dev/null
	rc_status -v
	return $?
}

iscsimountall() {
	#Added to take care of LVM groups on iSCSI
	vgscan > /dev/null
	sleep 1
	vgchange -a y > /dev/null 

	# Find all fstab lines with iscsi as the fstype
	for mountpoint in `grep "iscsi," /etc/fstab | sed -e 's|\s*iscsi,.*||' -e 's|.*[ \t]/|/|'`; do
		# Only try to mount filesystems that are NOT currently mounted.
		if ! mount | grep "on $mountpoint\b" > /dev/null 
		then
			iscsimount $mountpoint || overallstatus=$?
		fi
	done
	return $overallstatus
}

iscsiumountall() {
	# Find all fstab lines with iscsi as the fstype
	for mountpoint in `grep "iscsi," /etc/fstab | sed -e 's|\s*iscsi,.*||' -e 's|.*[ \t]/|/|'`; do
		# Only try to umount filesystems that are currently mounted.
		if mount | grep "on $mountpoint\b" > /dev/null
		then
			iscsiumount $mountpoint || overallstatus=$?
		fi
	done
	return $overallstatus
}

iscsicheckall() {
	# Find all fstab lines with iscsi as the fstype
	for mountpoint in `grep "iscsi," /etc/fstab | sed -e 's|\s*iscsi,.*||' -e 's|.*[ \t]/|/|'`; do
		iscsicheck $mountpoint || overallstatus=$?
	done
	return $overallstatus
}

case "$1" in
    start)  $ISCSISCRIPT $@ && sleep 1 && iscsimountall ;;
    stop)   iscsiumountall && $ISCSISCRIPT $@ ; overallstatus=$? ;;
    status) $ISCSISCRIPT $@ && iscsicheckall ;;
    restart|reload) $0 stop && sleep 1 && $0 start ; overallstatus=$? ;;
    initiator) shift ; $ISCSISCRIPT $@ ; overallstatus=$? ;;
    *) echo "Usage: $0 {start|stop|status|restart|reload|initiator}"; overallstatus=1 ;;
esac
rc_failed $overallstatus
rc_exit
Edit - History - Print - Recent Changes - Search
Page last modified on November 13, 2009, at 04:07 PM