grub.cfg: bruteforce linux/initrd if no grub.cfg
this is probably not safe, and neither is the current fall back code which is being removed from master. i already finished it before testing, but after realising the above, so i'll just stash it in this branch for now. Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
2d6e5ca4c4
commit
fbb8f8b1d0
|
@ -90,6 +90,11 @@ function search_isolinux {
|
||||||
done
|
done
|
||||||
echo # Insert newline
|
echo # Insert newline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function try_without_config {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
|
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
|
||||||
|
|
||||||
if [ "${grub_scan_disk}" != "ata" ]; then
|
if [ "${grub_scan_disk}" != "ata" ]; then
|
||||||
|
@ -146,31 +151,104 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
|
||||||
try_user_config "${vol}"
|
try_user_config "${vol}"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${grub_scan_disk}" != "ata" ]; then
|
# bruteforce as a last result. figure out how to boot
|
||||||
# Last resort, if all else fails
|
# linux without a grub configuration file. (crypto and lvm unsupported)
|
||||||
set root=ahci0,1
|
set vmlinuz=""
|
||||||
for p in / /boot/; do
|
set initrd=""
|
||||||
if [ -f "${p}vmlinuz" ]; then
|
set devtype=""
|
||||||
linux ${p}vmlinuz root=/dev/sda1 rw
|
set devnum=""
|
||||||
if [ -f "${p}initrd.img" ]; then
|
set devletter=""
|
||||||
initrd ${p}initrd.img
|
set partnum=""
|
||||||
|
for t in ata ahci; do
|
||||||
|
set vmlinuz=""
|
||||||
|
set initrd=""
|
||||||
|
if [ "${t}" = "ata" ] && [ "${grub_scan_disk}" = "ahci" ]; then
|
||||||
|
continue
|
||||||
|
elif [ "${t}" = "ahci" ] && [ "${grub_scan_disk}" = "ata" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
for dev in 0 1 2 3 4 5 6 7 8; do
|
||||||
|
for part in 1 2 3 4 5 6 7 8 9; do
|
||||||
|
set root="${t}${devnum},${partnum}"
|
||||||
|
set devnum="${dev}"
|
||||||
|
set partnum="${part}"
|
||||||
|
for k in /vmlinuz* @/vmlinuz*; do
|
||||||
|
if [ ! -f "${k}" ] || [ ! -d /boot ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
set vmlinuz="${k}"
|
||||||
|
# do not break. if furthe rentries are
|
||||||
|
# available, due to alphabetic sorting,
|
||||||
|
# the next entry is likely a newer
|
||||||
|
# kernel version
|
||||||
|
done
|
||||||
|
for k in /boot/vmlinuz* @/boot/vmlinuz*; do
|
||||||
|
if [ "${vmlinuz}" != "" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
set vmlinuz="${k}"
|
||||||
|
done
|
||||||
|
if [ "${vmlinuz}" = "" ]; then
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
|
for i in /initrd* /initramfs* @/initrd* @/initramfs*; do
|
||||||
|
if [ ! -f "${i}" ] || [ ! -d "/boot" ]; then
|
||||||
|
continue
|
||||||
|
done
|
||||||
|
set initrd="${i}"
|
||||||
|
# ditto. do not break yet
|
||||||
|
done
|
||||||
|
for i in /boot/initrd* /boot/initramfs* @/boot/initrd* @/boot/initramfs*; do
|
||||||
|
if [ "${initrd}" != "" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
set initrd="${i}"
|
||||||
|
done
|
||||||
|
if [ "${vmlinuz}" != "" ] && [ "${initrd}" != "" ]; then
|
||||||
|
set devtype="${t}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
set vmlinuz=""
|
||||||
|
set initrd=""
|
||||||
|
done
|
||||||
|
if [ "${vmlinuz}" != "" ] && [ "${initrd}" != "" ]; then
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
if [ "${vmlinuz}" != "" ] && [ "${initrd}" != "" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ "${grub_scan_disk}" != "ahci" ]; then
|
if [ "${vmlinuz}" = "" ] || [ "${initrd}" = "" ]; then
|
||||||
# Last resort (for setups that use IDE instead of SATA)
|
return
|
||||||
set root=ata0,1
|
|
||||||
for p in / /boot/; do
|
|
||||||
if [ -f "${p}vmlinuz" ]; then
|
|
||||||
linux ${p}vmlinuz root=/dev/sda1 rw
|
|
||||||
if [ -f "${p}initrd.img" ]; then
|
|
||||||
initrd ${p}initrd.img
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
if [ "${devnum}" = "0" ]; then
|
||||||
|
set devletter="a"
|
||||||
|
elif [ "${devnum}" = "1" ]; then
|
||||||
|
set devletter="b"
|
||||||
|
elif [ "${devnum}" = "2" ]; then
|
||||||
|
set devletter="c"
|
||||||
|
elif [ "${devnum}" = "3" ]; then
|
||||||
|
set devletter="d"
|
||||||
|
elif [ "${devnum}" = "4" ]; then
|
||||||
|
set devletter="e"
|
||||||
|
elif [ "${devnum}" = "5" ]; then
|
||||||
|
set devletter="f"
|
||||||
|
elif [ "${devnum}" = "6" ]; then
|
||||||
|
set devletter="g"
|
||||||
|
elif [ "${devnum}" = "7" ]; then
|
||||||
|
set devletter="h"
|
||||||
|
elif [ "${devnum}" = "8" ]; then
|
||||||
|
set devletter="i"
|
||||||
|
fi
|
||||||
|
set btrfsvol=""
|
||||||
|
if [ "${vmlinuz#@}" != "${vmlinuz}" ]; then
|
||||||
|
set btrfsvol="rootflags=subvol=@"
|
||||||
|
fi
|
||||||
|
set root="${devtype}${devnum},${partnum}"
|
||||||
|
linux ${vmlinuz} root=/dev/sd${devletter}${partnum} ${btrfsvol} rw
|
||||||
|
initrd ${initrd}
|
||||||
|
|
||||||
true # Prevent pager requiring to accept each line instead of whole screen
|
true # Prevent pager requiring to accept each line instead of whole screen
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue