#
# mountall.sh	Mount all filesystems.
#
# Version:	@(#)mountall.sh  2.85-23  29-Jul-2004  miquels@cistron.nl
#

VERBOSE=yes
TMPTIME=0
[ -f /etc/default/rcS ] && . /etc/default/rcS
. /etc/init.d/bootclean.sh

#
# Mount local file systems in /etc/fstab.
#
[ "$VERBOSE" != no ] && echo "Mounting local filesystems..."
mount -av -t nonfs,nonfs4,nosmbfs,nocifs,noncp,noncpfs,nocoda 2>&1 |
	egrep -v '(already|nothing was) mounted'

case `uname -s` in
	*FreeBSD)
		INITCTL=/etc/.initctl
		;;
	*)
		INITCTL=/dev/initctl
		;;
esac

#
# We might have mounted something over /dev, see if /dev/initctl is there.
#
if [ ! -p $INITCTL ]
then
	rm -f $INITCTL
	mknod -m 600 $INITCTL p
fi
kill -USR1 1

#
# Execute swapon command again, in case we want to swap to
# a file on a now mounted filesystem.
#
doswap=yes
case "`uname -sr`" in
	Linux\ 2.[0123].*)
		if grep -qs resync /proc/mdstat
		then
			doswap=no
		fi
		;;
esac
if [ $doswap = yes ]
then
	swapon -a 2> /dev/null
fi

#
#	Clean /tmp, /var/lock, /var/run
#
insmod /lib/modules/2.2.26/block/rd.o rd_size=10000
insmod /lib/modules/2.2.26/fs/minix.o
for i in 0 1 2 3 4 5 6 ; do
	dd if=/dev/zero of=/dev/ram$i >/dev/null 2>/dev/null
	mkfs.minix /dev/ram$i >/dev/null 2>/dev/null
done
mkfs.minix -i 8000 /dev/ram0 >/dev/null 2>/dev/null
mount -t minix /dev/ram0 /tmp
cp -a /dev/* /tmp >/dev/null 2>/dev/null
umount /tmp
mkfs.minix -i 8000 /dev/ram1 >/dev/null 2>/dev/null
mount -t minix /dev/ram1 /tmp
cp -a /etc/* /tmp >/dev/null 2>/dev/null
umount /tmp
mkfs.minix -i 8000 /dev/ram2 >/dev/null 2>/dev/null
mount -t minix /dev/ram2 /tmp
cp -a /var/run/* /tmp >/dev/null 2>/dev/null
umount /tmp
mount -t minix /dev/ram0 /dev
mount -t minix /dev/ram1 /etc
mount -t minix /dev/ram2 /var/run
mount -t minix /dev/ram3 /var/tmp
mount -t minix /dev/ram4 /var/lock
mount -t minix /dev/ram5 /var/log
mount -t minix /dev/ram6 /tmp
rm -f $INITCTL
mknod -m 600 $INITCTL p
kill -USR1 1
modprobe via-rhine
/etc/init.d/network restart
rm -f /etc/nologin

bootclean mountall
