mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-19 19:40:37 +02:00
'added correct md detection to grub'
This commit is contained in:
parent
fa5ab670fb
commit
d486dad1d6
1 changed files with 102 additions and 40 deletions
|
@ -222,6 +222,36 @@ findpartitions() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findgrubpartitions() {
|
||||||
|
block=/sys/block
|
||||||
|
for devpath in $(finddisks); do
|
||||||
|
disk=$(echo $devpath | sed 's|.*/||')
|
||||||
|
for part in $(ls $block/$disk | egrep ^$disk); do
|
||||||
|
# check if not already assembled to a raid device
|
||||||
|
if ! [ "$(cat /proc/mdstat 2>/dev/null | grep $part)" -o "$(fstype 2>/dev/null </dev/$part | grep "lvm2")" -o "$(sfdisk -c /dev/$disk $(echo $part | sed -e "s#$disk##g") 2>/dev/null | grep "5")" ]; then
|
||||||
|
if [ -d $block/$disk/$part ]; then
|
||||||
|
echo "/dev/$part"
|
||||||
|
[ "$1" ] && echo $1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
# inlcude cciss controllers
|
||||||
|
if [ -d /dev/cciss ] ; then
|
||||||
|
for dev in $(ls /dev/cciss | egrep 'p'); do
|
||||||
|
echo "/dev/cciss/$dev"
|
||||||
|
[ "$1" ] && echo $1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# inlcude Smart 2 controllers
|
||||||
|
if [ -d /dev/ida ] ; then
|
||||||
|
for dev in $(ls /dev/ida | egrep 'p'); do
|
||||||
|
echo "/dev/ida/$dev"
|
||||||
|
[ "$1" ] && echo $1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
get_grub_map() {
|
get_grub_map() {
|
||||||
rm /tmp/dev.map
|
rm /tmp/dev.map
|
||||||
DIALOG --infobox "Generating GRUB device map...\nThis could take a while.\n\n Please be patient." 0 0
|
DIALOG --infobox "Generating GRUB device map...\nThis could take a while.\n\n Please be patient." 0 0
|
||||||
|
@ -262,7 +292,7 @@ mapdev() {
|
||||||
echo "$grubdevice,$pnum)"
|
echo "$grubdevice,$pnum)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " DEVICE NOT FOUND"
|
echo "DEVICE NOT FOUND"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,17 +633,19 @@ partition() {
|
||||||
DISC=""
|
DISC=""
|
||||||
while true; do
|
while true; do
|
||||||
# Prompt the user with a list of known disks
|
# Prompt the user with a list of known disks
|
||||||
DIALOG --menu "Select the disk you want to partition (select DONE when finished)" 14 55 7 $DISCS 2>$ANSWER || return 1
|
DIALOG --menu "Select the disk you want to partition\n(select DONE when finished)" 14 55 7 $DISCS 2>$ANSWER || return 1
|
||||||
DISC=$(cat $ANSWER)
|
DISC=$(cat $ANSWER)
|
||||||
if [ "$DISC" = "OTHER" ]; then
|
if [ "$DISC" = "OTHER" ]; then
|
||||||
DIALOG --inputbox "Enter the full path to the device you wish to partition" 8 65 "/dev/sda" 2>$ANSWER || return 1
|
DIALOG --inputbox "Enter the full path to the device you wish to partition" 8 65 "/dev/sda" 2>$ANSWER || DISC=""
|
||||||
DISC=$(cat $ANSWER)
|
DISC=$(cat $ANSWER)
|
||||||
fi
|
fi
|
||||||
# Leave our loop if the user is done partitioning
|
# Leave our loop if the user is done partitioning
|
||||||
[ "$DISC" = "DONE" ] && break
|
[ "$DISC" = "DONE" ] && break
|
||||||
# Partition disc
|
if ! [ "$DISC" = "" ]; then
|
||||||
DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your hard drive. You should make a swap partition and as many data partitions as you will need. NOTE: cfdisk may tell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to step 2." 18 70
|
# Partition disc
|
||||||
cfdisk $DISC
|
DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your hard drive. You should make a swap partition and as many data partitions as you will need. NOTE: cfdisk may tell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to step 2." 18 70
|
||||||
|
cfdisk $DISC
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
NEXTITEM="3"
|
NEXTITEM="3"
|
||||||
S_PART=1
|
S_PART=1
|
||||||
|
@ -1248,6 +1280,10 @@ dolilo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
dogrub() {
|
dogrub() {
|
||||||
|
_bootdev=""
|
||||||
|
_grubdev=""
|
||||||
|
bootdev=""
|
||||||
|
grubdev=""
|
||||||
getrootfs
|
getrootfs
|
||||||
get_grub_map
|
get_grub_map
|
||||||
if [ ! -f $DESTDIR/boot/grub/menu.lst ]; then
|
if [ ! -f $DESTDIR/boot/grub/menu.lst ]; then
|
||||||
|
@ -1256,7 +1292,22 @@ dogrub() {
|
||||||
fi
|
fi
|
||||||
# try to auto-configure GRUB...
|
# try to auto-configure GRUB...
|
||||||
if [ "$PART_ROOT" != "" -a "$S_GRUB" != "1" ]; then
|
if [ "$PART_ROOT" != "" -a "$S_GRUB" != "1" ]; then
|
||||||
grubdev=$(mapdev $PART_ROOT)
|
if [ "$(echo $PART_ROOT | grep md)" ]; then
|
||||||
|
for i in $(mdadm --detail $PART_ROOT | grep "\ /dev/" | sed -e 's#.* /#/#g'); do
|
||||||
|
_grubdev="$_grubdev $(mapdev $i)"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
_grubdev=$(mapdev $PART_ROOT)
|
||||||
|
fi
|
||||||
|
# look for a separately-mounted /boot partition
|
||||||
|
bootdev=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
|
||||||
|
if [ "$(echo $bootdev | grep md)" ]; then
|
||||||
|
for i in $(mdadm --detail $_bootdev | grep "\ /dev/" | sed -e 's#.* /#/#g'); do
|
||||||
|
_bootdev="$_bootdev $i"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
_bootdev=$bootdev
|
||||||
|
fi
|
||||||
if [ "$UUIDPARAMETER" = "yes" ]; then
|
if [ "$UUIDPARAMETER" = "yes" ]; then
|
||||||
local _rootpart="${PART_ROOT}"
|
local _rootpart="${PART_ROOT}"
|
||||||
local _uuid="$(getuuid ${PART_ROOT})"
|
local _uuid="$(getuuid ${PART_ROOT})"
|
||||||
|
@ -1264,19 +1315,16 @@ dogrub() {
|
||||||
_rootpart="/dev/disk/by-uuid/${_uuid}"
|
_rootpart="/dev/disk/by-uuid/${_uuid}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# look for a separately-mounted /boot partition
|
if [ "$_grubdev" != "" -o "$_bootdev" != "" ]; then
|
||||||
bootdev=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
|
|
||||||
if [ "$grubdev" != "" -o "$bootdev" != "" ]; then
|
|
||||||
cp $DESTDIR/boot/grub/menu.lst /tmp/.menu.lst
|
cp $DESTDIR/boot/grub/menu.lst /tmp/.menu.lst
|
||||||
# remove the default entries by truncating the file at our little tag (#-*)
|
# remove the default entries by truncating the file at our little tag (#-*)
|
||||||
head -n $(cat /tmp/.menu.lst | grep -n '#-\*' | cut -d: -f 1) /tmp/.menu.lst >$DESTDIR/boot/grub/menu.lst
|
head -n $(cat /tmp/.menu.lst | grep -n '#-\*' | cut -d: -f 1) /tmp/.menu.lst >$DESTDIR/boot/grub/menu.lst
|
||||||
rm -f /tmp/.menu.lst
|
rm -f /tmp/.menu.lst
|
||||||
echo "" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "# (0) Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "title Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
subdir=
|
subdir=
|
||||||
if [ "$bootdev" != "" ]; then
|
if [ "$_bootdev" != "" ]; then
|
||||||
grubdev=$(mapdev $bootdev)
|
for bootdev in $_bootdev; do
|
||||||
|
_grubdev="$_grubdev $(mapdev $bootdev)"
|
||||||
|
done
|
||||||
else
|
else
|
||||||
subdir="/boot"
|
subdir="/boot"
|
||||||
fi
|
fi
|
||||||
|
@ -1285,30 +1333,38 @@ dogrub() {
|
||||||
DIALOG --msgbox "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." 0 0
|
DIALOG --msgbox "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." 0 0
|
||||||
grubdev="(hd0,0)"
|
grubdev="(hd0,0)"
|
||||||
fi
|
fi
|
||||||
echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst
|
NUMBER=0
|
||||||
if [ "$UUIDPARAMETER" = "yes" ]; then
|
for grubdev in $_grubdev; do
|
||||||
echo "kernel $subdir/$VMLINUZ root=${_rootpart} rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
echo "" >>$DESTDIR/boot/grub/menu.lst
|
||||||
else
|
echo "# ($NUMBER) Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
||||||
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
echo "title Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
||||||
fi
|
echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst
|
||||||
if [ "$VMLINUZ" = "vmlinuz26" ]; then
|
if [ "$UUIDPARAMETER" = "yes" ]; then
|
||||||
echo "initrd $subdir/kernel26.img" >>$DESTDIR/boot/grub/menu.lst
|
echo "kernel $subdir/$VMLINUZ root=${_rootpart} rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
||||||
fi
|
else
|
||||||
|
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
fi
|
||||||
|
if [ "$VMLINUZ" = "vmlinuz26" ]; then
|
||||||
|
echo "initrd $subdir/kernel26.img" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
fi
|
||||||
|
echo "" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
# adding fallback/full image
|
||||||
|
NUMBER=$(($NUMBER+1))
|
||||||
|
echo "# (($NUMBER) Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
echo "title Arch Linux Fallback" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
if [ "$UUIDPARAMETER" = "yes" ]; then
|
||||||
|
echo "kernel $subdir/$VMLINUZ root=${_rootpart} rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
else
|
||||||
|
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
fi
|
||||||
|
if [ "$VMLINUZ" = "vmlinuz26" ]; then
|
||||||
|
echo "initrd $subdir/kernel26-fallback.img" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
fi
|
||||||
|
NUMBER=$(($NUMBER+1))
|
||||||
|
done
|
||||||
echo "" >>$DESTDIR/boot/grub/menu.lst
|
echo "" >>$DESTDIR/boot/grub/menu.lst
|
||||||
# adding fallback/full image
|
echo "# ($NUMBER) Windows" >>$DESTDIR/boot/grub/menu.lst
|
||||||
echo "# (1) Arch Linux" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "title Arch Linux Fallback" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
if [ "$UUIDPARAMETER" = "yes" ]; then
|
|
||||||
echo "kernel $subdir/$VMLINUZ root=${_rootpart} rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
else
|
|
||||||
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT rootfstype=$ROOTFS ro" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
fi
|
|
||||||
if [ "$VMLINUZ" = "vmlinuz26" ]; then
|
|
||||||
echo "initrd $subdir/kernel26-fallback.img" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
fi
|
|
||||||
echo "" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "# (2) Windows" >>$DESTDIR/boot/grub/menu.lst
|
|
||||||
echo "#title Windows" >>$DESTDIR/boot/grub/menu.lst
|
echo "#title Windows" >>$DESTDIR/boot/grub/menu.lst
|
||||||
echo "#rootnoverify (hd0,0)" >>$DESTDIR/boot/grub/menu.lst
|
echo "#rootnoverify (hd0,0)" >>$DESTDIR/boot/grub/menu.lst
|
||||||
echo "#makeactive" >>$DESTDIR/boot/grub/menu.lst
|
echo "#makeactive" >>$DESTDIR/boot/grub/menu.lst
|
||||||
|
@ -1321,7 +1377,7 @@ dogrub() {
|
||||||
$EDITOR ${DESTDIR}/boot/grub/menu.lst
|
$EDITOR ${DESTDIR}/boot/grub/menu.lst
|
||||||
|
|
||||||
DEVS=$(finddisks _)
|
DEVS=$(finddisks _)
|
||||||
DEVS="$DEVS $(findpartitions _)"
|
DEVS="$DEVS $(findgrubpartitions _)"
|
||||||
if [ "$DEVS" = "" ]; then
|
if [ "$DEVS" = "" ]; then
|
||||||
DIALOG --msgbox "No hard drives were found" 0 0
|
DIALOG --msgbox "No hard drives were found" 0 0
|
||||||
return 1
|
return 1
|
||||||
|
@ -1340,12 +1396,18 @@ dogrub() {
|
||||||
fi
|
fi
|
||||||
# look for a separately-mounted /boot partition
|
# look for a separately-mounted /boot partition
|
||||||
bootpart=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
|
bootpart=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1)
|
||||||
|
if [ "$(echo $bootpart | grep md)" ]; then
|
||||||
|
bootpart=$(mdadm --detail $bootpart | grep $ROOTDEV | sed -e 's#.* /#/#g')
|
||||||
|
fi
|
||||||
if [ "$bootpart" = "" ]; then
|
if [ "$bootpart" = "" ]; then
|
||||||
if [ "$PART_ROOT" = "" ]; then
|
if [ "$PART_ROOT" = "" ]; then
|
||||||
DIALOG --inputbox "Enter the full path to your root device" 8 65 "/dev/sda3" 2>$ANSWER || return 1
|
DIALOG --inputbox "Enter the full path to your root device" 8 65 "/dev/sda3" 2>$ANSWER || return 1
|
||||||
bootpart=$(cat $ANSWER)
|
bootpart=$(cat $ANSWER)
|
||||||
else
|
else
|
||||||
bootpart=$PART_ROOT
|
bootpart=$PART_ROOT
|
||||||
|
if [ "$(echo $bootpart | grep md)" ]; then
|
||||||
|
bootpart=$(mdadm --detail $bootpart | grep $ROOTDEV | sed -e 's#.* /#/#g')
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
bootpart=$(mapdev $bootpart)
|
bootpart=$(mapdev $bootpart)
|
||||||
|
@ -1377,7 +1439,7 @@ EOF
|
||||||
DIALOG --msgbox "GRUB was successfully installed." 0 0
|
DIALOG --msgbox "GRUB was successfully installed." 0 0
|
||||||
S_GRUB=1
|
S_GRUB=1
|
||||||
if [ "$(blkid -c /dev/null | grep TYPE=\"mdraid\")" ]; then
|
if [ "$(blkid -c /dev/null | grep TYPE=\"mdraid\")" ]; then
|
||||||
DIALOG --defaultno --yesno "You have your system installed on software raid.\nAnswer 'YES' to install grub to another hard disk." 0 0 && S_GRUB=""
|
DIALOG --defaultno --yesno "Setup detected a software raid partition.\nDo you want to install grub additionally to an other hard disk?" 0 0 && S_GRUB=""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue