xref: /freebsd/libexec/rc/rc.d/root (revision f3c5273d315a64826d2149ac453ff8c4583ddbe8)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: root
7# REQUIRE: fsck
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="root"
13desc="Mount root filesystem read/write"
14start_cmd="root_start"
15stop_cmd=":"
16
17root_start()
18{
19	# root normally must be read/write, but if this is a BOOTP NFS
20	# diskless boot it does not have to be.
21	#
22	case ${root_rw_mount} in
23	[Nn][Oo] | '')
24		;;
25	*)
26		if ! mount -uw /; then
27			echo 'Mounting root filesystem rw failed, startup aborted'
28			stop_boot true
29		fi
30		;;
31	esac
32
33	umount -a >/dev/null 2>&1
34
35	# If we booted a special kernel remove the record
36	# so we will boot the default kernel next time.
37	if [ -x /sbin/nextboot ]; then
38		/sbin/nextboot -D > /dev/null 2>&1
39	fi
40}
41
42load_rc_config $name
43run_rc_command "$1"
44