i am using open-iscsi-1.0-485 with fedora 4.
it works well, but i have problem if i want to mount
automatically iscsi volume at boot time,
and similarly to umount automatically at shutdown.
the problem is that iscsi volume are seen as standard scsi
disk, and the system try to mount them before iscsid is started
and similarly to umount after iscsid is down.
i solve the problem by creating a startup script to mount and umount
iscsi volume at the right time, for this if have set the noauto flag
in
fstab.
I am sure man can find a better solution, but meanwhile
it is easy to setup and it works.
here is the iscsi-volume script :
------------------cut here -----------------------------
#!/bin/sh
#
# chkconfig: - 99 01
# description: Mount / Umount iSCSI volume
#
#
# iSCSI volume are seen like standard scsi disk
# the rc scripts try to mount them early
# BEFORE iscsi is up,
# and more problematic, when shutdowning it try
# to umount after network is down -> crash
#
# one solution is to set the noauto flag for
# iSCSI volumes on fstab and call this script
# last on boot and early on shutdown
#
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
start()
{
RETVAL=0
echo -n "Mouting iSCSI volumes: "
mount /mnt/xxxx
mount /mnt/yyyy
return $RETVAL
}
stop()
{
RETVAL=0
echo -n "Unmounting iSCSI volumes: "
umount /mnt/xxxx
umount /mnt/yyyy
return $RETVAL
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
------------------cut here -----------------------------
just put this script in /etc/init.d/iscsi-volume
and do a chkconfig -add iscsi-volume; chkconfig iscsi-volume on
TODO: it would be better to have a way to flag iscsi volumes in
/etc/fstab
and to loop automaticaly on this list. Any idea ?
Best Regards.
...
> TODO: it would be better to have a way to flag iscsi volumes in
> /etc/fstab
> and to loop automaticaly on this list. Any idea ?
>
>
In FC5 you can add the _nettdev flag in the fstab:
/dev/sda /mnt/t0 ext2 _netdev 0 0
I think this also might work in FC4 due to us resuing the sane netfs
scripts. When my FC4 system is fixed I can check.
That should be "_netdev" like in the example below
so you can forget about my script, and use netdev instead.
thank you very much.
Hey, good. We lucked out. I guess i will add that to the docs.
Does anyone know what you do for suse and debian and gentoo? Do you add
_netdev to the fstab?
> so you can forget about my script, and use netdev instead.
>
> thank you very much.
>
no problem
yes, my fstab look like :
/dev/sda1 /mnt/lun/test1 auto _netdev 0 0
/dev/sda2 /mnt/lun/test2 auto _netdev 0 0
you just have to call /etc/init.d/netfs to get your iscsi drive
mounted.
you just have to pay attention that the iscsi daemon is launched before
netfs.
for 1.0-485 and fedora 4 it is not the case, i had to change the Sxx
number.
What did you change it too so we can fix that here?
Thanks
I'm just starting to look at SLES 10 myself, but I would hope they
already have this issue covered here. Perhaps our friends at SuSE
engineering could add something to this thread?
Regards,
Wayne.
here is the script:
---------------------cut here ---------------------
#!/bin/sh
#
# chkconfig: - 13 89
# description: Starts and stops the iSCSI initiator
#
# pidfile: /var/run/iscsid.pid
# config: /etc/iscsid.conf
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
ISCSID=`which iscsid`
ISCSIADM=`which iscsiadm`
if [ -z $ISCSID ] || [ -z $ISCSIADM ]
then
echo "open-iscsi not installed."
exit 1
fi
start_iscsid()
{
RETVAL=0
modprobe -q iscsi_tcp
daemon $ISCSID
RETVAL=$?
TARGETS=`$ISCSIADM -m node | sed 's@\[\(.*\)\] .*@\1@g'`
for rec in $TARGETS
do
STARTUP=`$ISCSIADM -m node -r $rec | grep "node.conn\[0\].startup" |
cut -d' ' -f3`
if [ $STARTUP = "automatic" ]
then
$ISCSIADM -m node -r $rec -l
fi
done
return $RETVAL
}
stop_iscsid()
{
RETVAL=0
sync
TARGETS=`$ISCSIADM | grep "\[*\]" | sed 's@\[\(.*\)\] .*@\1@g'`
for rec in $TARGETS
do
$ISCSIADM -m node -r $rec -u
done
pkill -KILL `basename $ISCSID`
modprobe -r iscsi_tcp
RETVAL=$?
return $RETVAL
}
start()
{
RETVAL=0
echo -n "Starting iSCSI initiator service: "
PID=`pidofproc $ISCSID`
if [ -z $PID ]
then
start_iscsid
fi
if [ $RETVAL == "0" ]
then
touch /var/lock/subsys/open-iscsi
echo_success
else
echo_failure
fi
echo
return $RETVAL
}
stop()
{
RETVAL=0
echo -n "Stopping iSCSI initiator service: "
PID=`pidofproc $ISCSID`
if [ $PID ]
then
stop_iscsid
fi
if [ $RETVAL == "0" ]
then
rm -f /var/lock/subsys/open-iscsi
echo_success
else
echo_failure
fi
echo
return $RETVAL
}
restart()
{
stop
start
}
status()
{
PID=`pidofproc $ISCSID`
if [ ! $PID ]
then
echo "iSCSI initiator is stopped."
exit 1
else
echo "iSCSI initiator is running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
-------------------cut here---------------------
thanks. I merged the fixes in svn r532.