xref: /illumos-gate/usr/src/cmd/svc/milestone/fs-root (revision 4de2612967d06c4fdbf524a62556a1e8118a006f)
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, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# ident	"%Z%%M%	%I%	%E% SMI"
28#
29# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
30# All rights reserved.
31#
32
33# Make sure that the libraries essential to this stage of booting can be found.
34LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
35
36libc_mount() {
37	#
38	# If there is an optimized libc available in /usr that fits this
39	# processor, mount it on top of the base libc.
40	#
41	MOE=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'`
42	if [ -n "$MOE" ]; then
43		/usr/sbin/mount | egrep -s "^/lib/libc.so.1 on "
44		if [ $? -ne 0 ]; then
45			/usr/sbin/mount -O -F lofs $MOE /lib/libc.so.1
46		fi
47	fi
48}
49
50libc_psr_mount() {
51	LIBC_MOE_32=`/usr/bin/moe -32 '/platform/sun4v/lib/libc_psr/$HWCAP'`
52	if [ -n "$LIBC_MOE_32" ]; then
53		/usr/sbin/mount | egrep -s "^/platform/sun4v/lib/libc_psr.so.1 on "
54		if [ $? -ne 0 ]; then
55			/usr/sbin/mount -O -F lofs $LIBC_MOE_32 /platform/sun4v/lib/libc_psr.so.1
56		fi
57	fi
58
59	LIBC_MOE_64=`/usr/bin/moe -64 '/platform/sun4v/lib/sparcv9/libc_psr/$HWCAP'`
60	if [ -n "$LIBC_MOE_64" ]; then
61		/usr/sbin/mount | egrep -s "^/platform/sun4v/lib/sparcv9/libc_psr.so.1 on "
62		if [ $? -ne 0 ]; then
63			/usr/sbin/mount -O -F lofs $LIBC_MOE_64 /platform/sun4v/lib/sparcv9/libc_psr.so.1
64		fi
65	fi
66}
67
68#
69# Most of the operations in this script are only necessary in the global
70# zone but due to the way initialization scripts like this are packaged,
71# it needs to currently exist for all zones.
72#
73if [ "${_INIT_ZONENAME:=`/sbin/zonename`}" != "global" ]; then
74	libc_mount
75	exit 0
76fi
77
78. /lib/svc/share/smf_include.sh
79. /lib/svc/share/fs_include.sh
80
81#
82# Root is already mounted (by the kernel), but still needs to be
83# checked, possibly remounted and entered into mnttab. First
84# mount /usr read only if it is a separate file system. This must
85# be done first to allow utilities such as fsck and setmnt to
86# reside on /usr minimizing the space required by the root file
87# system.
88#
89readvfstab "/usr" < $vfstab
90if [ -n "$mountp" ]; then
91	if [ "$fstype" = cachefs ]; then
92		#
93		# Mount without the cache initially.  We'll enable it
94		# later at remount time.  This lets us avoid
95		# teaching the statically linked mount program about
96		# cachefs.  Here we determine the backfstype.
97		# This is not pretty, but we have no tools for parsing
98		# the option string until we get /usr mounted...
99		#
100		case "$mntopts" in
101		*backfstype=nfs*)
102			cfsbacktype=nfs
103			;;
104		*backfstype=hsfs*)
105			cfsbacktype=hsfs
106			;;
107		*)
108			msg='invalid vfstab entry for /usr'
109			echo $msg
110			echo "$SMF_FMRI:" $msg >/dev/msglog
111			cfsbacktype=nfs
112			;;
113		esac
114		mountfs - /usr $cfsbacktype ro $special ||
115		    exit $SMF_EXIT_ERR_FATAL
116	else
117		#
118		# Must use -o largefiles here to ensure the
119		# read-only mount does not fail as a result of
120		# having a large file present on /usr. This gives
121		# fsck a chance to fix up the largefiles flag
122		# before we remount /usr read-write.
123		#
124		if [ "x$mntopts" = x- ]; then
125			mntopts='ro,largefiles'
126		else
127			checkopt largefiles $mntopts
128			if [ "x$option" != xlargefiles ]; then
129				mntopts="largefiles,$mntopts"
130			fi
131
132			checkopt ro $mntopts
133			if [ "x$option" != xro ]; then
134				mntopts="ro,$mntopts"
135			fi
136
137			#
138			# Requesting logging on a read-only mount
139			# causes errors to be displayed, so remove
140			# "logging" from the list of options for now.
141			# The read-write mount performed later will
142			# specify the logging option if appropriate.
143			#
144
145			checkopt logging $mntopts
146			if [ "x$option" = xlogging ]; then
147				mntopts="$otherops"
148			fi
149		fi
150
151		mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
152	fi
153fi
154
155#
156# Also mount /boot now so that things like keymap.sh can access
157# boot properties through eeprom.  Readonly isn't required because
158# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet.
159# Also, we don't account for caching /boot as it must be on a local
160# disk.  So what's in vfstab is fine as it stands; just look to see
161# if it's there and avoid the mount if not.
162#
163readvfstab "/boot" < $vfstab
164
165if [ -n "$mountp" ]; then
166	mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
167fi
168
169#
170# Update kernel driver.conf cache with any additional driver.conf
171# files found on /usr, and device permissions from /etc/minor_perm.
172#
173/usr/sbin/devfsadm -I -P
174
175[ -f /etc/.dynamic_routing ] && /usr/bin/rm -f /etc/.dynamic_routing
176
177libc_mount
178
179libc_psr_mount
180
181exit 0
182