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*04cbdd1eSramat# Common Development and Distribution License (the "License"). 7*04cbdd1eSramat# 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*04cbdd1eSramat# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 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-gateFPCONF=/kernel/drv/fp.conf 357c478bd9Sstevel@tonic-gateSAVEDIR=/etc/mpxio 367c478bd9Sstevel@tonic-gateRECOVERFILE=$SAVEDIR/recover_instructions 377c478bd9Sstevel@tonic-gateDEVFSADM=/usr/sbin/devfsadm 387c478bd9Sstevel@tonic-gateMETADEVADM=/usr/sbin/metadevadm 397c478bd9Sstevel@tonic-gateusrmounted=0 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate# map $special and $fsckdev 427c478bd9Sstevel@tonic-gatempxio_mapdev() 437c478bd9Sstevel@tonic-gate{ 447c478bd9Sstevel@tonic-gate new_special=`$STMSBOOTUTIL -m $special` 457c478bd9Sstevel@tonic-gate if [ $? -eq 0 ]; then 467c478bd9Sstevel@tonic-gate special=$new_special 477c478bd9Sstevel@tonic-gate fi 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate new_fsckdev=`$STMSBOOTUTIL -m $fsckdev` 507c478bd9Sstevel@tonic-gate if [ $? -eq 0 ]; then 517c478bd9Sstevel@tonic-gate fsckdev=$new_fsckdev 527c478bd9Sstevel@tonic-gate fi 537c478bd9Sstevel@tonic-gate} 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gatempxio_error() 567c478bd9Sstevel@tonic-gate{ 577c478bd9Sstevel@tonic-gate cecho "\nERROR: stmsboot: $1" 587c478bd9Sstevel@tonic-gate # 597c478bd9Sstevel@tonic-gate # display recovery instructions - the first call logs to the service 607c478bd9Sstevel@tonic-gate # log and the second call displays on the console. 617c478bd9Sstevel@tonic-gate # 627c478bd9Sstevel@tonic-gate shcat $RECOVERFILE 637c478bd9Sstevel@tonic-gate shcat $RECOVERFILE >/dev/msglog 2>&1 647c478bd9Sstevel@tonic-gate cecho "These instructions were also logged to the file $RECOVERFILE\n" 657c478bd9Sstevel@tonic-gate} 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate# 687c478bd9Sstevel@tonic-gate# root ("/") is already mounted read only by the kernel. 697c478bd9Sstevel@tonic-gate# Remount the root read-write. 707c478bd9Sstevel@tonic-gate# 717c478bd9Sstevel@tonic-gatempxio_mount_root() 727c478bd9Sstevel@tonic-gate{ 737c478bd9Sstevel@tonic-gate exec < $vfstab; readvfstab / 747c478bd9Sstevel@tonic-gate mpxio_mapdev 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate checkopt "llock" $mntopts 777c478bd9Sstevel@tonic-gate mntopts='remount' 787c478bd9Sstevel@tonic-gate [ -n "$otherops" ] && mntopts="${mntopts},${otherops}" 797c478bd9Sstevel@tonic-gate /sbin/mount -m -F $fstype -o $mntopts $special $mountp \ 807c478bd9Sstevel@tonic-gate>/dev/msglog 2>&1 817c478bd9Sstevel@tonic-gate} 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate# 847c478bd9Sstevel@tonic-gate# mount /usr read only 857c478bd9Sstevel@tonic-gate# 867c478bd9Sstevel@tonic-gatempxio_mount_usr() 877c478bd9Sstevel@tonic-gate{ 887c478bd9Sstevel@tonic-gate exec < $vfstab; readvfstab "/usr" 897c478bd9Sstevel@tonic-gate ret_val=0 907c478bd9Sstevel@tonic-gate if [ -n "$mountp" ]; then 917c478bd9Sstevel@tonic-gate mpxio_mapdev 927c478bd9Sstevel@tonic-gate if [ "$fstype" = cachefs ]; then 937c478bd9Sstevel@tonic-gate # Mount read-only without the cache. 947c478bd9Sstevel@tonic-gate case "$mntopts" in 957c478bd9Sstevel@tonic-gate *backfstype=nfs*) 967c478bd9Sstevel@tonic-gate cfsbacktype=nfs 977c478bd9Sstevel@tonic-gate ;; 987c478bd9Sstevel@tonic-gate *backfstype=hsfs*) 997c478bd9Sstevel@tonic-gate cfsbacktype=hsfs 1007c478bd9Sstevel@tonic-gate ;; 1017c478bd9Sstevel@tonic-gate *) 1027c478bd9Sstevel@tonic-gate cecho 'stmsboot: invalid vfstab entry for /usr' 1037c478bd9Sstevel@tonic-gate cfsbacktype=nfs 1047c478bd9Sstevel@tonic-gate ;; 1057c478bd9Sstevel@tonic-gate esac 1067c478bd9Sstevel@tonic-gate # see the comment below for /dev/null 1077c478bd9Sstevel@tonic-gate /sbin/mount -m -F $cfsbacktype -o ro $special $mountp \ 1087c478bd9Sstevel@tonic-gate>/dev/null 2>&1 1097c478bd9Sstevel@tonic-gate ret_val=$? 1107c478bd9Sstevel@tonic-gate else 1117c478bd9Sstevel@tonic-gate # 1127c478bd9Sstevel@tonic-gate # Must use -o largefiles here to ensure the read-only 1137c478bd9Sstevel@tonic-gate # mount does not fail as a result of having a large 1147c478bd9Sstevel@tonic-gate # file present on /usr. 1157c478bd9Sstevel@tonic-gate # 1167c478bd9Sstevel@tonic-gate if [ "x$mntopts" = x- ]; then 1177c478bd9Sstevel@tonic-gate mntopts='ro,largefiles' 1187c478bd9Sstevel@tonic-gate else 1197c478bd9Sstevel@tonic-gate checkopt largefiles $mntopts 1207c478bd9Sstevel@tonic-gate if [ "x$option" != xlargefiles ]; then 1217c478bd9Sstevel@tonic-gate mntopts="largefiles,$mntopts" 1227c478bd9Sstevel@tonic-gate fi 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate checkopt ro $mntopts 1257c478bd9Sstevel@tonic-gate if [ "x$option" != xro ]; then 1267c478bd9Sstevel@tonic-gate mntopts="ro,$mntopts" 1277c478bd9Sstevel@tonic-gate fi 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate # 1307c478bd9Sstevel@tonic-gate # Requesting logging on a read-only mount 1317c478bd9Sstevel@tonic-gate # causes errors to be displayed, so remove 1327c478bd9Sstevel@tonic-gate # "logging" from the list of options. 1337c478bd9Sstevel@tonic-gate # 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate checkopt logging $mntopts 1367c478bd9Sstevel@tonic-gate if [ "x$option" = xlogging ]; then 1377c478bd9Sstevel@tonic-gate mntopts="$otherops" 1387c478bd9Sstevel@tonic-gate fi 1397c478bd9Sstevel@tonic-gate fi 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate # 1427c478bd9Sstevel@tonic-gate # In case of a manual restart of the service, mount 1437c478bd9Sstevel@tonic-gate # will emit messages if /usr is already mounted. 1447c478bd9Sstevel@tonic-gate # So redirect the output to /dev/null. 1457c478bd9Sstevel@tonic-gate # 1467c478bd9Sstevel@tonic-gate /sbin/mount -m -F $fstype -o $mntopts $special /usr \ 1477c478bd9Sstevel@tonic-gate>/dev/null 2>&1 1487c478bd9Sstevel@tonic-gate ret_val=$? 1497c478bd9Sstevel@tonic-gate fi 1507c478bd9Sstevel@tonic-gate if [ $ret_val -eq 0 ]; then 1517c478bd9Sstevel@tonic-gate usrmounted=1 1527c478bd9Sstevel@tonic-gate fi 1537c478bd9Sstevel@tonic-gate fi 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate return $ret_val 1567c478bd9Sstevel@tonic-gate} 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate# update system dump configuration 1597c478bd9Sstevel@tonic-gateupdate_dumpconf() 1607c478bd9Sstevel@tonic-gate{ 161*04cbdd1eSramat # 162*04cbdd1eSramat # Disable device-in-use checking (done in libdiskmgt). 163*04cbdd1eSramat # Without disabling this check, the configuration of dump device 164*04cbdd1eSramat # would fail as the device-in-use code incorrectly concludes that 165*04cbdd1eSramat # the device is in use and hence prevents configuration of the dump 166*04cbdd1eSramat # device. 167*04cbdd1eSramat # 168*04cbdd1eSramat NOINUSE_CHECK=1 169*04cbdd1eSramat export NOINUSE_CHECK 170*04cbdd1eSramat 1717c478bd9Sstevel@tonic-gate set -- `dumpadm -u 2>&1 | egrep 'cannot use /dev.* as dump device'` 1727c478bd9Sstevel@tonic-gate if [ "x$4" != x ]; then 1737c478bd9Sstevel@tonic-gate newname=`$STMSBOOTUTIL -M $4` 1747c478bd9Sstevel@tonic-gate if [ $? -eq 0 ]; then 1757c478bd9Sstevel@tonic-gate if dumpadm -d $newname > /dev/null; then 1767c478bd9Sstevel@tonic-gate cecho "stmsboot: dump configuration has been \ 1777c478bd9Sstevel@tonic-gateupdated." 1787c478bd9Sstevel@tonic-gate else 1797c478bd9Sstevel@tonic-gate mpxio_error "failed to configure $newname as \ 1807c478bd9Sstevel@tonic-gatethe dump device.\nold dump device name: $4" 1817c478bd9Sstevel@tonic-gate return 1 1827c478bd9Sstevel@tonic-gate fi 1837c478bd9Sstevel@tonic-gate fi 1847c478bd9Sstevel@tonic-gate fi 1857c478bd9Sstevel@tonic-gate return 0 1867c478bd9Sstevel@tonic-gate} 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate# 1897c478bd9Sstevel@tonic-gate# do the actual work 1907c478bd9Sstevel@tonic-gate# 1917c478bd9Sstevel@tonic-gatempxio_main() 1927c478bd9Sstevel@tonic-gate{ 1937c478bd9Sstevel@tonic-gate # 1947c478bd9Sstevel@tonic-gate # NOTE: If the first attempt to run the service has failed due to an 1957c478bd9Sstevel@tonic-gate # expected error, users should be able to manually rerun the service. 1967c478bd9Sstevel@tonic-gate # 1977c478bd9Sstevel@tonic-gate # First mount /usr read only. This must be done to run 1987c478bd9Sstevel@tonic-gate # utilities such as fsck and devfsadm. 1997c478bd9Sstevel@tonic-gate # In the case of a manual rerun of the service, mounting of /usr here 2007c478bd9Sstevel@tonic-gate # fails if /usr already happens to be mounted. It is better that we 2017c478bd9Sstevel@tonic-gate # do not mount /usr if already mounted, but there seems to be no 2027c478bd9Sstevel@tonic-gate # apparent way to check whether /usr is mounted or not as we mount 2037c478bd9Sstevel@tonic-gate # /usr without making an entry into /etc/mnttab. So instead of 2047c478bd9Sstevel@tonic-gate # explicitly checking for mount failures, we just do a sanity check 2057c478bd9Sstevel@tonic-gate # by looking for some file (in this case devfsadm) in /usr. 2067c478bd9Sstevel@tonic-gate # 2077c478bd9Sstevel@tonic-gate mpxio_mount_usr 2087c478bd9Sstevel@tonic-gate if [ ! -s $DEVFSADM ]; then 2097c478bd9Sstevel@tonic-gate mpxio_error "failed to mount the /usr filesystem." 2107c478bd9Sstevel@tonic-gate return 2117c478bd9Sstevel@tonic-gate fi 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate if mpxio_mount_root; then 2147c478bd9Sstevel@tonic-gate # create /dev links 2157c478bd9Sstevel@tonic-gate cecho "stmsboot: configuring devices" 2167c478bd9Sstevel@tonic-gate $DEVFSADM 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate # update /etc/vfstab to reflect device name changes 2197c478bd9Sstevel@tonic-gate if $STMSBOOTUTIL -u >/dev/msglog 2>&1; then 2207c478bd9Sstevel@tonic-gate if update_dumpconf; then 2217c478bd9Sstevel@tonic-gate # update svm configuration to reflect new names 2227c478bd9Sstevel@tonic-gate if [ -s /kernel/drv/md.conf ] && \ 2237c478bd9Sstevel@tonic-gate [ -x $METADEVADM ]; then 2247c478bd9Sstevel@tonic-gate $METADEVADM -r >/dev/msglog 2>&1 2257c478bd9Sstevel@tonic-gate fi 2267c478bd9Sstevel@tonic-gate fi 2277c478bd9Sstevel@tonic-gate else 2287c478bd9Sstevel@tonic-gate mpxio_error "failed to update /etc/vfstab." 2297c478bd9Sstevel@tonic-gate fi 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /usr/sbin/svcadm disable platform/sun4u/mpxio-upgrade 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /usr/sbin/reboot 2347c478bd9Sstevel@tonic-gate else 2357c478bd9Sstevel@tonic-gate mpxio_error "failed to mount the root filesystem." 2367c478bd9Sstevel@tonic-gate if [ $usrmounted -eq 1 ]; then 2377c478bd9Sstevel@tonic-gate /sbin/umount /usr 2387c478bd9Sstevel@tonic-gate fi 2397c478bd9Sstevel@tonic-gate fi 2407c478bd9Sstevel@tonic-gate} 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gatempxio_main 243