60 lines
1.8 KiB
Plaintext
60 lines
1.8 KiB
Plaintext
if [ -d /sys/firmware/efi ]; then
|
|
echo "Setting Boot Manager for the next boot."
|
|
echo "delete all sysclone boot list"
|
|
str_bootnums=`efibootmgr | grep 'syscloneLinux' | awk '{print $1}' | sed 's/boot//i' | sed 's/*//'`
|
|
for str_num in $str_bootnums
|
|
do
|
|
efibootmgr -b $str_num -B -q
|
|
done
|
|
|
|
if [ -f "/boot/efi/EFI/redhat/grub.efi" ];then
|
|
efibootmgr -c -l \\EFI\\redhat\\grub.efi -L syscloneLinux
|
|
elif [ -f "/boot/efi/efi/SuSE/elilo.efi" ];then
|
|
efibootmgr -c -l \\efi\\SuSE\\elilo.efi -L syscloneLinux
|
|
else
|
|
echo "Can not find the boot loader."
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "run grub-install to configure the MBR."
|
|
if [ -e /etc/mtab ];then
|
|
mv /etc/mtab /etc/mtab.bak
|
|
fi
|
|
grep -v rootfs /proc/mounts > /etc/mtab
|
|
boot_device=''
|
|
if [ -f "/etc/systemconfig/systemconfig.conf" ];then
|
|
boot_device=`cat /etc/systemconfig/systemconfig.conf | grep BOOTDEV | awk '{print $3}'`
|
|
else
|
|
str_temp=`mount | awk '{print $1","$3}'`
|
|
for line in $str_temp
|
|
do
|
|
mp=`echo $line | awk -F, '{print $2}'`
|
|
if [ "$mp" = "/" ];then
|
|
boot_device=`echo $line | awk -F, '{print $1}' | sed -e 's/[0-9]*$//'`
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ -n "$boot_device" ];then
|
|
echo "the boot device is $boot_device"
|
|
else
|
|
echo "Can not find the boot device, return error"
|
|
exit 1
|
|
fi
|
|
|
|
#for sles10, should run grub-install with parameters
|
|
echo "grub-install --no-floppy --recheck $boot_device"
|
|
grub-install --no-floppy --recheck $boot_device
|
|
if [ $? -ne 0 ];then
|
|
#sles11, run grub install directly
|
|
grub-install
|
|
fi
|
|
|
|
if [ -e /etc/mtab.bak ];then
|
|
mv -f /etc/mtab.bak /etc/mtab
|
|
else
|
|
rm -f /etc/mtab
|
|
fi
|
|
fi
|