xref: /titanic_52/usr/src/cmd/svc/milestone/fs-usr (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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 2008 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# ident	"%Z%%M%	%I%	%E% SMI"
31
32. /lib/svc/share/smf_include.sh
33. /lib/svc/share/fs_include.sh
34
35#
36# Add physical swap.
37#
38/sbin/swapadd -1
39
40#
41# Check and remount the / (root) file system.
42# For NFS mounts, force the llock option on.
43#
44if smf_is_globalzone; then
45	readvfstab / < $vfstab
46	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
47	checkopt "llock" $mntopts
48	mntopts='remount'
49
50	[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
51	[ "$fstype" = nfs ] && mntopts="${mntopts},llock"
52
53	# if root dev is a read-only metadevice then fail
54	case $special in
55	/dev/md/dsk/*)
56		dd if=/dev/null of=$special count=0 >/dev/null 2>&1 ||
57		    exit $SMF_EXIT_ERR_FATAL
58		;;
59	esac
60
61	mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
62fi
63
64#
65# Check and remount the /usr file system (formerly mounted read-only).
66#
67readvfstab /usr < $vfstab
68if [ "$mountp" ]; then
69	if [ "$fstype" = cachefs ]; then
70		mountfs -O $mountp cachefs $mntopts $special ||
71		    exit $SMF_EXIT_ERR_FATAL
72	else
73		checkopt ro $mntopts
74		if [ "x$option" != xro ]; then
75			checkfs $fsckdev $fstype $mountp ||
76			    exit $SMF_EXIT_ERR_FATAL
77			if [ "x$mntopts" != x- ]; then
78				mntopts="remount,$mntopts"
79			else
80				mntopts="remount"
81			fi
82
83			# if usr dev is a read-only metadevice then fail
84			case $special in
85			/dev/md/dsk/*)
86				dd if=/dev/null of=$special count=0 \
87				    >/dev/null 2>&1 || exit $SMF_EXIT_ERR_FATAL
88				;;
89			esac
90
91			mountfs - /usr $fstype $mntopts - ||
92			    exit $SMF_EXIT_ERR_FATAL
93		fi
94	fi
95fi
96
97#
98# Check and mount the /usr/platform file system.  This should only be
99# present when a SunOS 5.5 (Solaris 2.5) or greater client is being
100# administered by a SunOS 5.4 or less host.
101#
102readvfstab /usr/platform < $vfstab
103if [ "$mountp" ]; then
104	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
105	mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
106fi
107
108#
109# Mount the fd file systems if mount point exists.
110#
111readvfstab /dev/fd < $vfstab
112if [ "$mountp" -a -d /dev/fd ]; then
113	mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL
114fi
115
116exit $SMF_EXIT_OK
117