#! /bin/sh
#
# umountfs	Turn off swap and unmount all local file systems.
#
# Version:      @(#)umountfs  2.79  26-Feb-2001  miquels@cistron.nl
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin

case "`uname -r`" in
  1.*|2.[01].*) FORCE=""   ;;
  *)            FORCE="-f" ;;
esac

umount -ttmpfs $FORCE -a -r

echo -n "Deactivating swap... "
swapoff -a
echo "done."

#
#	Turn off write caching on all IDE devices. Systems that
#	do poweroff-on-halt might otherwise still be writing
#	stuff to disk when the power is yanked - oops.
#	The package 'hdparm' needs to be installed for this to
#	work, unfortunately there's no /proc interface for it yet.
#
if [ -x /sbin/hdparm ] && [ -d /proc/ide ]
then
	sync
	cd /proc/ide
	for i in hd*
	do
		[ -b /dev/$i ] && hdparm -W0 /dev/$i >/dev/null 2>&1
	done
fi

echo -n "Unmounting local filesystems... "
umount $FORCE -a -r
echo "done."

mount -n -o remount,ro /

: exit 0
