xref: /titanic_52/usr/src/cmd/svc/milestone/fs-minimal (revision f5c2e7ea56aaa46a9976476fb0cb1f02b9426f07)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
27# All rights reserved.
28#
29#
30
31. /lib/svc/share/smf_include.sh
32. /lib/svc/share/fs_include.sh
33
34# Mount other file systems to be available in single user mode.
35# Currently, these are /var, /var/adm, /var/run and /tmp.  A change
36# here will require a modification to the following programs (and
37# documentation): /sbin/mountall, /sbin/umountall, and
38# /lib/svc/bin/svc.startd.
39
40rootiszfs=0
41readmnttab / < /etc/mnttab
42if [ "$fstype" = zfs ] ; then
43	rootiszfs=1
44	be=$special
45fi
46
47for fs in /var /var/adm /tmp; do
48	readvfstab $fs < $vfstab
49	if [ -n "$mountp" ]; then
50		mounted $mountp $mntopts $fstype < /etc/mnttab && continue
51		checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
52		mountfs -O $mountp $fstype $mntopts - ||
53		    exit $SMF_EXIT_ERR_FATAL
54		continue
55	fi
56	if [ "$rootiszfs" = 1 ]; then
57		mountpt=`zfs get -H -o value mountpoint $be$fs 2>/dev/null`
58		if [ $? = 0 ] ; then
59			if [ "x$mountpt" = "x$fs" ] ; then
60				/sbin/zfs mount -O $be$fs
61			fi
62		fi
63	fi
64done
65
66mounted /var/run - tmpfs < /etc/mnttab
67if [ $? != 0 ] ; then
68	mountfs -O /var/run tmpfs - swap || exit $SMF_EXIT_ERR_FATAL
69fi
70
71if [ ! -f /var/run/tzsync ] ; then
72	/sbin/tzreload -I
73fi
74
75if [ "$rootiszfs" = 1 ] ; then
76	/sbin/zfs list -rH -o mountpoint -s mountpoint -t filesystem $be | \
77	    while read mountp ; do
78		if [ "x$mountp" != "x" -a "$mountp" != "legacy" ] ; then
79			mounted $mountp - zfs < /etc/mnttab  && continue
80			/sbin/zfs mount $be$mountp
81		fi
82	done
83fi
84
85exit $SMF_EXIT_OK
86