xref: /illumos-gate/usr/src/cmd/svc/milestone/fs-usr (revision 6927f468b0af7710df000f6b16f6ee413e1e3007)
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*6927f468Sdp# Common Development and Distribution License (the "License").
7*6927f468Sdp# 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*6927f468Sdp# Copyright 2006 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#
367c478bd9Sstevel@tonic-gate# Add physical swap.
377c478bd9Sstevel@tonic-gate#
387c478bd9Sstevel@tonic-gate/sbin/swapadd -1
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate#
417c478bd9Sstevel@tonic-gate# Check and remount the / (root) file system.
427c478bd9Sstevel@tonic-gate# For NFS mounts, force the llock option on.
437c478bd9Sstevel@tonic-gate#
44*6927f468Sdpif smf_is_globalzone; then
457c478bd9Sstevel@tonic-gate	readvfstab / < $vfstab
467c478bd9Sstevel@tonic-gate	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
477c478bd9Sstevel@tonic-gate	checkopt "llock" $mntopts
487c478bd9Sstevel@tonic-gate	mntopts='remount'
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate	[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
517c478bd9Sstevel@tonic-gate	[ "$fstype" = nfs ] && mntopts="${mntopts},llock"
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate	# if root dev is a read-only metadevice then fail
547c478bd9Sstevel@tonic-gate	case $special in
557c478bd9Sstevel@tonic-gate	/dev/md/dsk/*)
567c478bd9Sstevel@tonic-gate		dd if=/dev/null of=$special count=0 >/dev/null 2>&1 ||
577c478bd9Sstevel@tonic-gate		    exit $SMF_EXIT_ERR_FATAL
587c478bd9Sstevel@tonic-gate		;;
597c478bd9Sstevel@tonic-gate	esac
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate	mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
627c478bd9Sstevel@tonic-gatefi
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate#
657c478bd9Sstevel@tonic-gate# Check and remount the /usr file system (formerly mounted read-only).
667c478bd9Sstevel@tonic-gate#
677c478bd9Sstevel@tonic-gatereadvfstab /usr < $vfstab
687c478bd9Sstevel@tonic-gateif [ "$mountp" ]; then
697c478bd9Sstevel@tonic-gate	if [ "$fstype" = cachefs ]; then
707c478bd9Sstevel@tonic-gate		mountfs -O $mountp cachefs $mntopts $special ||
717c478bd9Sstevel@tonic-gate		    exit $SMF_EXIT_ERR_FATAL
727c478bd9Sstevel@tonic-gate	else
737c478bd9Sstevel@tonic-gate		checkopt ro $mntopts
747c478bd9Sstevel@tonic-gate		if [ "x$option" != xro ]; then
757c478bd9Sstevel@tonic-gate			checkfs $fsckdev $fstype $mountp ||
767c478bd9Sstevel@tonic-gate			    exit $SMF_EXIT_ERR_FATAL
777c478bd9Sstevel@tonic-gate			if [ "x$mntopts" != x- ]; then
787c478bd9Sstevel@tonic-gate				mntopts="remount,$mntopts"
797c478bd9Sstevel@tonic-gate			else
807c478bd9Sstevel@tonic-gate				mntopts="remount"
817c478bd9Sstevel@tonic-gate			fi
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate			# if usr dev is a read-only metadevice then fail
847c478bd9Sstevel@tonic-gate			case $special in
857c478bd9Sstevel@tonic-gate			/dev/md/dsk/*)
867c478bd9Sstevel@tonic-gate				dd if=/dev/null of=$special count=0 \
877c478bd9Sstevel@tonic-gate				    >/dev/null 2>&1 || exit $SMF_EXIT_ERR_FATAL
887c478bd9Sstevel@tonic-gate				;;
897c478bd9Sstevel@tonic-gate			esac
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate			mountfs - /usr $fstype $mntopts - ||
927c478bd9Sstevel@tonic-gate			    exit $SMF_EXIT_ERR_FATAL
937c478bd9Sstevel@tonic-gate		fi
947c478bd9Sstevel@tonic-gate	fi
957c478bd9Sstevel@tonic-gatefi
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate#
987c478bd9Sstevel@tonic-gate# Check and mount the /usr/platform file system.  This should only be
997c478bd9Sstevel@tonic-gate# present when a SunOS 5.5 (Solaris 2.5) or greater client is being
1007c478bd9Sstevel@tonic-gate# administered by a SunOS 5.4 or less host.
1017c478bd9Sstevel@tonic-gate#
1027c478bd9Sstevel@tonic-gatereadvfstab /usr/platform < $vfstab
1037c478bd9Sstevel@tonic-gateif [ "$mountp" ]; then
1047c478bd9Sstevel@tonic-gate	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
1057c478bd9Sstevel@tonic-gate	mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
1067c478bd9Sstevel@tonic-gatefi
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gate#
1097c478bd9Sstevel@tonic-gate# Mount the fd file systems if mount point exists.
1107c478bd9Sstevel@tonic-gate#
1117c478bd9Sstevel@tonic-gatereadvfstab /dev/fd < $vfstab
1127c478bd9Sstevel@tonic-gateif [ "$mountp" -a -d /dev/fd ]; then
1137c478bd9Sstevel@tonic-gate	mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL
1147c478bd9Sstevel@tonic-gatefi
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate# Clean up existing /etc/dfs/sharetab as there are no shared file systems
1177c478bd9Sstevel@tonic-gate# at this point. This also takes care of a corrupt sharetab.
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gateif [ -f /etc/dfs/sharetab ]; then
1207c478bd9Sstevel@tonic-gate	> /etc/dfs/sharetab
1217c478bd9Sstevel@tonic-gatefi
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
124