#! /bin/sh

# filesystems: System initialization script

. init-script-lib

case $1 in 
	start)
	    fatal need devfs
	    fatal need fsck-all

	    say remounting root fs readwrite
	
	    important mount -n -o remount,rw /
		# -n: don't write to mtab
		# -o remount,rw: options, remount readwrite 

	    say clearing mtabs

	    rm -f /etc/mtab*

	    say mounting all non-NFS filesystems

	    important mount -a -t nonfs 
		# -a: all in fstab
		# -v: verbose
		# -t nonfs: all types but nfs
		# -F: fork
		#
		# This call writes the root fs into mtab

	    exit 0 

		# even if mount did not succeed e.g. because of
		# unknown filesystem type
	    ;;
	stop)
	    # Do not umount filesystems as other programs probably want them

# 	    say remounting filesystems readonly

# 	    important mount -n -a -o remount,ro

# 	    say umounting all

# 	    important umount -n -ar

# 	    sync
# 	    sleep 2 # To clear hardware drive caches.
# 	    sync
	    ;;
esac
