1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 # T2 SDE: package/*/grub/stone_mod_grub.sh
5 # Copyright (C) 2004 - 2021 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 # [MAIN] 70 grub GRUB Boot Loader Setup
19 create_kernel_list
() {
21 for x
in `(cd /boot/; ls vmlinuz-*) | sort -r` ; do
23 if [ $first = 1 ] ; then
32 kernel $bootdrive$bootpath/$x root=$rootdev ro
33 initrd $bootdrive$bootpath/initrd-${ver}
39 gui_cmd
'(Re-)Create GRUB Device Map' "$( cat << "EOT
"
40 rm -vf /boot/grub/device.map
41 echo quit | grub --batch --device-map=/boot/grub/device.map
50 # extract device type (block) and major number for root drive
51 local major_minor
=`ls -Ll $device |
52 awk '{if ($6 < 64) printf("%c%d0", $1, $5); else printf("%c%d1", $1, $5)}'`
54 # find the matching BIOS device
55 for bios_drive
in `grep -v '^#' /boot/grub/device.map | awk '{print $2}'`
57 bios_major_minor
=`ls -Ll $bios_drive 2>/dev/null |
58 awk '{if ($6 < 64) printf("%c%d0", $1, $5); else printf("%c%d1", $1, $5)}'`
60 if [ "$major_minor" = "$bios_major_minor" ]; then
62 root_drive
=`grep $bios_drive /boot/grub/device.map | awk '{print $1}'`
63 root_part
=`ls -Ll $device | awk '{print $6}'`
64 root_part
=$
(( $root_part % 16 - 1 ))
69 drive
=`echo $root_drive | sed "s:)$:,$root_part):"`
74 # determine /boot path, relative to the boot device
75 # (non local as used by create_kernel_list() ...)
77 if [ "$rootdrive" = "$bootdrive" ]
78 then bootpath
="/boot"; else bootpath
=""; fi
80 cat << EOT > /boot/grub/menu.lst
86 [ -f /boot
/t2.xpm.gz
] && cat << EOT >> /boot/grub/menu.lst
90 splashimage $bootdrive$bootpath/t2.xpm.gz
93 create_kernel_list
>> /boot
/grub
/menu.lst
95 [ -f /boot
/memtest86.bin
] && cat << EOT >> /boot/grub/menu.lst
97 title MemTest86 (memory tester)
98 kernel $bootdrive$bootpath/memtest86.bin
101 gui_message
"This is the new /boot/grub/menu.lst file:
103 $( cat /boot/grub/menu.lst )"
108 gui_cmd
'Installing GRUB' "echo -e 'root $bootdrive\\nsetup (hd0)\\nquit' | grub --batch --device-map=/boot/grub/device.map"
112 rootdev
="`grep ' / ' /proc/mounts | tail -n 1 | sed 's, .*,,'`"
113 bootdev
="`grep ' /boot ' /proc/mounts | tail -n 1 | sed 's, .*,,'`"
114 [ -z "$bootdev" ] && bootdev
="$rootdev"
117 rootdev
="$( cd `dirname $rootdev` ; pwd -P )/$( basename $rootdev )"
118 while [ -L $rootdev ] ; do
119 directory
="$( cd `dirname $rootdev` ; pwd -P )"
120 rootdev
="$( ls -l $rootdev | sed 's,.* -> ,,' )"
121 [ "${rootdev##/*}" ] && rootdev
="$directory/$rootdev"
122 i
=$
(( $i + 1 )) ; [ $i -gt 20 ] && rootdev
="Not found!"
126 bootdev
="$( cd `dirname $bootdev` ; pwd -P )/$( basename $bootdev )"
127 while [ -L $bootdev ] ; do
128 directory
="$( cd `dirname $bootdev` ; pwd -P )"
129 bootdev
="$( ls -l $bootdev | sed 's,.* -> ,,' )"
130 [ "${bootdev##/*}" ] && bootdev
="$directory/$bootdev"
131 i
=$
(( $i + 1 )) ; [ $i -gt 20 ] && bootdev
="Not found!"
134 if [ ! -f /boot
/grub
/menu.lst
] ; then
135 if gui_yesno
"GRUB does not appear to be configured.
136 Automatically install GRUB now?"; then
138 rootdrive
=`convert_device $rootdev`
139 bootdrive
=`convert_device $bootdev`
141 if ! grub_install
; then
142 gui_message
"There was an error while installing GRUB."
149 if [ -s /boot
/grub
/device.map
] ; then
150 rootdrive
=`convert_device $rootdev`
151 bootdrive
=`convert_device $bootdev`
153 rootdrive
='No Device Map found!'
154 bootdrive
='No Device Map found!'
157 gui_menu grub
'GRUB Boot Loader Setup' \
158 '(Re-)Create GRUB Device Map' 'create_device_map' \
159 "Root Device ... $rootdev" "" \
160 "Boot Drive .... $bootdrive$boot_path" "" \
162 '(Re-)Create boot menu with installed kernels' 'create_boot_menu' \
163 '(Re-)Install GRUB in MBR of (hd0)' 'grub_install' \
165 "Edit /boot/grub/device.map (Device Map)" \
166 "gui_edit 'GRUB Device Map' /boot/grub/device.map" \
167 "Edit /boot/grub/menu.lst (Boot Menu)" \
168 "gui_edit 'GRUB Boot Menu' /boot/grub/menu.lst"