NetBSD/etc/rc.d/fsck_root
joerg e7f29a3386 Split fsck during boot into two phases. Check the root file system
first, mount root and run the various disk providers. Add swap and
check the remaining file systems after that.
This breaks the dependency cycle for lvm, which needs writeable /dev.
Depend on rndctl in cgd.
2009-04-21 16:08:57 +00:00

53 lines
967 B
Bash
Executable File

#!/bin/sh
#
# $NetBSD: fsck_root,v 1.1 2009/04/21 16:08:57 joerg Exp $
#
# PROVIDE: fsck_root
$_rc_subr_loaded . /etc/rc.subr
name="fsck_root"
start_cmd="fsck_root_start"
stop_cmd=":"
fsck_root_start()
{
if [ -e /fastboot ]; then
echo "Fast boot: skipping disk checks."
return
fi
trap : 2 # Ignore SIGINT, SIGQUIT, so we
trap : 3 # enter single-user mode on failure.
echo "Starting root file system check:"
fsck $fsck_flags /
local fsck_error="$?"
case $fsck_error in
0) # OK
return
;;
2) # Needs re-run, still fs errors
echo "file system still has errors; re-run fsck manually!"
;;
4) # Root modified
echo "Root filesystem was modified, rebooting ..."
reboot
echo "Reboot failed; help!"
;;
8) # Check failed
echo "Automatic file system check failed; help!"
;;
12) # Got signal
echo "Boot interrupted."
;;
*)
echo "Unknown error $fsck_error; help!"
;;
esac
stop_boot
}
load_rc_config $name
run_rc_command "$1"