xref: /titanic_44/usr/src/cmd/svc/milestone/fs-usr (revision 023e71de9e5670cebc23dd51162833661d3d2d3b)
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. /lib/svc/share/smf_include.sh
31. /lib/svc/share/fs_include.sh
32
33#
34# Once root is read/write we can enable the dedicated dumpdevice if it exists
35# locally. This is an optimization as svc-dumpadm will attempt do this later.
36#
37dump_setup()
38{
39	[ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf
40
41	readswapdev $DUMPADM_DEVICE < $vfstab
42
43	#
44	# Make sure that the dump save area has been configured before
45	# proceeding. If the variable has not been defined or does not exist
46	# then bail out early. This will prevent us from configuring a
47	# dump save area before a hostname has been configured (i.e after
48	# sys-unconfig has been invoked).
49	#
50	[ -z "$DUMPADM_SAVDIR" ] && return
51
52	#
53	# If we have a dedicated dump device, then go ahead and configure it.
54	#
55	if [ "x$special" != "x$DUMPADM_DEVICE" ]; then
56		if [ -x /usr/sbin/dumpadm -a -b $DUMPADM_DEVICE ]; then
57			/usr/sbin/dumpadm -u || exit $SMF_EXIT_ERR_CONFIG
58		fi
59	fi
60}
61
62rootiszfs=0
63# get the fstype of root
64readmnttab / </etc/mnttab
65if [ "$fstype" = zfs ] ; then
66	rootiszfs=1
67	dump_setup
68fi
69
70#
71# Add physical swap.
72#
73/sbin/swapadd -1
74
75#
76# Check and remount the / (root) file system.
77# For NFS mounts, force the llock option on.
78#
79if smf_is_globalzone && [ $rootiszfs = 0 ]; then
80	readvfstab / < $vfstab
81	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
82	checkopt "llock" $mntopts
83	mntopts='remount'
84
85	[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
86	[ "$fstype" = nfs ] && mntopts="${mntopts},llock"
87
88	# if root dev is a read-only metadevice then fail
89	case $special in
90	/dev/md/dsk/*)
91		dd if=/dev/null of=$special count=0 >/dev/null 2>&1 ||
92		    exit $SMF_EXIT_ERR_FATAL
93		;;
94	esac
95
96	mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
97fi
98
99#
100# Check and remount the /usr file system (formerly mounted read-only).
101# Unless root is zfs, in which case we've already mounted /usr read-write
102#
103if [ "$rootiszfs" = 0 ] ; then
104	readvfstab /usr < $vfstab
105	if [ "$mountp" ]; then
106		if [ "$fstype" = cachefs ]; then
107			mountfs -O $mountp cachefs $mntopts $special ||
108			    exit $SMF_EXIT_ERR_FATAL
109		else
110			checkopt ro $mntopts
111			if [ "x$option" != xro ]; then
112				checkfs $fsckdev $fstype $mountp ||
113				    exit $SMF_EXIT_ERR_FATAL
114				if [ "x$mntopts" != x- ]; then
115					mntopts="remount,$mntopts"
116				else
117					mntopts="remount"
118				fi
119
120				# if usr dev is a read-only metadevice then fail
121				case $special in
122				/dev/md/dsk/*)
123					dd if=/dev/null of=$special count=0 \
124					    >/dev/null 2>&1 || exit $SMF_EXIT_ERR_FATAL
125					;;
126				esac
127
128				mountfs - /usr $fstype $mntopts - ||
129				    exit $SMF_EXIT_ERR_FATAL
130			fi
131		fi
132	fi
133fi
134
135#
136# Check and mount the /usr/platform file system.  This should only be
137# present when a SunOS 5.5 (Solaris 2.5) or greater client is being
138# administered by a SunOS 5.4 or less host.
139#
140readvfstab /usr/platform < $vfstab
141if [ "$mountp" ]; then
142	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
143	mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
144fi
145
146#
147# Mount the fd file systems if mount point exists.
148#
149readvfstab /dev/fd < $vfstab
150if [ "$mountp" -a -d /dev/fd ]; then
151	mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL
152fi
153
154exit $SMF_EXIT_OK
155