xref: /titanic_50/usr/src/cmd/svc/milestone/fs-minimal (revision d1419d5a02eaedd520f925cd465fd62f3950ae43)
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
6a227b7f4Shs24103# Common Development and Distribution License (the "License").
7a227b7f4Shs24103# 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*d1419d5aSNobutomo Nakano# Copyright 2009 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
317c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
327c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate# Mount other file systems to be available in single user mode.
357c478bd9Sstevel@tonic-gate# Currently, these are /var, /var/adm, /var/run and /tmp.  A change
367c478bd9Sstevel@tonic-gate# here will require a modification to the following programs (and
377c478bd9Sstevel@tonic-gate# documentation): /sbin/mountall, /sbin/umountall, and
387c478bd9Sstevel@tonic-gate# /lib/svc/bin/svc.startd.
397c478bd9Sstevel@tonic-gate
40a227b7f4Shs24103rootiszfs=0
41a227b7f4Shs24103readmnttab / < /etc/mnttab
42a227b7f4Shs24103if [ "$fstype" = zfs ] ; then
43a227b7f4Shs24103	rootiszfs=1
44a227b7f4Shs24103	be=$special
45a227b7f4Shs24103fi
46a227b7f4Shs24103
477c478bd9Sstevel@tonic-gatefor fs in /var /var/adm /tmp; do
487c478bd9Sstevel@tonic-gate	readvfstab $fs < $vfstab
497c478bd9Sstevel@tonic-gate	if [ -n "$mountp" ]; then
507c478bd9Sstevel@tonic-gate		mounted $mountp $mntopts $fstype < /etc/mnttab && continue
517c478bd9Sstevel@tonic-gate		checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
527c478bd9Sstevel@tonic-gate		mountfs -O $mountp $fstype $mntopts - ||
537c478bd9Sstevel@tonic-gate		    exit $SMF_EXIT_ERR_FATAL
54a227b7f4Shs24103		continue
55a227b7f4Shs24103	fi
56a227b7f4Shs24103	if [ "$rootiszfs" = 1 ]; then
57a227b7f4Shs24103		mountpt=`zfs get -H -o value mountpoint $be$fs 2>/dev/null`
58a227b7f4Shs24103		if [ $? = 0 ] ; then
59a227b7f4Shs24103			if [ "x$mountpt" = "x$fs" ] ; then
60e7cbe64fSgw25295				/sbin/zfs mount -O $be$fs
61a227b7f4Shs24103			fi
62a227b7f4Shs24103		fi
637c478bd9Sstevel@tonic-gate	fi
647c478bd9Sstevel@tonic-gatedone
657c478bd9Sstevel@tonic-gate
66a227b7f4Shs24103mounted /var/run - tmpfs < /etc/mnttab
67a227b7f4Shs24103if [ $? != 0 ] ; then
687c478bd9Sstevel@tonic-gate	mountfs -O /var/run tmpfs - swap || exit $SMF_EXIT_ERR_FATAL
69a227b7f4Shs24103fi
70a227b7f4Shs24103
71*d1419d5aSNobutomo Nakanoif [ ! -f /var/run/tzsync ] ; then
72*d1419d5aSNobutomo Nakano	/sbin/tzreload -I
73*d1419d5aSNobutomo Nakanofi
74*d1419d5aSNobutomo Nakano
75a227b7f4Shs24103if [ "$rootiszfs" = 1 ] ; then
76b21718f0Sgw25295	/sbin/zfs list -rH -o mountpoint -s mountpoint -t filesystem $be | \
77a227b7f4Shs24103	    while read mountp ; do
78a227b7f4Shs24103		if [ "x$mountp" != "x" -a "$mountp" != "legacy" ] ; then
79a227b7f4Shs24103			mounted $mountp - zfs < /etc/mnttab  && continue
80a227b7f4Shs24103			/sbin/zfs mount $be$mountp
81a227b7f4Shs24103		fi
82a227b7f4Shs24103	done
83a227b7f4Shs24103fi
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
86