2014-11-19 14:42:19 +00:00
|
|
|
#!/bin/bash
|
2010-10-12 08:26:20 +00:00
|
|
|
# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#(C)IBM Corp
|
|
|
|
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#setbootfromdisk
|
|
|
|
# The script is used to set harddisk(sda) to be the default bootup devices
|
|
|
|
# on Redhat-family OSes with POWER system
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OS=`uname`
|
|
|
|
if [[ $OS = "Linux" ]]; then
|
|
|
|
if [[ $OSVER = fedora* ]] || [[ $OSVER = rhels5* ]] || [[ $OSVER = rhel6* ]] || [[ $OSVER=rhels6* ]] || [[ -f /etc/fedora-release ]] || [[ -f /etc/redhat-release ]]; then
|
|
|
|
if [[ -f /usr/sbin/bootlist ]] ; then
|
|
|
|
# determine which harddisk should be the default one
|
|
|
|
# /dev/sda3 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
|
|
|
|
BOOTENTRY=`cat /proc/mounts |grep /boot`
|
|
|
|
|
|
|
|
if [[ -z $BOOTENTRY ]]; then
|
2010-11-12 09:09:11 +00:00
|
|
|
BOOTENTRY=`grep ^\/dev /proc/mounts |grep " / "`
|
2010-10-12 08:26:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
BOOTDEVICE=`echo $BOOTENTRY | awk '{print $1}'`
|
2011-05-25 06:46:22 +00:00
|
|
|
|
2011-07-25 09:08:07 +00:00
|
|
|
if [[ -f /sbin/multipath ]] ; then
|
|
|
|
MPATH=`/sbin/multipath -ll`
|
|
|
|
fi
|
|
|
|
|
2011-05-25 06:46:22 +00:00
|
|
|
#software raid, assume sda and sdb
|
|
|
|
if echo $BOOTDEVICE | grep "md"
|
|
|
|
then
|
2011-07-25 09:08:07 +00:00
|
|
|
if echo $MPATH | grep "sdc"
|
|
|
|
then
|
|
|
|
if echo $MPATH | grep "sdd"
|
|
|
|
then
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting sda sdb sdc sdd to be the default bootup device
|
2011-07-25 09:08:07 +00:00
|
|
|
echo "setbootfromdisk: setting up sda sdb sdc sdd to be the default bootup device"
|
|
|
|
bootlist -m normal sda sdb sdc sdd
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting sda sdb to be the default bootup device
|
2011-07-25 09:08:07 +00:00
|
|
|
echo "setbootfromdisk: setting up sda sdb to be the default bootup device for software raid"
|
2011-05-25 06:46:22 +00:00
|
|
|
bootlist -m normal sda sdb
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-08-10 05:28:53 +00:00
|
|
|
if echo $BOOTDEVICE | grep "mpath"
|
2011-07-25 09:08:07 +00:00
|
|
|
then
|
2011-08-10 05:28:53 +00:00
|
|
|
found=0
|
|
|
|
for i in $MPATH
|
|
|
|
do
|
|
|
|
if echo $BOOTDEVICE | grep "$i"
|
|
|
|
then
|
|
|
|
found=1
|
|
|
|
else
|
|
|
|
if echo $i | grep "mpath"
|
|
|
|
then
|
|
|
|
found=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $found = 1 ]]
|
|
|
|
then
|
|
|
|
if echo $i | grep "sda"
|
|
|
|
then
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting sda sdb to be the default bootup device
|
2011-08-10 05:28:53 +00:00
|
|
|
echo "setbootfromdisk: setting up sda sdb to be the default bootup device"
|
|
|
|
bootlist -m normal sda sdb
|
|
|
|
exit 0
|
|
|
|
elif echo $i | grep "sdc"
|
|
|
|
then
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting sdc sdd to be the default bootup device
|
2011-08-10 05:28:53 +00:00
|
|
|
echo "setbootfromdisk: setting up sdc sdd to be the default bootup device"
|
|
|
|
bootlist -m normal sdc sdd
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2011-07-25 09:08:07 +00:00
|
|
|
if echo $MPATH | grep "sdb"
|
|
|
|
then
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting sda sdb to be the default bootup device
|
2011-07-25 09:08:07 +00:00
|
|
|
echo "setbootfromdisk: setting up sda sdb to be the default bootup device"
|
|
|
|
bootlist -m normal sda sdb
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-10-12 08:26:20 +00:00
|
|
|
if [[ -z $BOOTDEVICE ]]; then
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.err setbootfromdisk: cannot find the booting device
|
2010-10-12 08:26:20 +00:00
|
|
|
else
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.info setbootfromdisk: Setting $BOOTDEVICE to be the default bootup device
|
2010-10-12 08:26:20 +00:00
|
|
|
echo "setbootfromdisk: setting up $BOOTDEVICE as the default bootup device"
|
|
|
|
bootlist -m normal $BOOTDEVICE
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
2012-05-15 03:25:47 +00:00
|
|
|
logger -t xcat -p local4.err Could not find /usr/sbin/bootlist
|
2010-10-12 08:26:20 +00:00
|
|
|
echo "setbootfromdisk: could not find /usr/sbin/bootlist"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|