summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2008-09-24 16:14:19 -0700
committerBob Gilligan <gilligan@vyatta.com>2008-09-24 16:14:19 -0700
commit5b12b1bc33ccafdbfafdafe71740ccb9e8977cc0 (patch)
tree5066689f58e3729989414f2bf00b369015fdcafc
parent0558e3ce00df57792cef3678f21fa6cd834ce641 (diff)
downloadvyatta-cfg-quagga-5b12b1bc33ccafdbfafdafe71740ccb9e8977cc0.tar.gz
vyatta-cfg-quagga-5b12b1bc33ccafdbfafdafe71740ccb9e8977cc0.zip
Bugfix: 3703
Add an item to the grub menu to boot diagnostics if we find a partition that looks to be the diag partition.
-rwxr-xr-xscripts/grub-setup63
1 files changed, 51 insertions, 12 deletions
diff --git a/scripts/grub-setup b/scripts/grub-setup
index 70da564e..1bf47dde 100755
--- a/scripts/grub-setup
+++ b/scripts/grub-setup
@@ -71,26 +71,26 @@ serial_console="console=tty0 console=ttyS0,9600"
#
vga_logo="vga=785"
- # get list of kernels, except Xen
- kernel_versions=$(ls $ROOTFSDIR/boot/vmlinuz-* 2> /dev/null | grep -v xen | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
+# get list of kernels, except Xen
+kernel_versions=$(ls $ROOTFSDIR/boot/vmlinuz-* 2> /dev/null | grep -v xen | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
- # get xen kernel info
- xen_kernel_version=$(ls $ROOTFSDIR/boot/vmlinuz*xen 2> /dev/null | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
- xen_version=$(ls $ROOTFSDIR/boot/xen-* 2> /dev/null | awk -F/ '{ print $5 }' | sort -r)
+# get xen kernel info
+xen_kernel_version=$(ls $ROOTFSDIR/boot/vmlinuz*xen 2> /dev/null | awk -F/ '{ print $5 }' | sed 's/vmlinuz//g' | sort -r)
+xen_version=$(ls $ROOTFSDIR/boot/xen-* 2> /dev/null | awk -F/ '{ print $5 }' | sort -r)
- # Figure out whether we are running on the serial or KVM console:
- if [ "`tty`" == "/dev/ttyS0" ]; then
+# Figure out whether we are running on the serial or KVM console:
+if [ "`tty`" == "/dev/ttyS0" ]; then
# Since user is running on serial console, make that the default.
default_console=1
- else
+else
# Since user is running on KVM console, make that the default
default_console=0
- fi
+fi
- if eval "$UNION"; then
+if eval "$UNION"; then
GRUB_OPTIONS="boot=live live-media-path=/boot/$livedir module=$livedir quiet persistent noautologin nonetworking nouser hostname=vyatta"
union_kernel_versions=$(ls $ROOTFSDIR/boot/$livedir/vmlinuz-* 2> /dev/null | grep -v xen | awk -F/ '{ print $6 }' | sed 's/vmlinuz//g' | sort -r)
- else
+else
# Read UUID off of filesystem and use it to tell GRUB where to mount drive
# This allows device to move around and grub will still find it
uuid=$(dumpe2fs -h /dev/${ROOT_PARTITION} 2>/dev/null | awk '/^Filesystem UUID/ {print $3}')
@@ -102,7 +102,37 @@ vga_logo="vga=785"
else
GRUB_OPTIONS="$GRUB_OPTIONS root=UUID=$uuid ro"
fi
- fi
+fi
+
+# Check for diagnostic partition residing in first partition of drive
+# holding the root partition.
+
+diag_drive_number=""
+
+if [ ${ROOT_PARTITION:0:2} = "md" ]; then
+ # Select the first disk in the RAID group to look for diag partition on
+ root_disks=`echo /sys/block/$ROOT_PARTITION/slaves/*`
+ root_disk=`echo ${root_disks} | awk '{ print $1 }'`
+ root_disk=${root_disk##*/}
+ root_disk=${root_disk:0:${#root_disk}-1}
+else
+ # Shave off the partition number to get the disk name
+ root_disk=${ROOT_PARTITION:0:${#ROOT_PARTITION}-1}
+fi
+
+# If the root partition is not occupying the first partition, then we
+# can look for a diag partition there.
+if [ "$ROOT_PARTITION" != "${root_disk}1" ]; then
+ first_part_fstype=`fdisk -l /dev/$root_disk | grep ^/dev/${root_disk}1 | awk '{ print $6 }'`
+
+ if [ "$first_part_fstype" = "FAT16" -o "$first_part_fstype" = "Dell" ]; then
+ # Translate the Linux drive letter (e.g. the "a" in "/dev/sda") into
+ # a drive number that grub uses. i.e. "a" = 0, "b" = 1, etc.
+ diag_drive_letter=${root_disk:2:1}
+ diag_drive_number=`echo $diag_drive_letter | od -t u1 -N 1 | awk '{ print $2 }'`
+ let diag_drive_number-=97
+ fi
+fi
(
# create the grub.cfg file for grub
@@ -208,6 +238,15 @@ vga_logo="vga=785"
echo -e "\tlinux /boot/vmlinuz $GRUB_OPTIONS $serial_console init=$pass_reset"
echo -e "\tinitrd /boot/initrd.img"
echo -e "}"
+
+ if [ -n "$diag_drive_number" ]; then
+ echo
+ echo -e "menuentry \"Diagnostics\" {"
+ echo -e "\tchainloader (hd$diag_drive_number,1)+1"
+ echo -e "}"
+ fi
+
+
) >"$ROOTFSDIR"/boot/grub/grub.cfg
( [ -s /boot/grub/menu.lst ] &&