xref: /onnv-gate/usr/src/cmd/stmsboot/mpxio-upgrade (revision 12168:f38263bc3ed1)
10Sstevel@tonic-gate#!/sbin/sh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
62987Sramat# Common Development and Distribution License (the "License").
72987Sramat# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
220Sstevel@tonic-gate#
23*12168SJianfei.Wang@Sun.COM# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate#
250Sstevel@tonic-gate
260Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
270Sstevel@tonic-gate. /lib/svc/share/net_include.sh
280Sstevel@tonic-gate
290Sstevel@tonic-gate# Make sure that the essential libraries can be found.
300Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
310Sstevel@tonic-gateSTMSBOOTUTIL=/lib/mpxio/stmsboot_util
320Sstevel@tonic-gateSAVEDIR=/etc/mpxio
338101SJames.McPherson@Sun.COMBOOTDEVICES=$SAVEDIR/boot-devices
340Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions
350Sstevel@tonic-gateDEVFSADM=/usr/sbin/devfsadm
367498SJames.McPherson@Sun.COMDUMPADM=/usr/sbin/dumpadm
370Sstevel@tonic-gateMETADEVADM=/usr/sbin/metadevadm
388101SJames.McPherson@Sun.COMISROOTDEV=""
39*12168SJianfei.Wang@Sun.COMISROOTDEVPATH=""
400Sstevel@tonic-gateusrmounted=0
4110882SJianfei.Wang@Sun.COMUNAME=/usr/bin/uname
428101SJames.McPherson@Sun.COMECHO=/usr/bin/echo
438101SJames.McPherson@Sun.COMCAT=/usr/bin/cat
447498SJames.McPherson@Sun.COMCP=/usr/bin/cp
457498SJames.McPherson@Sun.COMDF=/usr/bin/df
467498SJames.McPherson@Sun.COMLS=/usr/bin/ls
477498SJames.McPherson@Sun.COMRM=/usr/bin/rm
484022Sjw149990EGREP=/usr/bin/egrep
494110SjmcpSED=/usr/bin/sed
507498SJames.McPherson@Sun.COMZPOOL=/usr/sbin/zpool
517498SJames.McPherson@Sun.COMAWK=/usr/bin/awk
527498SJames.McPherson@Sun.COMMOUNT=/sbin/mount
537498SJames.McPherson@Sun.COMUMOUNT=/sbin/mount
547498SJames.McPherson@Sun.COMEEPROM=/usr/sbin/eeprom
557498SJames.McPherson@Sun.COMBOOTADM=/usr/sbin/bootadm
567498SJames.McPherson@Sun.COMSVCADM=/usr/sbin/svcadm
5710882SJianfei.Wang@Sun.COMREBOOT=/usr/sbin/reboot
580Sstevel@tonic-gate
590Sstevel@tonic-gatempxio_error()
600Sstevel@tonic-gate{
610Sstevel@tonic-gate	cecho "\nERROR: stmsboot: $1"
620Sstevel@tonic-gate	#
630Sstevel@tonic-gate	# display recovery instructions - the first call logs to the service
640Sstevel@tonic-gate	# log and the second call displays on the console.
650Sstevel@tonic-gate	#
660Sstevel@tonic-gate	shcat $RECOVERFILE
670Sstevel@tonic-gate	shcat $RECOVERFILE >/dev/msglog 2>&1
680Sstevel@tonic-gate	cecho "These instructions were also logged to the file $RECOVERFILE\n"
690Sstevel@tonic-gate}
700Sstevel@tonic-gate
710Sstevel@tonic-gate#
720Sstevel@tonic-gate# root ("/") is already mounted read only by the kernel.
730Sstevel@tonic-gate# Remount the root read-write.
740Sstevel@tonic-gate#
750Sstevel@tonic-gatempxio_mount_root()
760Sstevel@tonic-gate{
777498SJames.McPherson@Sun.COM	HASZFSROOT=`$DF -g / |grep zfs`
788101SJames.McPherson@Sun.COM	RVAL=""
790Sstevel@tonic-gate
807498SJames.McPherson@Sun.COM	# In single-user maintenance mode, we don't have a writable
817498SJames.McPherson@Sun.COM	# root partition, so we _cannot_ use devlinks. Therefore we
827498SJames.McPherson@Sun.COM	# have to do some dancing - first mount the physical path
837498SJames.McPherson@Sun.COM	# read-write, then re-run $STMSBOOTUTIL to get the real
847498SJames.McPherson@Sun.COM	# devlink mapping, and then re-mount the root slice. Of course,
857498SJames.McPherson@Sun.COM	# if we all used ZFS this wouldn't be such a pain!
867498SJames.McPherson@Sun.COM	exec < $vfstab; readvfstab /
877498SJames.McPherson@Sun.COM	# ZFS root environments should _not_ have an entry for /
887498SJames.McPherson@Sun.COM	# in their /etc/vfstab.
898101SJames.McPherson@Sun.COM	if [ -n "$special" ]; then
907498SJames.McPherson@Sun.COM		# sanity check for ZFSRoot _and_ / in /etc/vfstab
918101SJames.McPherson@Sun.COM		if [ -n "$HASZFSROOT" ]; then
927498SJames.McPherson@Sun.COM			# ERROR - this would cause a failure later
937498SJames.McPherson@Sun.COM			# so let root know about it now and provide
947498SJames.McPherson@Sun.COM			# a chance to handle it before filesystem/usr
957498SJames.McPherson@Sun.COM			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"
967498SJames.McPherson@Sun.COM			exit 1
977498SJames.McPherson@Sun.COM		fi
987498SJames.McPherson@Sun.COM		ISPHYS=`echo $special |$AWK '/^\/dev\/dsk/ {print}'`;
998101SJames.McPherson@Sun.COM		if [ -z "$ISPHYS" ]; then
1008101SJames.McPherson@Sun.COM			# a metadevice, either /dev/md or /dev/vx
1018101SJames.McPherson@Sun.COM			new_special=$special
1028101SJames.McPherson@Sun.COM			$MOUNT -o remount,rw $new_special / >/dev/msglog 2>&1
1038101SJames.McPherson@Sun.COM		else
1047498SJames.McPherson@Sun.COM			new_special=`$STMSBOOTUTIL -m $special`
10510882SJianfei.Wang@Sun.COM			if [ "$new_special" = "NOT_MAPPED" ]; then
1067498SJames.McPherson@Sun.COM				# this is a bad state to be in, exit
1077498SJames.McPherson@Sun.COM				cecho "Error: Your root device is not mapped."
1087498SJames.McPherson@Sun.COM				exit 1
1097498SJames.McPherson@Sun.COM			fi
1107498SJames.McPherson@Sun.COM	       		checkopt "llock" $mntopts
1117498SJames.McPherson@Sun.COM			mntopts='remount'
1127498SJames.McPherson@Sun.COM			[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
1138101SJames.McPherson@Sun.COM			RVAL=`$MOUNT -m -F $fstype -o $mntopts $new_special \
1148101SJames.McPherson@Sun.COM				$mountp >/dev/msglog 2>&1`
1158101SJames.McPherson@Sun.COM			# if we've got active-active paths to our rootvp and
1168101SJames.McPherson@Sun.COM			# the first path returned by $STMSBOOTUTIL is not the
1178101SJames.McPherson@Sun.COM			# same as the one we booted from, then we need some
1188101SJames.McPherson@Sun.COM			# handwaving due to restrictions in the ufs module
1198101SJames.McPherson@Sun.COM			# (see the remountfs() function in
1208101SJames.McPherson@Sun.COM			# $SRC/uts/common/fs/ufs/ufs_vfsops.c)
1218101SJames.McPherson@Sun.COM			if [ $? -eq 0 ]; then
1228101SJames.McPherson@Sun.COM				# now re-run $STMSBOOTUTIL to get the real
1238101SJames.McPherson@Sun.COM				# mapping for this device
1248101SJames.McPherson@Sun.COM				new_special=`$STMSBOOTUTIL -m $special`
1258101SJames.McPherson@Sun.COM				# mount root for real
1268101SJames.McPherson@Sun.COM				$MOUNT -o remount,rw $new_special / \
1278101SJames.McPherson@Sun.COM				    >/dev/msglog 2>&1
1288101SJames.McPherson@Sun.COM			else
1298101SJames.McPherson@Sun.COM				for device in `$CAT $BOOTDEVICES`; do
130*12168SJianfei.Wang@Sun.COM					new_special="/devices${device}"
1318101SJames.McPherson@Sun.COM					$MOUNT -m -F $fstype -o $mntopts \
1328101SJames.McPherson@Sun.COM					    $new_special $mountp >/dev/msglog 2>&1
1338101SJames.McPherson@Sun.COM					if [ $? -eq 0 ]; then
1348101SJames.McPherson@Sun.COM						# success, break out
135*12168SJianfei.Wang@Sun.COM						ISROOTDEVPATH=`$ECHO $device | \
136*12168SJianfei.Wang@Sun.COM						$AWK -F":" '{print $1}'`
1378101SJames.McPherson@Sun.COM					    break;
1388101SJames.McPherson@Sun.COM					fi
1398101SJames.McPherson@Sun.COM				done
1408101SJames.McPherson@Sun.COM				if [ -n "$RVAL" ]; then
1418101SJames.McPherson@Sun.COM					cecho "Error: Unable to remount your root device"
1428101SJames.McPherson@Sun.COM					exit 1;
1438101SJames.McPherson@Sun.COM				fi
1448101SJames.McPherson@Sun.COM			fi
1457498SJames.McPherson@Sun.COM		fi
1467498SJames.McPherson@Sun.COM	else
1478101SJames.McPherson@Sun.COM		if [ -z "$HASZFSROOT" ]; then
1487498SJames.McPherson@Sun.COM			cecho "stmsboot: Error: your root slice is invalid"
1497498SJames.McPherson@Sun.COM			exit 1
1507498SJames.McPherson@Sun.COM		else
1517498SJames.McPherson@Sun.COM			cecho "stmsboot: Root is on ZFS"
1527498SJames.McPherson@Sun.COM		fi
1537498SJames.McPherson@Sun.COM	fi
1540Sstevel@tonic-gate}
1550Sstevel@tonic-gate
1560Sstevel@tonic-gate#
1570Sstevel@tonic-gate# mount /usr read only
1580Sstevel@tonic-gate#
1590Sstevel@tonic-gatempxio_mount_usr()
1600Sstevel@tonic-gate{
1610Sstevel@tonic-gate	exec < $vfstab; readvfstab "/usr"
1620Sstevel@tonic-gate	ret_val=0
1630Sstevel@tonic-gate	if [ -n "$mountp" ]; then
16411682SRaghuram.Prahlada@Sun.COM		case "$special" in
16511682SRaghuram.Prahlada@Sun.COM		/dev/md/*)
16611682SRaghuram.Prahlada@Sun.COM			new_special=$special
16711682SRaghuram.Prahlada@Sun.COM			;;
16811682SRaghuram.Prahlada@Sun.COM		/dev/vx/*)
16911682SRaghuram.Prahlada@Sun.COM			new_special=$special
17011682SRaghuram.Prahlada@Sun.COM			;;
17111682SRaghuram.Prahlada@Sun.COM		*)
17211682SRaghuram.Prahlada@Sun.COM			new_special=`$STMSBOOTUTIL -m $special`
17311682SRaghuram.Prahlada@Sun.COM			;;
17411682SRaghuram.Prahlada@Sun.COM		esac
1757498SJames.McPherson@Sun.COM
17610882SJianfei.Wang@Sun.COM		if [ "$fstype" = "cachefs" ]; then
1770Sstevel@tonic-gate			# Mount read-only without the cache.
1780Sstevel@tonic-gate			case "$mntopts" in
1790Sstevel@tonic-gate			*backfstype=nfs*)
1800Sstevel@tonic-gate				cfsbacktype=nfs
1810Sstevel@tonic-gate				;;
1820Sstevel@tonic-gate			*backfstype=hsfs*)
1830Sstevel@tonic-gate				cfsbacktype=hsfs
1840Sstevel@tonic-gate				;;
1850Sstevel@tonic-gate			*)
1860Sstevel@tonic-gate				cecho 'stmsboot: invalid vfstab entry for /usr'
1870Sstevel@tonic-gate				cfsbacktype=nfs
1880Sstevel@tonic-gate				;;
1890Sstevel@tonic-gate			esac
1900Sstevel@tonic-gate			# see the comment below for /dev/null
1917498SJames.McPherson@Sun.COM			$MOUNT -m -F $cfsbacktype -o ro $new_special $mountp \
1920Sstevel@tonic-gate>/dev/null 2>&1
1930Sstevel@tonic-gate			ret_val=$?
1940Sstevel@tonic-gate		else
1950Sstevel@tonic-gate			#
1960Sstevel@tonic-gate			# Must use -o largefiles here to ensure the read-only
1970Sstevel@tonic-gate			# mount does not fail as a result of having a large
1980Sstevel@tonic-gate			# file present on /usr.
1990Sstevel@tonic-gate			#
20010882SJianfei.Wang@Sun.COM			if [ "$mntopts" = "-" ]; then
2010Sstevel@tonic-gate				mntopts='ro,largefiles'
2020Sstevel@tonic-gate			else
2030Sstevel@tonic-gate				checkopt largefiles $mntopts
20410882SJianfei.Wang@Sun.COM				if [ "$option" != "largefiles" ]; then
2050Sstevel@tonic-gate					mntopts="largefiles,$mntopts"
2060Sstevel@tonic-gate				fi
2070Sstevel@tonic-gate
2080Sstevel@tonic-gate				checkopt ro $mntopts
20910882SJianfei.Wang@Sun.COM				if [ "$option" != "ro" ]; then
2100Sstevel@tonic-gate					mntopts="ro,$mntopts"
2110Sstevel@tonic-gate				fi
2120Sstevel@tonic-gate
2130Sstevel@tonic-gate				# Requesting logging on a read-only mount
2140Sstevel@tonic-gate				# causes errors to be displayed, so remove
2150Sstevel@tonic-gate				# "logging" from the list of options.
2160Sstevel@tonic-gate				checkopt logging $mntopts
21710882SJianfei.Wang@Sun.COM				if [ "$option" = "logging" ]; then
2180Sstevel@tonic-gate					mntopts="$otherops"
2190Sstevel@tonic-gate				fi
2200Sstevel@tonic-gate			fi
2210Sstevel@tonic-gate
2220Sstevel@tonic-gate			# In case of a manual restart of the service, mount
2230Sstevel@tonic-gate			# will emit messages if /usr is already mounted.
2240Sstevel@tonic-gate			# So redirect the output to /dev/null.
2257498SJames.McPherson@Sun.COM			$MOUNT -m -F $fstype -o $mntopts $new_special /usr \
2260Sstevel@tonic-gate>/dev/null 2>&1
2270Sstevel@tonic-gate			ret_val=$?
2280Sstevel@tonic-gate		fi
2290Sstevel@tonic-gate		if [ $ret_val -eq 0 ]; then
2300Sstevel@tonic-gate			usrmounted=1
2310Sstevel@tonic-gate		fi
2320Sstevel@tonic-gate	fi
2330Sstevel@tonic-gate
2340Sstevel@tonic-gate	return $ret_val
2350Sstevel@tonic-gate}
2360Sstevel@tonic-gate
2370Sstevel@tonic-gate# update system dump configuration
2380Sstevel@tonic-gateupdate_dumpconf()
2390Sstevel@tonic-gate{
2402987Sramat	# Disable device-in-use checking (done in libdiskmgt).
2412987Sramat	# Without disabling this check, the configuration of dump device
2422987Sramat	# would fail as the device-in-use code incorrectly concludes that
2432987Sramat	# the device is in use and hence prevents configuration of the dump
2442987Sramat	# device.
2452987Sramat	NOINUSE_CHECK=1
2462987Sramat	export NOINUSE_CHECK
2472987Sramat
2487498SJames.McPherson@Sun.COM	DUMPISZFS=`$AWK -F"=" '/DUMPADM_DEVICE/ {print $2}' /etc/dumpadm.conf|$EGREP zvol`
24910882SJianfei.Wang@Sun.COM	if [ -z "$DUMPISZFS" ]; then
2507498SJames.McPherson@Sun.COM		set -- `$DUMPADM -u 2>&1 | $EGREP 'cannot use /dev.* as dump device'`
25110882SJianfei.Wang@Sun.COM		if [ -n "$4" ]; then
2527498SJames.McPherson@Sun.COM			newname=`$STMSBOOTUTIL -m $4`
2537498SJames.McPherson@Sun.COM			if [ $? -eq 0 ]; then
2547498SJames.McPherson@Sun.COM				if $DUMPADM -d $newname > /dev/msglog 2> /dev/console; then
2557498SJames.McPherson@Sun.COM					cecho "stmsboot: dump configuration \
2567498SJames.McPherson@Sun.COM					has been updated."
2577498SJames.McPherson@Sun.COM				else
2587498SJames.McPherson@Sun.COM					mpxio_error "failed to configure \
2597498SJames.McPherson@Sun.COM					the dump device.\nold \
2607498SJames.McPherson@Sun.COM					dump device name: $4"
2617498SJames.McPherson@Sun.COM					return 1
2627498SJames.McPherson@Sun.COM				fi
2630Sstevel@tonic-gate			fi
2640Sstevel@tonic-gate		fi
2657498SJames.McPherson@Sun.COM	else
2667498SJames.McPherson@Sun.COM		# make sure we can get to it, force zfs to load fully
2677498SJames.McPherson@Sun.COM		$LS $DUMPISZFS >>/dev/null 2>&1
2687498SJames.McPherson@Sun.COM		cecho "stmsboot: dump on ZFS, no dumpadm update required"
2690Sstevel@tonic-gate	fi
2700Sstevel@tonic-gate	return 0
2710Sstevel@tonic-gate}
2720Sstevel@tonic-gate
2733385Sqh201292# Update bootpath for x86 here when we are enabling mpxio on root
2743385Sqh201292update_bootpath()
2753385Sqh201292{
2767498SJames.McPherson@Sun.COM	cur_bootpath=`$STMSBOOTUTIL -b`
27710882SJianfei.Wang@Sun.COM	if [ $? -ne 0 ]; then
2787498SJames.McPherson@Sun.COM		cecho "stmsboot: ERROR! Unable to retrieve bootpath property\n"
2797498SJames.McPherson@Sun.COM		exit 1
2807498SJames.McPherson@Sun.COM	fi
2813385Sqh201292
28210882SJianfei.Wang@Sun.COM	# Since on x64 platforms the eeprom command doesn't update the
28310882SJianfei.Wang@Sun.COM	# kernel, the file /boot/solaris/bootenv.rc and the kernel's
28410882SJianfei.Wang@Sun.COM	# bootpath variable have a good chance of differing. We do some
28510882SJianfei.Wang@Sun.COM	# extra handwaving to get the correct bootpath variable setting.
28610882SJianfei.Wang@Sun.COM
28710882SJianfei.Wang@Sun.COM	ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
28810882SJianfei.Wang@Sun.COM		$SED -e"s,',,g"`
28910882SJianfei.Wang@Sun.COM	if [ "$ONDISKVER" != "$cur_bootpath" ]; then
29010882SJianfei.Wang@Sun.COM		cur_bootpath="$ONDISKVER"
29110882SJianfei.Wang@Sun.COM	fi
29210882SJianfei.Wang@Sun.COM
2937498SJames.McPherson@Sun.COM	NEWBOOTPATH=""
2947498SJames.McPherson@Sun.COM	for path in $cur_bootpath; do
2957498SJames.McPherson@Sun.COM		mapped=`$STMSBOOTUTIL -p $path`
2967498SJames.McPherson@Sun.COM		if [ "$mapped" != "NOT_MAPPED" ]; then
29710882SJianfei.Wang@Sun.COM			if [ "$mapped" != "$path" ]; then
2987498SJames.McPherson@Sun.COM				NEWBOOTPATH=`echo "$path " | \
2997498SJames.McPherson@Sun.COM				    $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
3007498SJames.McPherson@Sun.COM			else
3017498SJames.McPherson@Sun.COM				NEWBOOTPATH="$NEWBOOTPATH $path"
3027498SJames.McPherson@Sun.COM			fi
3033385Sqh201292		fi
3047498SJames.McPherson@Sun.COM	done
3057498SJames.McPherson@Sun.COM	# now strip off leading and trailing space chars
3067498SJames.McPherson@Sun.COM	new_bootpath=`echo $NEWBOOTPATH`
3077498SJames.McPherson@Sun.COM	$EEPROM bootpath="$new_bootpath"
3089922SJianfei.Wang@Sun.COM	cecho "stmsboot: bootpath has been updated"
3097498SJames.McPherson@Sun.COM	cecho ""
3103385Sqh201292}
3113385Sqh201292
3127498SJames.McPherson@Sun.COM# Now do the actual work
3130Sstevel@tonic-gatempxio_main()
3140Sstevel@tonic-gate{
3150Sstevel@tonic-gate	# NOTE: If the first attempt to run the service has failed due to an
3160Sstevel@tonic-gate	# expected error, users should be able to manually rerun the service.
3170Sstevel@tonic-gate	#
3180Sstevel@tonic-gate	# First mount /usr read only. This must be done to run
3190Sstevel@tonic-gate	# utilities such as fsck and devfsadm.
3200Sstevel@tonic-gate	# In the case of a manual rerun of the service, mounting of /usr here
3210Sstevel@tonic-gate	# fails if /usr already happens to be mounted. It is better that we
3220Sstevel@tonic-gate	# do not mount /usr if already mounted, but there seems to be no
3230Sstevel@tonic-gate	# apparent way to check whether /usr is mounted or not as we mount
3240Sstevel@tonic-gate	# /usr without making an entry into /etc/mnttab. So instead of
3250Sstevel@tonic-gate	# explicitly checking for mount failures, we just do a sanity check
3260Sstevel@tonic-gate	# by looking for some file (in this case devfsadm) in /usr.
3270Sstevel@tonic-gate	#
3280Sstevel@tonic-gate	mpxio_mount_usr
3290Sstevel@tonic-gate	if [ ! -s $DEVFSADM ]; then
3300Sstevel@tonic-gate		mpxio_error "failed to mount the /usr filesystem."
3310Sstevel@tonic-gate		return
3320Sstevel@tonic-gate	fi
3330Sstevel@tonic-gate
3340Sstevel@tonic-gate	if mpxio_mount_root; then
3350Sstevel@tonic-gate		# create /dev links
3360Sstevel@tonic-gate		cecho "stmsboot: configuring devices"
3370Sstevel@tonic-gate		$DEVFSADM
3380Sstevel@tonic-gate
339*12168SJianfei.Wang@Sun.COM		if [ -n "$ISROOTDEVPATH" ]; then
340*12168SJianfei.Wang@Sun.COM			ISROOTDEV=`$STMSBOOTUTIL -o $ISROOTDEVPATH`
341*12168SJianfei.Wang@Sun.COM		fi
342*12168SJianfei.Wang@Sun.COM
3430Sstevel@tonic-gate		# update /etc/vfstab to reflect device name changes
3447498SJames.McPherson@Sun.COM		$STMSBOOTUTIL -u >/dev/msglog 2>&1
3457498SJames.McPherson@Sun.COM		if [ $? -eq 0 ]; then
3467498SJames.McPherson@Sun.COM			$CP /etc/vfstab /etc/vfstab.old
3478101SJames.McPherson@Sun.COM			# handle active-active paths, where the probe order
3488101SJames.McPherson@Sun.COM			# for the hba reports a different path to what the
3498101SJames.McPherson@Sun.COM			# boot-device variable gives us
3508101SJames.McPherson@Sun.COM			if [ -n "$ISROOTDEV" ]; then
3518101SJames.McPherson@Sun.COM				ROOTDEVCHK=`grep $ISROOTDEV /etc/vfstab`
35210882SJianfei.Wang@Sun.COM				if [ $? -ne 0 ]; then
3538101SJames.McPherson@Sun.COM					# we got a different path for root
3548101SJames.McPherson@Sun.COM					exec < $SAVEDIR/vfstab.new; readvfstab /
3558101SJames.McPherson@Sun.COM					FILEDEV=`$ECHO $special | \
356*12168SJianfei.Wang@Sun.COM					    $SED -e"s,/dev/dsk/,," -e"s,s[0-9]*,,"`
3578101SJames.McPherson@Sun.COM					$SED -e"s,$FILEDEV,$ISROOTDEV,g" < \
3588101SJames.McPherson@Sun.COM					    $SAVEDIR/vfstab.new > /etc/vfstab
3598101SJames.McPherson@Sun.COM				fi
3608101SJames.McPherson@Sun.COM			else
3618101SJames.McPherson@Sun.COM				$CP $SAVEDIR/vfstab.new /etc/vfstab
3628101SJames.McPherson@Sun.COM			fi
3637498SJames.McPherson@Sun.COM			$RM $SAVEDIR/vfstab.new
3647498SJames.McPherson@Sun.COM			cecho ""
3657498SJames.McPherson@Sun.COM			cecho "stmsboot: vfstab has been updated"
36610882SJianfei.Wang@Sun.COM
36711682SRaghuram.Prahlada@Sun.COM			if update_dumpconf; then
36811682SRaghuram.Prahlada@Sun.COM				# update svm configuration to reflect new names
36911682SRaghuram.Prahlada@Sun.COM				if [ -s /kernel/drv/md.conf ] && \
37011682SRaghuram.Prahlada@Sun.COM				    [ -x $METADEVADM ]; then
37111682SRaghuram.Prahlada@Sun.COM					$METADEVADM -r >/dev/msglog 2>&1
37211682SRaghuram.Prahlada@Sun.COM				fi
37311682SRaghuram.Prahlada@Sun.COM			fi
37410882SJianfei.Wang@Sun.COM
37510882SJianfei.Wang@Sun.COM			MACH=`$UNAME -p`
37610882SJianfei.Wang@Sun.COM			if [ "$MACH" = "i386" ]; then
3773385Sqh201292				# only update bootpath here for x86
3783385Sqh201292				update_bootpath
3793385Sqh201292			fi
3809922SJianfei.Wang@Sun.COM			cecho "stmsboot: now regenerating boot archive"
3819922SJianfei.Wang@Sun.COM			$BOOTADM update-archive
3820Sstevel@tonic-gate		else
3830Sstevel@tonic-gate			mpxio_error "failed to update /etc/vfstab."
3840Sstevel@tonic-gate		fi
3850Sstevel@tonic-gate
3867498SJames.McPherson@Sun.COM		$SVCADM disable system/device/mpxio-upgrade
38710882SJianfei.Wang@Sun.COM
38810882SJianfei.Wang@Sun.COM		if [ $usrmounted -eq 1 ]; then
38910882SJianfei.Wang@Sun.COM			cecho "stmsboot: rebooting the system now."
39010882SJianfei.Wang@Sun.COM			$REBOOT
39110882SJianfei.Wang@Sun.COM		fi
3920Sstevel@tonic-gate	else
3930Sstevel@tonic-gate		mpxio_error "failed to mount the root filesystem."
3940Sstevel@tonic-gate	fi
3950Sstevel@tonic-gate}
3960Sstevel@tonic-gate
3970Sstevel@tonic-gatempxio_main
398