tag 555541 + patch
thanks
In order to make glusterfs work properly with fstab and insserv, two
scripts
have to be used : the first should mount the glusterfs partition, the
second
should wait for the partitions to be mounted in case of asynchronous
startup.
Moreover, insserv header should be properly configured in the scripts.
This mimics NFS client scripts behavior.
The following set of files manage to correctly mount the partitions at
startup:
* glusterfs-mount mounts the glusterfs partitions ; its insserv header is
configured to depend on fuse and on $network.
* mountglusterfs.sh wait for the gluster partition to be mounted ; its
insserv header is configured to only depend on the other init script
glusterfs-mount.
* The following line should be added to a dedicated file in the insserv
conf.d directory : $remote_fs $local_fs +mountglusterfs +sendsigs
so that application such as xen might start when their configuration is
on a
remote glusterfs file system.
The problem is that if you make use of nfs, it creates a loop in
insserv: fuse
also depends on $remote_fs in case (according to the documentation) the
/usr is
mounted via nfs...
Since we don't need that feature we simply remove the fuse dependency on
$remote_fs by overriding its configuration in the /etc/insserv/overrides/
directory (the joined fuse file). Perhaps, there is a need for splitting
$remote_fs and and new
insserv variable $remote_usr, but this is beyond the scope of this package.
Those files should be provided by the glusterfs-client package.
Thanks,
--Jan
#! /bin/bash
# description: Mount glustefs volumes at boot.
### BEGIN INIT INFO
# Provides: glusterfs-mount
# Required-Start: $network fuse
# Required-Stop:
# Default-Start: 2 3 4 5 S
# Default-Stop:
# Short-Description: Mount glusterfs volumes at boot.
# Description: Mount glusterfs volumes at boot.
### END INIT INFO
. /lib/lsb/init-functions
glusterfsmounts()
{
LC_ALL=C awk '$3 == "fuse.glusterfs" { print $2 }' /proc/mounts
}
glusterfsfstab()
{
LC_ALL=C awk '!/^#/ && $3 == "glusterfs" && $4 !~ /noauto/ { print $2 }'
/etc/fstab
}
case "$1" in
start|reload)
if [ -n "`glusterfsfstab`" ] ; then
log_action_begin_msg "Mounting glusterfs partitions"
mount -at glusterfs
if [ $? = 0 ]
then
log_action_end_msg 0
else
echo "Error : Unable to mount glusterfs filesystems"
log_action_end_msg 1
fi
fi
;;
stop)
log_action_begin_msg "Unmounting glusterfs partitions"
remaining="`glusterfsmounts`"
sig=
retry=3
while [ -n "remaining" -a "$retry" -gt 0 ]; do
for i in $remaining; do
umount $i
done
sleep 1
remaining="`glusterfsmounts`"
[ -z "$remaining" ] && break
echo " Error :Unable to unmount glusterfs attempt : $retry/3"
sleep 5
retry=$(($retry - 1))
sig=-9
done
[ -z "$remaining" ] && log_action_end_msg 0 || log_action_end_msg 1
;;
restart)
$0 stop
$0 start
;;
status)
if [ -f /proc/mounts ] ; then
[ -n "`glusterfsfstab`" ] && {
echo "Configured glusterfs mountpoints: " `glusterfsfstab`
}
[ -n "`glusterfsmounts`" ] && {
echo "Active glusterfs mountpoints: " `glusterfsmounts`
}
else
echo -n "Checking glusterfs mountpoints: "
echo -n "FAILED"
fi
;;
*)
echo "Usage: $0 {start|stop|status|reload|restart}"
exit 1
esac
#! /bin/sh
### BEGIN INIT INFO
# Provides: mountglusterfs
# Required-Start: glusterfs-mount
# Required-Stop: glusterfs-mount
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Wait for glusterfs file systems to be mounted
# Description: Wait for glusterfs file systems to be mounted
### END INIT INFO
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_wait_async_mount() {
[ -f /etc/fstab ] || return
#
# Read through fstab line by line. If it is glusterfs, set the flag
# for mounting glusterfs file systems. If any glusterfs partition is
found
# then wait around for it.
#
exec 9<&0 </etc/fstab
waitglusterfs=
while read DEV MTPT FSTYPE OPTS REST
do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
esac
case "$FSTYPE" in
glusterfs)
;;
*)
continue
;;
esac
case "$MTPT" in
/mnt/glusterfs)
waitglusterfs="$waitglusterfs $MTPT"
;;
esac
done
exec 0<&9 9<&-
# Wait for each path, the timeout is for all of them as that's
# really the maximum time we have to wait anyway
TIMEOUT=900
for mountpt in $waitglusterfs; do
log_action_begin_msg "Waiting for $mountpt"
while ! mountpoint -q $mountpt; do
sleep 0.1
TIMEOUT=$(( $TIMEOUT - 1 ))
if [ $TIMEOUT -le 0 ]; then
log_action_end_msg 1
break
fi
done
if [ $TIMEOUT -gt 0 ]; then
log_action_end_msg 0
fi
done
}
case "$1" in
start)
# Using 'no !=' instead of 'yes =' to make sure async nfs
# mounting is the default even without a value in
# /etc/default/rcS
if [ no != "$ASYNCMOUNTNFS" ] ; then
do_wait_async_mount
else
FROMINITD=yes /etc/network/if-up.d/mountnfs
fi
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
: exit 0
### BEGIN INIT INFO
# Provides: fuse
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Filesystem in userspace with no dependencies on remote_fs
for glusterfs
# Description: This file load all what's needed to make fuse work fine
with no dependencies on remote_fs for glusterfs
### END INIT INFO