The time now is Sun 19 May 2013, 17:43
All times are UTC - 4 |
| Author |
Message |
bwh1969
Joined: 25 Oct 2010 Posts: 126 Location: Allentown, PA
|
Posted: Sun 21 Nov 2010, 09:15 Post subject:
nfs (samba, cifs): getting shares to umount @ shutdown |
|
This is NOT very elegant, but I used two ubuntu scripts: one in the /etc/init.d/ and one in /lib/init.
The issue, if I mounted shares in terminal and forgot to umount them, then the machine would hang and not shut down. I knew this was an issue with earlier 'buntus so I assumed it was the same issue.
Pnethood is a great too for mounting shares, and might solve this issue BUT if I mounted shares that way, the mounted folders were invisible to any applications except file managers and wine programs (how odd, but I get this on two machines running two different puppies.
I modified "umountnfs.sh" slightly as when I ran it, there were was an fstab command in the file, and the file needed to call another one in /lib/init. There is no /lib/init in puppy so I created it.DON'T FORGET TO MAKE THESE TWO FILES EXECUTABLE.
Put this in /etc/init.d and name it umountnfs
| Code: | #! /bin/sh
### BEGIN INIT INFO
# Provides: umountnfs
# Required-Start:
# Required-Stop: umountfs
# Should-Stop: $network $portmap nfs-common
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Unmount all network filesystems except the root fs.
# Description: Also unmounts all virtual filesystems (proc, devfs,
# devpts, usbfs, sysfs) that are not mounted at the
# top level.
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
KERNEL="$(uname -s)"
RELEASE="$(uname -r)"
. /lib/init/vars.sh
. /lib/lsb/init-functions
case "${KERNEL}:${RELEASE}" in
Linux:[01].*|Linux:2.[01].*)
FLAGS=""
;;
Linux:2.[23].*|Linux:2.4.?|Linux:2.4.?-*|Linux:2.4.10|Linux:2.4.10-*)
FLAGS="-f"
;;
*)
FLAGS="-f -l"
;;
esac
do_stop () {
# Write a reboot record to /var/log/wtmp before unmounting
halt -w
# Remove bootclean flag files (precaution against symlink attacks)
rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
#
# Make list of points to unmount in reverse order of their creation
#
exec 9<&0 </etc/mtab
DIRS=""
while read -r DEV MTPT FSTYPE OPTS REST
do
case "$MTPT" in
/|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/lib/init/rw)
continue
;;
/var/run)
continue
;;
/var/lock)
continue
;;
esac
case "$FSTYPE" in
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs)
DIRS="$MTPT $DIRS"
;;
proc|procfs|linprocfs|devfs|devpts|usbfs|usbdevfs|sysfs)
DIRS="$MTPT $DIRS"
;;
esac
case "$OPTS" in
_netdev|*,_netdev|_netdev,*|*,_netdev,*)
DIRS="$MTPT $DIRS"
;;
esac
done
exec 0<&9 9<&-
if [ "$DIRS" ]
then
[ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems"
umount $FLAGS $DIRS
ES=$?
[ "$VERBOSE" = no ] || log_action_end_msg $ES
fi
}
case "$1" in
start)
# No-op
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop|"")
do_stop
;;
*)
echo "Usage: umountnfs.sh [start|stop]" >&2
exit 3
;;
esac
:
|
Then create folder /lib/init and put this file there (call it var.sh):
| Code: | #
# Set rcS vars
#
[ -f /etc/default/rcS ] && . /etc/default/rcS || true
# check for bootoption 'noswap' and do not activate swap
# partitions/files when it is set.
if [ -r /proc/cmdline ] && grep -qw 'noswap' /proc/cmdline ; then
NOSWAP=yes
else
NOSWAP=no
fi
# Accept the same 'quiet' option as the kernel
if [ ! -e /proc/cmdline ] || egrep -qw 'quiet' /proc/cmdline ; then
VERBOSE="no"
fi
# But allow both rcS and the kernel options 'quiet' to be overrided
# when INIT_VERBOSE=yes is used as well.
[ "$INIT_VERBOSE" ] && VERBOSE="$INIT_VERBOSE" || true
|
Lastly, call the file in /etc/rc.d/shutdown
I put this near the top of the file, as the first command right after the intro commented lines:
/etc/init.d/umountnfs
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|