mpxio-upgrade revision bd93c05dbd9b8f1e8d2edf48c777bc881f927608
c80e152862cc3e3207dc837fde7116bd4c0e4b9dTinderbox User# CDDL HEADER START
8d1b3ceb4d491ce32572f1702f37ed585eede993Evan Hunt# The contents of this file are subject to the terms of the
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# Common Development and Distribution License (the "License").
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# You may not use this file except in compliance with the License.
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# See the License for the specific language governing permissions
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# and limitations under the License.
7ec97ae74e42ec21b354fd2d1366313b41d947d6Evan Hunt# When distributing Covered Code, include this CDDL HEADER in each
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# If applicable, add the following below this CDDL HEADER, with the
002f1373374a0b72fc0329baa682917929bef168Tony Finch# fields enclosed by brackets "[]" replaced with your own identifying
002f1373374a0b72fc0329baa682917929bef168Tony Finch# information: Portions Copyright [yyyy] [name of copyright owner]
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# CDDL HEADER END
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt# Make sure that the essential libraries can be found.
fd82c70695888c134287b8018296028c252d100eMukund Sivaraman # display recovery instructions - the first call logs to the service
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews # log and the second call displays on the console.
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews cecho "These instructions were also logged to the file $RECOVERFILE\n"
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt# root ("/") is already mounted read only by the kernel.
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt# Remount the root read-write.
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień # In single-user maintenance mode, we don't have a writable
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień # root partition, so we _cannot_ use devlinks. Therefore we
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień # have to do some dancing - first mount the physical path
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień # read-write, then re-run $STMSBOOTUTIL to get the real
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman # devlink mapping, and then re-mount the root slice. Of course,
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman # if we all used ZFS this wouldn't be such a pain!
7e1a62eea2e4ba9d6c3fc718e679b965fa514f69Mark Andrews # ZFS root environments should _not_ have an entry for /
afefd754734f896bf3e0590177fff83e7cdfdf35Mark Andrews # sanity check for ZFSRoot _and_ / in /etc/vfstab
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt 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"
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt ISPHYS=`echo $special |$AWK '/^\/dev\/dsk/ {print}'`;
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt $MOUNT -o remount,rw $new_special / >/dev/msglog 2>&1
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews [ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews RVAL=`$MOUNT -m -F $fstype -o $mntopts $new_special \
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews # if we've got active-active paths to our rootvp and
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews # the first path returned by $STMSBOOTUTIL is not the
cb616c6d5c2ece1fac37fa6e0bca2b53d4043098Mark Andrews # same as the one we booted from, then we need some
cb616c6d5c2ece1fac37fa6e0bca2b53d4043098Mark Andrews # handwaving due to restrictions in the ufs module
c0a2210466dec0cc81ebf2ffbe21693b57b9c29cMark Andrews if [ $? -eq 0 ]; then
1848d38f441ebf70ab21f6151bc3487a92d25b63Mark Andrews if [ $? -eq 0 ]; then
0d6328ce5f6b799f8e7c6cbbb3b965cf29bfb7baMark Andrews cecho "Error: Unable to remount your root device"
677f507de7c546c187c1505c48bc7b440545485cMark Andrews cecho "stmsboot: Error: your root slice is invalid"
677f507de7c546c187c1505c48bc7b440545485cMark Andrews# mount /usr read only
75505befa93c993aa5d2df24a2b64eac0c34cbffMark Andrews # Must use -o largefiles here to ensure the read-only
75505befa93c993aa5d2df24a2b64eac0c34cbffMark Andrews # mount does not fail as a result of having a large
86d2f9abc8493321aacb0d540485de4d562fb734Mark Andrews # In case of a manual restart of the service, mount
86d2f9abc8493321aacb0d540485de4d562fb734Mark Andrews # will emit messages if /usr is already mounted.
86d2f9abc8493321aacb0d540485de4d562fb734Mark Andrews $MOUNT -m -F $fstype -o $mntopts $new_special /usr \
86d2f9abc8493321aacb0d540485de4d562fb734Mark Andrews if [ $ret_val -eq 0 ]; then
3ed16e796dba90c96933c8a8a3f5b9404d8d3e61Mark Andrews# update system dump configuration
14d8a144779b54b103d2da741a2242bf5f9052f7Mark Andrews # Disable device-in-use checking (done in libdiskmgt).
14d8a144779b54b103d2da741a2242bf5f9052f7Mark Andrews # Without disabling this check, the configuration of dump device
70e041bea19b6ad9522b89c2299ad315a2deaafdMark Andrews # would fail as the device-in-use code incorrectly concludes that
70e041bea19b6ad9522b89c2299ad315a2deaafdMark Andrews # the device is in use and hence prevents configuration of the dump
eeb919b6f572e033d97cf001e4cd44aaff54e5dcMichał Kępień DUMPISZFS=`$AWK -F"=" '/DUMPADM_DEVICE/ {print $2}' /etc/dumpadm.conf|$EGREP zvol`
a55438eda32ecebf43ead45b216662b7923a465fMark Andrews set -- `$DUMPADM -u 2>&1 | $EGREP 'cannot use /dev.* as dump device'`
8de17f83cafa91a5720dd0b8c1aee5f47f6d7f09Evan Hunt if [ $? -eq 0 ]; then
8de17f83cafa91a5720dd0b8c1aee5f47f6d7f09Evan Hunt if $DUMPADM -d $newname > /dev/msglog 2> /dev/console; then
9789e54e55b61b669fb31a8b70e9655e8357dda2Mark Andrews has been updated."
f8362536c647625e602c8450a778a2b7ba90c9f4Mark Andrews the dump device.\nold \
f8362536c647625e602c8450a778a2b7ba90c9f4Mark Andrews dump device name: $4"
4b669b69bae7dedda2faa09a7ade247499c1d49cMichał Kępień # make sure we can get to it, force zfs to load fully
4b669b69bae7dedda2faa09a7ade247499c1d49cMichał Kępień cecho "stmsboot: dump on ZFS, no dumpadm update required"
8daeae9b01a2b7eb9fd6511b352b03bd7d96ae79Michał Kępień# Update bootpath for x86 here when we are enabling mpxio on root
01967d183990e44752fe61f193dab9c04c3afd9cEvan Hunt if [ $? -ne 0 ]; then
01967d183990e44752fe61f193dab9c04c3afd9cEvan Hunt cecho "stmsboot: ERROR! Unable to retrieve bootpath property\n"
575e9d9e4b6beaae688f107814a320b91243a4b2Mark Andrews # Since on x64 platforms the eeprom command doesn't update the
7c442d7fe06bc95432af7513764e5cc85e133648Evan Hunt # kernel, the file /boot/solaris/bootenv.rc and the kernel's
7c442d7fe06bc95432af7513764e5cc85e133648Evan Hunt # bootpath variable have a good chance of differing. We do some
7c442d7fe06bc95432af7513764e5cc85e133648Evan Hunt # extra handwaving to get the correct bootpath variable setting.
5e1ca7a326741a8f74e6f2b907c7e1fbf428bf80Michał Kępień ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
764e2f3413ca89d09abffb3eb228c8c820bf08b8Mark Andrews # now strip off leading and trailing space chars
50433a667cf0ed3ac7807768b745b0d870ff8c8bMark Andrews# Now do the actual work
3c12bec945ee71a38c5ba6f624abd12e2da7eea5Mark Andrews # NOTE: If the first attempt to run the service has failed due to an
f44202ab640d22e17b4c74bdad7817622918bd27Mark Andrews # expected error, users should be able to manually rerun the service.
f44202ab640d22e17b4c74bdad7817622918bd27Mark Andrews # First mount /usr read only. This must be done to run
ad9772c559c6aa42f8930f4acf1a2d833a08040aMichał Kępień # In the case of a manual rerun of the service, mounting of /usr here
ad9772c559c6aa42f8930f4acf1a2d833a08040aMichał Kępień # fails if /usr already happens to be mounted. It is better that we
ad9772c559c6aa42f8930f4acf1a2d833a08040aMichał Kępień # do not mount /usr if already mounted, but there seems to be no
5d7d67f82a8913fae5f1098e111fe50edb86cd5bEvan Hunt # apparent way to check whether /usr is mounted or not as we mount
5d7d67f82a8913fae5f1098e111fe50edb86cd5bEvan Hunt # /usr without making an entry into /etc/mnttab. So instead of
5d7d67f82a8913fae5f1098e111fe50edb86cd5bEvan Hunt # explicitly checking for mount failures, we just do a sanity check
6216df5ccded056abd5db4abac4e5cbd78c73f45Evan Hunt # by looking for some file (in this case devfsadm) in /usr.
6216df5ccded056abd5db4abac4e5cbd78c73f45Evan Hunt if [ ! -s $DEVFSADM ]; then
6216df5ccded056abd5db4abac4e5cbd78c73f45Evan Hunt mpxio_error "failed to mount the /usr filesystem."
0612274565d80e0ad87a19920e561cce5bddb05bEvan Hunt # update /etc/vfstab to reflect device name changes
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt if [ $? -eq 0 ]; then
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt # handle active-active paths, where the probe order
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt # for the hba reports a different path to what the
1c8aa38b53a0494fc7d4c3439594d1913987f264Mark Andrews if [ $? -ne 0 ]; then
5fa4be41a383cfbf5e1d195b18c04bdbf5603710Evan Hunt if [ -s /kernel/drv/md.conf ] && \
21d58795b10a13fa7ac306f7146bdcb58b2e5165Mark Andrews cecho "stmsboot: now regenerating boot archive"
ad1317338af79edad878c9c3e4361798503310baMark Andrews if [ $usrmounted -eq 1 ]; then
1c81aef28ddf0905344cc58dd3ea0ca539ef1414Evan Hunt mpxio_error "failed to mount the root filesystem."