mpxio-upgrade revision 789c9c8f354bb5b57979032ba9e62dafc2e0b20f
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#!/sbin/sh
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# CDDL HEADER START
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# The contents of this file are subject to the terms of the
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley# Common Development and Distribution License (the "License").
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# You may not use this file except in compliance with the License.
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# or http://www.opensolaris.org/os/licensing.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# See the License for the specific language governing permissions
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# and limitations under the License.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# When distributing Covered Code, include this CDDL HEADER in each
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# If applicable, add the following below this CDDL HEADER, with the
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# fields enclosed by brackets "[]" replaced with your own identifying
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# information: Portions Copyright [yyyy] [name of copyright owner]
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# CDDL HEADER END
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# Use is subject to license terms.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley. /lib/svc/share/fs_include.sh
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley. /lib/svc/share/net_include.sh
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# Make sure that the essential libraries can be found.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleySTMSBOOTUTIL=/lib/mpxio/stmsboot_util
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleySAVEDIR=/etc/mpxio
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyBOOTDEVICES=$SAVEDIR/boot-devices
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob HalleyRECOVERFILE=$SAVEDIR/recover_instructions
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyDEVFSADM=/usr/sbin/devfsadm
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyDUMPADM=/usr/sbin/dumpadm
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyMETADEVADM=/usr/sbin/metadevadm
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyISROOTDEV=""
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halleyusrmounted=0
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyMACH=`/usr/bin/uname -p`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyECHO=/usr/bin/echo
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyCAT=/usr/bin/cat
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyCP=/usr/bin/cp
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyDF=/usr/bin/df
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyLS=/usr/bin/ls
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyRM=/usr/bin/rm
63469b434a7726ce4b2700830721ecb1d1ad61a9Bob HalleyEGREP=/usr/bin/egrep
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleySED=/usr/bin/sed
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyZPOOL=/usr/sbin/zpool
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyAWK=/usr/bin/awk
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyMOUNT=/sbin/mount
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyUMOUNT=/sbin/mount
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyEEPROM=/usr/sbin/eeprom
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleyBOOTADM=/usr/sbin/bootadm
3da473e3e96d2d054331b43519426a9b5f83cf4cBob HalleySVCADM=/usr/sbin/svcadm
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halleympxio_error()
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley{
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cecho "\nERROR: stmsboot: $1"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley #
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # display recovery instructions - the first call logs to the service
78fda31f2608ca863b1381798e680dd1cab2f209Bob Halley # log and the second call displays on the console.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley #
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley shcat $RECOVERFILE
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley shcat $RECOVERFILE >/dev/msglog 2>&1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cecho "These instructions were also logged to the file $RECOVERFILE\n"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley}
e4c76dcbd1259d52345106778c5ad4d416f8a84dBob Halley
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley#
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# root ("/") is already mounted read only by the kernel.
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley# Remount the root read-write.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halleympxio_mount_root()
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley{
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley HASZFSROOT=`$DF -g / |grep zfs`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley RVAL=""
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
e4c76dcbd1259d52345106778c5ad4d416f8a84dBob Halley # In single-user maintenance mode, we don't have a writable
e4c76dcbd1259d52345106778c5ad4d416f8a84dBob Halley # root partition, so we _cannot_ use devlinks. Therefore we
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # have to do some dancing - first mount the physical path
4756105b9c20cc9de3ac686a413a0e4d0c1bb372Michael Graff # read-write, then re-run $STMSBOOTUTIL to get the real
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # devlink mapping, and then re-mount the root slice. Of course,
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # if we all used ZFS this wouldn't be such a pain!
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley exec < $vfstab; readvfstab /
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # ZFS root environments should _not_ have an entry for /
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # in their /etc/vfstab.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ -n "$special" ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # sanity check for ZFSRoot _and_ / in /etc/vfstab
b5cad0c59eaf9d813df6bed81f86a0525d802253Bob Halley if [ -n "$HASZFSROOT" ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # ERROR - this would cause a failure later
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # so let root know about it now and provide
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # a chance to handle it before filesystem/usr
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley 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"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley exit 1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
4756105b9c20cc9de3ac686a413a0e4d0c1bb372Michael Graff ISPHYS=`echo $special |$AWK '/^\/dev\/dsk/ {print}'`;
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ -z "$ISPHYS" ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # a metadevice, either /dev/md or /dev/vx
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley new_special=$special
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley $MOUNT -o remount,rw $new_special / >/dev/msglog 2>&1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley else
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley new_special=`$STMSBOOTUTIL -m $special`
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley if [ "x$new_special" = "xNOT_MAPPED" ]; then
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # this is a bad state to be in, exit
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cecho "Error: Your root device is not mapped."
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews exit 1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews checkopt "llock" $mntopts
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley mntopts='remount'
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews [ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley RVAL=`$MOUNT -m -F $fstype -o $mntopts $new_special \
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews $mountp >/dev/msglog 2>&1`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # if we've got active-active paths to our rootvp and
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # the first path returned by $STMSBOOTUTIL is not the
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # same as the one we booted from, then we need some
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # handwaving due to restrictions in the ufs module
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley # (see the remountfs() function in
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # $SRC/uts/common/fs/ufs/ufs_vfsops.c)
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ $? -eq 0 ]; then
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # now re-run $STMSBOOTUTIL to get the real
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # mapping for this device
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews new_special=`$STMSBOOTUTIL -m $special`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # mount root for real
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews $MOUNT -o remount,rw $new_special / \
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley >/dev/msglog 2>&1
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews else
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley SLICE=`$ECHO $special | $AWK -F"s" '{print $3}'`
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews for device in `$CAT $BOOTDEVICES`; do
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley new_special="${device}s${SLICE}"
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews $MOUNT -m -F $fstype -o $mntopts \
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley $new_special $mountp >/dev/msglog 2>&1
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews if [ $? -eq 0 ]; then
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley # success, break out
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews ISROOTDEV=`$ECHO $new_special |
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley $SED -e "s,/dev/dsk/,,"`
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews break;
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley fi
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews done
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley if [ -n "$RVAL" ]; then
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews cecho "Error: Unable to remount your root device"
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley exit 1;
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews fi
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley else
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews if [ -z "$HASZFSROOT" ]; then
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley cecho "stmsboot: Error: your root slice is invalid"
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews exit 1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley else
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews cecho "stmsboot: Root is on ZFS"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley}
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley#
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews# mount /usr read only
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley#
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrewsmpxio_mount_usr()
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley{
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews exec < $vfstab; readvfstab "/usr"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley ret_val=0
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews if [ -n "$mountp" ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley new_special=`$STMSBOOTUTIL -m $special`
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "$fstype" = cachefs ]; then
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews # Mount read-only without the cache.
19de822a35b5d9594b1521b55f1c93b9b86964a5Bob Halley case "$mntopts" in
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews *backfstype=nfs*)
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cfsbacktype=nfs
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews ;;
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley *backfstype=hsfs*)
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews cfsbacktype=hsfs
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley ;;
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews *)
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cecho 'stmsboot: invalid vfstab entry for /usr'
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews cfsbacktype=nfs
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley ;;
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews esac
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # see the comment below for /dev/null
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews $MOUNT -m -F $cfsbacktype -o ro $new_special $mountp \
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley>/dev/null 2>&1
f9658c3c37f21cb6dd46b0e21ebb31443f8daf4bMark Andrews ret_val=$?
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley else
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley #
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # Must use -o largefiles here to ensure the read-only
b5cad0c59eaf9d813df6bed81f86a0525d802253Bob Halley # mount does not fail as a result of having a large
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # file present on /usr.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley #
7cc0f69d173a2b67d0fbf03a8ef8926b74739b97Bob Halley if [ "x$mntopts" = x- ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley mntopts='ro,largefiles'
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley else
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley checkopt largefiles $mntopts
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "x$option" != xlargefiles ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley mntopts="largefiles,$mntopts"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley checkopt ro $mntopts
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "x$option" != xro ]; then
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley mntopts="ro,$mntopts"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # Requesting logging on a read-only mount
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # causes errors to be displayed, so remove
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # "logging" from the list of options.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley checkopt logging $mntopts
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "x$option" = xlogging ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley mntopts="$otherops"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # In case of a manual restart of the service, mount
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # will emit messages if /usr is already mounted.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # So redirect the output to /dev/null.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley $MOUNT -m -F $fstype -o $mntopts $new_special /usr \
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley>/dev/null 2>&1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley ret_val=$?
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ $ret_val -eq 0 ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley usrmounted=1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
63469b434a7726ce4b2700830721ecb1d1ad61a9Bob Halley
63469b434a7726ce4b2700830721ecb1d1ad61a9Bob Halley return $ret_val
63469b434a7726ce4b2700830721ecb1d1ad61a9Bob Halley}
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# update system dump configuration
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halleyupdate_dumpconf()
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley{
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # Disable device-in-use checking (done in libdiskmgt).
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # Without disabling this check, the configuration of dump device
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley # would fail as the device-in-use code incorrectly concludes that
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # the device is in use and hence prevents configuration of the dump
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley # device.
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley NOINUSE_CHECK=1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley export NOINUSE_CHECK
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley DUMPISZFS=`$AWK -F"=" '/DUMPADM_DEVICE/ {print $2}' /etc/dumpadm.conf|$EGREP zvol`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "x$DUMPISZFS" = "x" ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley set -- `$DUMPADM -u 2>&1 | $EGREP 'cannot use /dev.* as dump device'`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ "x$4" != x ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley newname=`$STMSBOOTUTIL -m $4`
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if [ $? -eq 0 ]; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley if $DUMPADM -d $newname > /dev/msglog 2> /dev/console; then
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cecho "stmsboot: dump configuration \
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley has been updated."
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley else
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley mpxio_error "failed to configure \
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley the dump device.\nold \
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley dump device name: $4"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley return 1
b5cad0c59eaf9d813df6bed81f86a0525d802253Bob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
b5cad0c59eaf9d813df6bed81f86a0525d802253Bob Halley else
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley # make sure we can get to it, force zfs to load fully
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley $LS $DUMPISZFS >>/dev/null 2>&1
7cc0f69d173a2b67d0fbf03a8ef8926b74739b97Bob Halley cecho "stmsboot: dump on ZFS, no dumpadm update required"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley return 0
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley}
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley# Update bootpath for x86 here when we are enabling mpxio on root
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halleyupdate_bootpath()
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley{
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley cur_bootpath=`$STMSBOOTUTIL -b`
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley if [ $? != 0 ]; then
036f4a76ec5e5bdba8a7d2f7e77c188a8246bbacBob Halley cecho "stmsboot: ERROR! Unable to retrieve bootpath property\n"
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley exit 1
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley fi
7cc0f69d173a2b67d0fbf03a8ef8926b74739b97Bob Halley
7cc0f69d173a2b67d0fbf03a8ef8926b74739b97Bob Halley NEWBOOTPATH=""
3da473e3e96d2d054331b43519426a9b5f83cf4cBob Halley for path in $cur_bootpath; do
mapped=`$STMSBOOTUTIL -p $path`
if [ "$mapped" != "NOT_MAPPED" ]; then
if [ "x$mapped" != "x$path" ]; then
NEWBOOTPATH=`echo "$path " | \
$SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
else
NEWBOOTPATH="$NEWBOOTPATH $path"
fi
fi
done
# now strip off leading and trailing space chars
new_bootpath=`echo $NEWBOOTPATH`
$EEPROM bootpath="$new_bootpath"
cecho "stmsboot: bootpath has been updated, now regenerating boot archive"
$BOOTADM update-archive
cecho ""
}
# Now do the actual work
mpxio_main()
{
# NOTE: If the first attempt to run the service has failed due to an
# expected error, users should be able to manually rerun the service.
#
# First mount /usr read only. This must be done to run
# utilities such as fsck and devfsadm.
# In the case of a manual rerun of the service, mounting of /usr here
# fails if /usr already happens to be mounted. It is better that we
# do not mount /usr if already mounted, but there seems to be no
# apparent way to check whether /usr is mounted or not as we mount
# /usr without making an entry into /etc/mnttab. So instead of
# explicitly checking for mount failures, we just do a sanity check
# by looking for some file (in this case devfsadm) in /usr.
#
mpxio_mount_usr
if [ ! -s $DEVFSADM ]; then
mpxio_error "failed to mount the /usr filesystem."
return
fi
if mpxio_mount_root; then
# create /dev links
cecho "stmsboot: configuring devices"
$DEVFSADM
# update /etc/vfstab to reflect device name changes
$STMSBOOTUTIL -u >/dev/msglog 2>&1
if [ $? -eq 0 ]; then
$CP /etc/vfstab /etc/vfstab.old
# handle active-active paths, where the probe order
# for the hba reports a different path to what the
# boot-device variable gives us
if [ -n "$ISROOTDEV" ]; then
ROOTDEVCHK=`grep $ISROOTDEV /etc/vfstab`
if [ $? != 0 ]; then
# we got a different path for root
exec < $SAVEDIR/vfstab.new; readvfstab /
FILEDEV=`$ECHO $special | \
$SED -e"s,/dev/dsk/,,"`
$SED -e"s,$FILEDEV,$ISROOTDEV,g" < \
$SAVEDIR/vfstab.new > /etc/vfstab
fi
else
$CP $SAVEDIR/vfstab.new /etc/vfstab
fi
$RM $SAVEDIR/vfstab.new
cecho ""
cecho "stmsboot: vfstab has been updated"
if update_dumpconf; then
# update svm configuration to reflect new names
if [ -s /kernel/drv/md.conf ] && \
[ -x $METADEVADM ]; then
$METADEVADM -r >/dev/msglog 2>&1
fi
fi
if [ "x$MACH" = "xi386" ]; then
# only update bootpath here for x86
update_bootpath
fi
else
mpxio_error "failed to update /etc/vfstab."
fi
$SVCADM disable system/device/mpxio-upgrade
else
mpxio_error "failed to mount the root filesystem."
if [ $usrmounted -eq 1 ]; then
$UMOUNT /usr
fi
fi
}
mpxio_main