xref: /titanic_44/usr/src/cmd/stmsboot/mpxio-upgrade (revision 22ca5eba2a84a9612aa439c234327fda99608f01)
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
604cbdd1eSramat# Common Development and Distribution License (the "License").
704cbdd1eSramat# 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#
22*22ca5ebaSYuri Pankov
237c478bd9Sstevel@tonic-gate#
247fc66be0Sjianfei wang - Sun Microsystems - Beijing China# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
25*22ca5ebaSYuri Pankov# Copyright 2016 Nexenta Systems, Inc.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
297c478bd9Sstevel@tonic-gate. /lib/svc/share/net_include.sh
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate# Make sure that the essential libraries can be found.
327c478bd9Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
337c478bd9Sstevel@tonic-gateSTMSBOOTUTIL=/lib/mpxio/stmsboot_util
347c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio
35789c9c8fSJames C. McPhersonBOOTDEVICES=$SAVEDIR/boot-devices
367c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions
377c478bd9Sstevel@tonic-gateDEVFSADM=/usr/sbin/devfsadm
38a0261a43SJames C. McPhersonDUMPADM=/usr/sbin/dumpadm
39789c9c8fSJames C. McPhersonISROOTDEV=""
407fc66be0Sjianfei wang - Sun Microsystems - Beijing ChinaISROOTDEVPATH=""
417c478bd9Sstevel@tonic-gateusrmounted=0
42fa30e7bdSjianfei wang - Sun Microsystems - Beijing ChinaUNAME=/usr/bin/uname
43789c9c8fSJames C. McPhersonECHO=/usr/bin/echo
44789c9c8fSJames C. McPhersonCAT=/usr/bin/cat
45a0261a43SJames C. McPhersonCP=/usr/bin/cp
46a0261a43SJames C. McPhersonDF=/usr/bin/df
47a0261a43SJames C. McPhersonLS=/usr/bin/ls
48a0261a43SJames C. McPhersonRM=/usr/bin/rm
4960fffc19Sjw149990EGREP=/usr/bin/egrep
50c17d6d03SjmcpSED=/usr/bin/sed
51a0261a43SJames C. McPhersonZPOOL=/usr/sbin/zpool
52a0261a43SJames C. McPhersonAWK=/usr/bin/awk
53a0261a43SJames C. McPhersonMOUNT=/sbin/mount
54a0261a43SJames C. McPhersonUMOUNT=/sbin/mount
55a0261a43SJames C. McPhersonEEPROM=/usr/sbin/eeprom
56a0261a43SJames C. McPhersonBOOTADM=/usr/sbin/bootadm
57a0261a43SJames C. McPhersonSVCADM=/usr/sbin/svcadm
58fa30e7bdSjianfei wang - Sun Microsystems - Beijing ChinaREBOOT=/usr/sbin/reboot
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gatempxio_error()
617c478bd9Sstevel@tonic-gate{
627c478bd9Sstevel@tonic-gate	cecho "\nERROR: stmsboot: $1"
637c478bd9Sstevel@tonic-gate	#
647c478bd9Sstevel@tonic-gate	# display recovery instructions - the first call logs to the service
657c478bd9Sstevel@tonic-gate	# log and the second call displays on the console.
667c478bd9Sstevel@tonic-gate	#
677c478bd9Sstevel@tonic-gate	shcat $RECOVERFILE
687c478bd9Sstevel@tonic-gate	shcat $RECOVERFILE >/dev/msglog 2>&1
697c478bd9Sstevel@tonic-gate	cecho "These instructions were also logged to the file $RECOVERFILE\n"
707c478bd9Sstevel@tonic-gate}
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate#
737c478bd9Sstevel@tonic-gate# root ("/") is already mounted read only by the kernel.
747c478bd9Sstevel@tonic-gate# Remount the root read-write.
757c478bd9Sstevel@tonic-gate#
767c478bd9Sstevel@tonic-gatempxio_mount_root()
777c478bd9Sstevel@tonic-gate{
78a0261a43SJames C. McPherson	HASZFSROOT=`$DF -g / |grep zfs`
79789c9c8fSJames C. McPherson	RVAL=""
807c478bd9Sstevel@tonic-gate
81a0261a43SJames C. McPherson	# In single-user maintenance mode, we don't have a writable
82a0261a43SJames C. McPherson	# root partition, so we _cannot_ use devlinks. Therefore we
83a0261a43SJames C. McPherson	# have to do some dancing - first mount the physical path
84a0261a43SJames C. McPherson	# read-write, then re-run $STMSBOOTUTIL to get the real
85a0261a43SJames C. McPherson	# devlink mapping, and then re-mount the root slice. Of course,
86a0261a43SJames C. McPherson	# if we all used ZFS this wouldn't be such a pain!
87a0261a43SJames C. McPherson	exec < $vfstab; readvfstab /
88a0261a43SJames C. McPherson	# ZFS root environments should _not_ have an entry for /
89a0261a43SJames C. McPherson	# in their /etc/vfstab.
90789c9c8fSJames C. McPherson	if [ -n "$special" ]; then
91a0261a43SJames C. McPherson		# sanity check for ZFSRoot _and_ / in /etc/vfstab
92789c9c8fSJames C. McPherson		if [ -n "$HASZFSROOT" ]; then
93a0261a43SJames C. McPherson			# ERROR - this would cause a failure later
94a0261a43SJames C. McPherson			# so let root know about it now and provide
95a0261a43SJames C. McPherson			# a chance to handle it before filesystem/usr
96a0261a43SJames C. McPherson			cecho "stmsboot: System has ZFS Root *and* an entry for / in /etc/vfstab\nstmsboot: Please remove the / entry from /etc/vfstab and then run\n# svcadm clear mpxio-upgrade"
97a0261a43SJames C. McPherson			exit 1
98a0261a43SJames C. McPherson		fi
99a0261a43SJames C. McPherson		ISPHYS=`echo $special |$AWK '/^\/dev\/dsk/ {print}'`;
100789c9c8fSJames C. McPherson		if [ -z "$ISPHYS" ]; then
101*22ca5ebaSYuri Pankov			# a metadevice, /dev/vx
102789c9c8fSJames C. McPherson			new_special=$special
103789c9c8fSJames C. McPherson			$MOUNT -o remount,rw $new_special / >/dev/msglog 2>&1
104789c9c8fSJames C. McPherson		else
105a0261a43SJames C. McPherson			new_special=`$STMSBOOTUTIL -m $special`
106fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$new_special" = "NOT_MAPPED" ]; then
107a0261a43SJames C. McPherson				# this is a bad state to be in, exit
108a0261a43SJames C. McPherson				cecho "Error: Your root device is not mapped."
109a0261a43SJames C. McPherson				exit 1
110a0261a43SJames C. McPherson			fi
1117c478bd9Sstevel@tonic-gate	       		checkopt "llock" $mntopts
1127c478bd9Sstevel@tonic-gate			mntopts='remount'
1137c478bd9Sstevel@tonic-gate			[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
114789c9c8fSJames C. McPherson			RVAL=`$MOUNT -m -F $fstype -o $mntopts $new_special \
115789c9c8fSJames C. McPherson				$mountp >/dev/msglog 2>&1`
116789c9c8fSJames C. McPherson			# if we've got active-active paths to our rootvp and
117789c9c8fSJames C. McPherson			# the first path returned by $STMSBOOTUTIL is not the
118789c9c8fSJames C. McPherson			# same as the one we booted from, then we need some
119789c9c8fSJames C. McPherson			# handwaving due to restrictions in the ufs module
120789c9c8fSJames C. McPherson			# (see the remountfs() function in
121789c9c8fSJames C. McPherson			# $SRC/uts/common/fs/ufs/ufs_vfsops.c)
122789c9c8fSJames C. McPherson			if [ $? -eq 0 ]; then
123789c9c8fSJames C. McPherson				# now re-run $STMSBOOTUTIL to get the real
124789c9c8fSJames C. McPherson				# mapping for this device
125a0261a43SJames C. McPherson				new_special=`$STMSBOOTUTIL -m $special`
126a0261a43SJames C. McPherson				# mount root for real
127789c9c8fSJames C. McPherson				$MOUNT -o remount,rw $new_special / \
128789c9c8fSJames C. McPherson				    >/dev/msglog 2>&1
129a0261a43SJames C. McPherson			else
130789c9c8fSJames C. McPherson				for device in `$CAT $BOOTDEVICES`; do
1317fc66be0Sjianfei wang - Sun Microsystems - Beijing China					new_special="/devices${device}"
132789c9c8fSJames C. McPherson					$MOUNT -m -F $fstype -o $mntopts \
133789c9c8fSJames C. McPherson					    $new_special $mountp >/dev/msglog 2>&1
134789c9c8fSJames C. McPherson					if [ $? -eq 0 ]; then
135789c9c8fSJames C. McPherson						# success, break out
1367fc66be0Sjianfei wang - Sun Microsystems - Beijing China						ISROOTDEVPATH=`$ECHO $device | \
1377fc66be0Sjianfei wang - Sun Microsystems - Beijing China						$AWK -F":" '{print $1}'`
138789c9c8fSJames C. McPherson					    break;
139789c9c8fSJames C. McPherson					fi
140789c9c8fSJames C. McPherson				done
141789c9c8fSJames C. McPherson				if [ -n "$RVAL" ]; then
142789c9c8fSJames C. McPherson					cecho "Error: Unable to remount your root device"
143789c9c8fSJames C. McPherson					exit 1;
144789c9c8fSJames C. McPherson				fi
145789c9c8fSJames C. McPherson			fi
146789c9c8fSJames C. McPherson		fi
147789c9c8fSJames C. McPherson	else
148789c9c8fSJames C. McPherson		if [ -z "$HASZFSROOT" ]; then
149a0261a43SJames C. McPherson			cecho "stmsboot: Error: your root slice is invalid"
150a0261a43SJames C. McPherson			exit 1
151a0261a43SJames C. McPherson		else
152a0261a43SJames C. McPherson			cecho "stmsboot: Root is on ZFS"
153a0261a43SJames C. McPherson		fi
154a0261a43SJames C. McPherson	fi
1557c478bd9Sstevel@tonic-gate}
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gate#
1587c478bd9Sstevel@tonic-gate# mount /usr read only
1597c478bd9Sstevel@tonic-gate#
1607c478bd9Sstevel@tonic-gatempxio_mount_usr()
1617c478bd9Sstevel@tonic-gate{
1627c478bd9Sstevel@tonic-gate	exec < $vfstab; readvfstab "/usr"
1637c478bd9Sstevel@tonic-gate	ret_val=0
1647c478bd9Sstevel@tonic-gate	if [ -n "$mountp" ]; then
165c0e23f97SRaghuram Prahlada		case "$special" in
166c0e23f97SRaghuram Prahlada		/dev/vx/*)
167c0e23f97SRaghuram Prahlada			new_special=$special
168c0e23f97SRaghuram Prahlada			;;
169c0e23f97SRaghuram Prahlada		*)
170a0261a43SJames C. McPherson			new_special=`$STMSBOOTUTIL -m $special`
171c0e23f97SRaghuram Prahlada			;;
172c0e23f97SRaghuram Prahlada		esac
173a0261a43SJames C. McPherson
174fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ "$fstype" = "cachefs" ]; then
1757c478bd9Sstevel@tonic-gate			# Mount read-only without the cache.
1767c478bd9Sstevel@tonic-gate			case "$mntopts" in
1777c478bd9Sstevel@tonic-gate			*backfstype=nfs*)
1787c478bd9Sstevel@tonic-gate				cfsbacktype=nfs
1797c478bd9Sstevel@tonic-gate				;;
1807c478bd9Sstevel@tonic-gate			*backfstype=hsfs*)
1817c478bd9Sstevel@tonic-gate				cfsbacktype=hsfs
1827c478bd9Sstevel@tonic-gate				;;
1837c478bd9Sstevel@tonic-gate			*)
1847c478bd9Sstevel@tonic-gate				cecho 'stmsboot: invalid vfstab entry for /usr'
1857c478bd9Sstevel@tonic-gate				cfsbacktype=nfs
1867c478bd9Sstevel@tonic-gate				;;
1877c478bd9Sstevel@tonic-gate			esac
1887c478bd9Sstevel@tonic-gate			# see the comment below for /dev/null
189a0261a43SJames C. McPherson			$MOUNT -m -F $cfsbacktype -o ro $new_special $mountp \
1907c478bd9Sstevel@tonic-gate>/dev/null 2>&1
1917c478bd9Sstevel@tonic-gate			ret_val=$?
1927c478bd9Sstevel@tonic-gate		else
1937c478bd9Sstevel@tonic-gate			#
1947c478bd9Sstevel@tonic-gate			# Must use -o largefiles here to ensure the read-only
1957c478bd9Sstevel@tonic-gate			# mount does not fail as a result of having a large
1967c478bd9Sstevel@tonic-gate			# file present on /usr.
1977c478bd9Sstevel@tonic-gate			#
198fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$mntopts" = "-" ]; then
1997c478bd9Sstevel@tonic-gate				mntopts='ro,largefiles'
2007c478bd9Sstevel@tonic-gate			else
2017c478bd9Sstevel@tonic-gate				checkopt largefiles $mntopts
202fa30e7bdSjianfei wang - Sun Microsystems - Beijing China				if [ "$option" != "largefiles" ]; then
2037c478bd9Sstevel@tonic-gate					mntopts="largefiles,$mntopts"
2047c478bd9Sstevel@tonic-gate				fi
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate				checkopt ro $mntopts
207fa30e7bdSjianfei wang - Sun Microsystems - Beijing China				if [ "$option" != "ro" ]; then
2087c478bd9Sstevel@tonic-gate					mntopts="ro,$mntopts"
2097c478bd9Sstevel@tonic-gate				fi
2107c478bd9Sstevel@tonic-gate
2117c478bd9Sstevel@tonic-gate				# Requesting logging on a read-only mount
2127c478bd9Sstevel@tonic-gate				# causes errors to be displayed, so remove
2137c478bd9Sstevel@tonic-gate				# "logging" from the list of options.
2147c478bd9Sstevel@tonic-gate				checkopt logging $mntopts
215fa30e7bdSjianfei wang - Sun Microsystems - Beijing China				if [ "$option" = "logging" ]; then
2167c478bd9Sstevel@tonic-gate					mntopts="$otherops"
2177c478bd9Sstevel@tonic-gate				fi
2187c478bd9Sstevel@tonic-gate			fi
2197c478bd9Sstevel@tonic-gate
2207c478bd9Sstevel@tonic-gate			# In case of a manual restart of the service, mount
2217c478bd9Sstevel@tonic-gate			# will emit messages if /usr is already mounted.
2227c478bd9Sstevel@tonic-gate			# So redirect the output to /dev/null.
223a0261a43SJames C. McPherson			$MOUNT -m -F $fstype -o $mntopts $new_special /usr \
2247c478bd9Sstevel@tonic-gate>/dev/null 2>&1
2257c478bd9Sstevel@tonic-gate			ret_val=$?
2267c478bd9Sstevel@tonic-gate		fi
2277c478bd9Sstevel@tonic-gate		if [ $ret_val -eq 0 ]; then
2287c478bd9Sstevel@tonic-gate			usrmounted=1
2297c478bd9Sstevel@tonic-gate		fi
2307c478bd9Sstevel@tonic-gate	fi
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate	return $ret_val
2337c478bd9Sstevel@tonic-gate}
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate# update system dump configuration
2367c478bd9Sstevel@tonic-gateupdate_dumpconf()
2377c478bd9Sstevel@tonic-gate{
23804cbdd1eSramat	# Disable device-in-use checking (done in libdiskmgt).
23904cbdd1eSramat	# Without disabling this check, the configuration of dump device
24004cbdd1eSramat	# would fail as the device-in-use code incorrectly concludes that
24104cbdd1eSramat	# the device is in use and hence prevents configuration of the dump
24204cbdd1eSramat	# device.
24304cbdd1eSramat	NOINUSE_CHECK=1
24404cbdd1eSramat	export NOINUSE_CHECK
24504cbdd1eSramat
246a0261a43SJames C. McPherson	DUMPISZFS=`$AWK -F"=" '/DUMPADM_DEVICE/ {print $2}' /etc/dumpadm.conf|$EGREP zvol`
247fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ -z "$DUMPISZFS" ]; then
248a0261a43SJames C. McPherson		set -- `$DUMPADM -u 2>&1 | $EGREP 'cannot use /dev.* as dump device'`
249fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ -n "$4" ]; then
250a0261a43SJames C. McPherson			newname=`$STMSBOOTUTIL -m $4`
2517c478bd9Sstevel@tonic-gate			if [ $? -eq 0 ]; then
252a0261a43SJames C. McPherson				if $DUMPADM -d $newname > /dev/msglog 2> /dev/console; then
253a0261a43SJames C. McPherson					cecho "stmsboot: dump configuration \
254a0261a43SJames C. McPherson					has been updated."
2557c478bd9Sstevel@tonic-gate				else
256a0261a43SJames C. McPherson					mpxio_error "failed to configure \
257a0261a43SJames C. McPherson					the dump device.\nold \
258a0261a43SJames C. McPherson					dump device name: $4"
2597c478bd9Sstevel@tonic-gate					return 1
2607c478bd9Sstevel@tonic-gate				fi
2617c478bd9Sstevel@tonic-gate			fi
2627c478bd9Sstevel@tonic-gate		fi
263a0261a43SJames C. McPherson	else
264a0261a43SJames C. McPherson		# make sure we can get to it, force zfs to load fully
265a0261a43SJames C. McPherson		$LS $DUMPISZFS >>/dev/null 2>&1
266a0261a43SJames C. McPherson		cecho "stmsboot: dump on ZFS, no dumpadm update required"
267a0261a43SJames C. McPherson	fi
2687c478bd9Sstevel@tonic-gate	return 0
2697c478bd9Sstevel@tonic-gate}
2707c478bd9Sstevel@tonic-gate
2715a4c37c9Sqh201292# Update bootpath for x86 here when we are enabling mpxio on root
2725a4c37c9Sqh201292update_bootpath()
2735a4c37c9Sqh201292{
274a0261a43SJames C. McPherson	cur_bootpath=`$STMSBOOTUTIL -b`
275fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ $? -ne 0 ]; then
276a0261a43SJames C. McPherson		cecho "stmsboot: ERROR! Unable to retrieve bootpath property\n"
277a0261a43SJames C. McPherson		exit 1
278a0261a43SJames C. McPherson	fi
2795a4c37c9Sqh201292
280fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	# Since on x64 platforms the eeprom command doesn't update the
281fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	# kernel, the file /boot/solaris/bootenv.rc and the kernel's
282fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	# bootpath variable have a good chance of differing. We do some
283fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	# extra handwaving to get the correct bootpath variable setting.
284fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
285fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
286fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		$SED -e"s,',,g"`
287fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	if [ "$ONDISKVER" != "$cur_bootpath" ]; then
288fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		cur_bootpath="$ONDISKVER"
289fa30e7bdSjianfei wang - Sun Microsystems - Beijing China	fi
290fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
291a0261a43SJames C. McPherson	NEWBOOTPATH=""
292a0261a43SJames C. McPherson	for path in $cur_bootpath; do
293a0261a43SJames C. McPherson		mapped=`$STMSBOOTUTIL -p $path`
294a0261a43SJames C. McPherson		if [ "$mapped" != "NOT_MAPPED" ]; then
295fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$mapped" != "$path" ]; then
296a0261a43SJames C. McPherson				NEWBOOTPATH=`echo "$path " | \
297a0261a43SJames C. McPherson				    $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
298a0261a43SJames C. McPherson			else
299a0261a43SJames C. McPherson				NEWBOOTPATH="$NEWBOOTPATH $path"
3005a4c37c9Sqh201292			fi
3015a4c37c9Sqh201292		fi
302a0261a43SJames C. McPherson	done
303a0261a43SJames C. McPherson	# now strip off leading and trailing space chars
304a0261a43SJames C. McPherson	new_bootpath=`echo $NEWBOOTPATH`
305a0261a43SJames C. McPherson	$EEPROM bootpath="$new_bootpath"
306e6f838bcSjianfei wang - Sun Microsystems - Beijing China	cecho "stmsboot: bootpath has been updated"
307a0261a43SJames C. McPherson	cecho ""
3085a4c37c9Sqh201292}
3095a4c37c9Sqh201292
310a0261a43SJames C. McPherson# Now do the actual work
3117c478bd9Sstevel@tonic-gatempxio_main()
3127c478bd9Sstevel@tonic-gate{
3137c478bd9Sstevel@tonic-gate	# NOTE: If the first attempt to run the service has failed due to an
3147c478bd9Sstevel@tonic-gate	# expected error, users should be able to manually rerun the service.
3157c478bd9Sstevel@tonic-gate	#
3167c478bd9Sstevel@tonic-gate	# First mount /usr read only. This must be done to run
3177c478bd9Sstevel@tonic-gate	# utilities such as fsck and devfsadm.
3187c478bd9Sstevel@tonic-gate	# In the case of a manual rerun of the service, mounting of /usr here
3197c478bd9Sstevel@tonic-gate	# fails if /usr already happens to be mounted. It is better that we
3207c478bd9Sstevel@tonic-gate	# do not mount /usr if already mounted, but there seems to be no
3217c478bd9Sstevel@tonic-gate	# apparent way to check whether /usr is mounted or not as we mount
3227c478bd9Sstevel@tonic-gate	# /usr without making an entry into /etc/mnttab. So instead of
3237c478bd9Sstevel@tonic-gate	# explicitly checking for mount failures, we just do a sanity check
3247c478bd9Sstevel@tonic-gate	# by looking for some file (in this case devfsadm) in /usr.
3257c478bd9Sstevel@tonic-gate	#
3267c478bd9Sstevel@tonic-gate	mpxio_mount_usr
3277c478bd9Sstevel@tonic-gate	if [ ! -s $DEVFSADM ]; then
3287c478bd9Sstevel@tonic-gate		mpxio_error "failed to mount the /usr filesystem."
3297c478bd9Sstevel@tonic-gate		return
3307c478bd9Sstevel@tonic-gate	fi
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate	if mpxio_mount_root; then
3337c478bd9Sstevel@tonic-gate		# create /dev links
3347c478bd9Sstevel@tonic-gate		cecho "stmsboot: configuring devices"
3357c478bd9Sstevel@tonic-gate		$DEVFSADM
3367c478bd9Sstevel@tonic-gate
3377fc66be0Sjianfei wang - Sun Microsystems - Beijing China		if [ -n "$ISROOTDEVPATH" ]; then
3387fc66be0Sjianfei wang - Sun Microsystems - Beijing China			ISROOTDEV=`$STMSBOOTUTIL -o $ISROOTDEVPATH`
3397fc66be0Sjianfei wang - Sun Microsystems - Beijing China		fi
3407fc66be0Sjianfei wang - Sun Microsystems - Beijing China
3417c478bd9Sstevel@tonic-gate		# update /etc/vfstab to reflect device name changes
342a0261a43SJames C. McPherson		$STMSBOOTUTIL -u >/dev/msglog 2>&1
343a0261a43SJames C. McPherson		if [ $? -eq 0 ]; then
344a0261a43SJames C. McPherson			$CP /etc/vfstab /etc/vfstab.old
345789c9c8fSJames C. McPherson			# handle active-active paths, where the probe order
346789c9c8fSJames C. McPherson			# for the hba reports a different path to what the
347789c9c8fSJames C. McPherson			# boot-device variable gives us
348789c9c8fSJames C. McPherson			if [ -n "$ISROOTDEV" ]; then
349789c9c8fSJames C. McPherson				ROOTDEVCHK=`grep $ISROOTDEV /etc/vfstab`
350fa30e7bdSjianfei wang - Sun Microsystems - Beijing China				if [ $? -ne 0 ]; then
351789c9c8fSJames C. McPherson					# we got a different path for root
352789c9c8fSJames C. McPherson					exec < $SAVEDIR/vfstab.new; readvfstab /
353789c9c8fSJames C. McPherson					FILEDEV=`$ECHO $special | \
3547fc66be0Sjianfei wang - Sun Microsystems - Beijing China					    $SED -e"s,/dev/dsk/,," -e"s,s[0-9]*,,"`
355789c9c8fSJames C. McPherson					$SED -e"s,$FILEDEV,$ISROOTDEV,g" < \
356789c9c8fSJames C. McPherson					    $SAVEDIR/vfstab.new > /etc/vfstab
357789c9c8fSJames C. McPherson				fi
358789c9c8fSJames C. McPherson			else
359a0261a43SJames C. McPherson				$CP $SAVEDIR/vfstab.new /etc/vfstab
360789c9c8fSJames C. McPherson			fi
361a0261a43SJames C. McPherson			$RM $SAVEDIR/vfstab.new
362a0261a43SJames C. McPherson			cecho ""
363a0261a43SJames C. McPherson			cecho "stmsboot: vfstab has been updated"
364fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
365*22ca5ebaSYuri Pankov			update_dumpconf
366fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
367fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			MACH=`$UNAME -p`
368fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			if [ "$MACH" = "i386" ]; then
3695a4c37c9Sqh201292				# only update bootpath here for x86
3705a4c37c9Sqh201292				update_bootpath
3715a4c37c9Sqh201292			fi
372e6f838bcSjianfei wang - Sun Microsystems - Beijing China			cecho "stmsboot: now regenerating boot archive"
373e6f838bcSjianfei wang - Sun Microsystems - Beijing China			$BOOTADM update-archive
3747c478bd9Sstevel@tonic-gate		else
3757c478bd9Sstevel@tonic-gate			mpxio_error "failed to update /etc/vfstab."
3767c478bd9Sstevel@tonic-gate		fi
3777c478bd9Sstevel@tonic-gate
378a0261a43SJames C. McPherson		$SVCADM disable system/device/mpxio-upgrade
379fa30e7bdSjianfei wang - Sun Microsystems - Beijing China
380fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		if [ $usrmounted -eq 1 ]; then
381fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			cecho "stmsboot: rebooting the system now."
382fa30e7bdSjianfei wang - Sun Microsystems - Beijing China			$REBOOT
383fa30e7bdSjianfei wang - Sun Microsystems - Beijing China		fi
3847c478bd9Sstevel@tonic-gate	else
3857c478bd9Sstevel@tonic-gate		mpxio_error "failed to mount the root filesystem."
3867c478bd9Sstevel@tonic-gate	fi
3877c478bd9Sstevel@tonic-gate}
3887c478bd9Sstevel@tonic-gate
3897c478bd9Sstevel@tonic-gatempxio_main
390