xref: /illumos-gate/usr/src/cmd/svc/milestone/fs-minimal (revision a227b7f4f323ad89c40a86c430a5e891504a8e8b)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*a227b7f4Shs24103# Common Development and Distribution License (the "License").
7*a227b7f4Shs24103# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23*a227b7f4Shs24103# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
277c478bd9Sstevel@tonic-gate# All rights reserved.
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate#
307c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
337c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate# Mount other file systems to be available in single user mode.
367c478bd9Sstevel@tonic-gate# Currently, these are /var, /var/adm, /var/run and /tmp.  A change
377c478bd9Sstevel@tonic-gate# here will require a modification to the following programs (and
387c478bd9Sstevel@tonic-gate# documentation): /sbin/mountall, /sbin/umountall, and
397c478bd9Sstevel@tonic-gate# /lib/svc/bin/svc.startd.
407c478bd9Sstevel@tonic-gate
41*a227b7f4Shs24103rootiszfs=0
42*a227b7f4Shs24103readmnttab / < /etc/mnttab
43*a227b7f4Shs24103if [ "$fstype" = zfs ] ; then
44*a227b7f4Shs24103	rootiszfs=1
45*a227b7f4Shs24103	be=$special
46*a227b7f4Shs24103fi
47*a227b7f4Shs24103
487c478bd9Sstevel@tonic-gatefor fs in /var /var/adm /tmp; do
497c478bd9Sstevel@tonic-gate	readvfstab $fs < $vfstab
507c478bd9Sstevel@tonic-gate	if [ -n "$mountp" ]; then
517c478bd9Sstevel@tonic-gate		mounted $mountp $mntopts $fstype < /etc/mnttab && continue
527c478bd9Sstevel@tonic-gate		checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
537c478bd9Sstevel@tonic-gate		mountfs -O $mountp $fstype $mntopts - ||
547c478bd9Sstevel@tonic-gate		    exit $SMF_EXIT_ERR_FATAL
55*a227b7f4Shs24103		continue
56*a227b7f4Shs24103	fi
57*a227b7f4Shs24103	if [ "$rootiszfs" = 1 ]; then
58*a227b7f4Shs24103		mountpt=`zfs get -H -o value mountpoint $be$fs 2>/dev/null`
59*a227b7f4Shs24103		if [ $? = 0 ] ; then
60*a227b7f4Shs24103			if [ "x$mountpt" = "x$fs" ] ; then
61*a227b7f4Shs24103				/sbin/zfs mount $be$fs
62*a227b7f4Shs24103			fi
63*a227b7f4Shs24103		fi
647c478bd9Sstevel@tonic-gate	fi
657c478bd9Sstevel@tonic-gatedone
667c478bd9Sstevel@tonic-gate
67*a227b7f4Shs24103mounted /var/run - tmpfs < /etc/mnttab
68*a227b7f4Shs24103if [ $? != 0 ] ; then
697c478bd9Sstevel@tonic-gate	mountfs -O /var/run tmpfs - swap || exit $SMF_EXIT_ERR_FATAL
70*a227b7f4Shs24103fi
71*a227b7f4Shs24103
72*a227b7f4Shs24103if [ "$rootiszfs" = 1 ] ; then
73*a227b7f4Shs24103	/sbin/zfs list -rH -o mountpoint -s mountpoint $be | \
74*a227b7f4Shs24103	    while read mountp ; do
75*a227b7f4Shs24103		if [ "x$mountp" != "x" -a "$mountp" != "legacy" ] ; then
76*a227b7f4Shs24103			mounted $mountp - zfs < /etc/mnttab  && continue
77*a227b7f4Shs24103			/sbin/zfs mount $be$mountp
78*a227b7f4Shs24103		fi
79*a227b7f4Shs24103	done
80*a227b7f4Shs24103fi
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
83