initscripts/etc/rc.d/init.d/mountfs
2011-04-26 12:26:24 +02:00

68 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# mountfs - File System Mount Script
# Based on mountfs script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans <gerard@linuxfromscratch.org>
# Modified by Davide Madrisan <davide.madrisan@gmail.com>
. /etc/sysconfig/rc
. $rc_functions
KERNELMIN=`uname -r | sed -e 's,[^\.]*\.,,' -e 's,\..*,,'`
case "$1" in
start)
echo -n "Remounting root file system in read-write mode: "
mount -n -o remount,rw /
evaluate_retval
echo
# Dump dmesg to log file
dmesg > /var/log/dmesg.log
# Clean and recreate /etc/mtab
rm -f /etc/mtab # delete in case of symlink
cat /proc/mounts | \
grep -v "^rootfs" | \
grep -v "^/dev/cloop" | \
grep -v "^devfs" | \
grep -v "^sysfs" | \
grep -v "^/dev/root.old" >/etc/mtab
rm -f /etc/mtab~ /etc/mtab~~
[ ! -f /proc/bus/usb/devices ] && mount -t usbfs usbfs /proc/bus/usb
#[ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
# The follow mount command will mount all file systems. If you
# have other (network based) file system that should not be or
# cannot be mounted at this time, add them to the NO_FS variable
# below. All file systems that are added to the variable in the
# form of no<filesystem> will be skipped.
NO_FS="nonfs,nosmbfs,noproc,nosysfs,nousbdevfs,nousbfs,nodevfs"
echo -n "Mounting remaining file systems: "
mount -a -t $NO_FS
evaluate_retval
echo
;;
stop)
echo -n "Unmounting all other currently mounted file systems: "
# remove data= in /etc/mtab to prevent problems when system reboots with different mode
# (as with kernel 2.6.30 upgrade)
sed -i "s|[,]*data=[a-z]*||" /etc/mtab
# [ -f /proc/bus/usb/devices ] && umount /proc/bus/usb >/dev/null 2>&1
# umount -l /proc
# umount -l /sys
NO_FS="nonfs,nosmbfs,noproc,nosysfs,nousbdevfs,nousbfs,nodevfs"
sync
umount -a -f -r -t $NO_FS >/dev/null 2>&1
evaluate_retval
echo
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac