From 16aeb473f44dea2b1a32a337f2603ad3f3146079 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sun, 30 Jul 2017 03:43:33 -0400 Subject: Add GRUB txtmode/vesafb-specific grub{,test}.cfg Files AUTHORS and COPYING were copied to new install directories in projects/grub/install in order to keep those notices as close to the relevant files as possible (as was before). --- projects/grub/install/txtmode/grubtest.cfg | 165 +++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 projects/grub/install/txtmode/grubtest.cfg (limited to 'projects/grub/install/txtmode/grubtest.cfg') diff --git a/projects/grub/install/txtmode/grubtest.cfg b/projects/grub/install/txtmode/grubtest.cfg new file mode 100644 index 00000000..c979d4a5 --- /dev/null +++ b/projects/grub/install/txtmode/grubtest.cfg @@ -0,0 +1,165 @@ +set prefix=(memdisk)/boot/grub + +insmod nativedisk +insmod ehci +insmod ohci +insmod uhci +insmod usb +insmod usbms +insmod usbserial_pl2303 +insmod usbserial_ftdi +insmod usbserial_usbdebug + +# Serial and keyboard configuration, very important. +serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 +terminal_input --append serial +terminal_output --append serial +terminal_input --append at_keyboard +terminal_output --append cbmemc + +gfxpayload=keep +terminal_output --append gfxterm + +# Default to first option, automatically boot after 1 second +set default="0" +set timeout=1 + +# This is useful when using 'cat' on long files on GRUB terminal +set pager=1 + +function try_user_config { + set root="${1}" + for dir in boot grub grub2 boot/grub boot/grub2; do + for name in libreboot_ autoboot_ librecore_ coreboot_ ''; do + if [ -f /"${dir}"/"${name}"grub.cfg ]; then + unset superusers + configfile /"${dir}"/"${name}"grub.cfg + fi + done + done +} +function search_grub { + for i in 0 1; do + # raw devices + try_user_config "(${1}${i})" + for part in 1 2 3 4 5; do + # MBR/GPT partitions + try_user_config "(${1}${i},${part})" + done + done +} +function try_isolinux_config { + set root="${1}" + for dir in '' /boot; do + if [ -f "${dir}"/isolinux/isolinux.cfg ]; then + syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg + elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then + syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg + fi + done +} +function search_isolinux { + for i in 0 1; do + # raw devices + try_isolinux_config "(${1}${i})" + for part in 1 2 3 4 5; do + # MBR/GPT partitions + try_isolinux_config "(${1}${i},${part})" + done + done +} +menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { +# GRUB2 handles (almost) every possible disk setup, but only the location of +# /boot is actually important since GRUB2 only loads the user's config. + +# LVM, RAID, filesystems and encryption on both raw devices and partitions in +# all various combinations need to be supported. Since full disk encryption is +# possible with GRUB2 as payload and probably even used by most users, this +# configuration tries to load the operating system in the following way: + +# 1. Look for user configuration on unencrypted devices first to avoid +# unnecessary decryption routines in the following order: + +# 1) raw devices and MBR/GPT partitions + search_grub ahci + search_grub ata +# 2) LVM and RAID which might be used accross multiple devices + lvm="lvm/matrix-rootvol lvm/matrix-boot" + raid="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9" + for vol in ${lvm} ${raid}; do + try_user_config "(${vol})" + done +# 2. In case no configuration could be found, try decrypting devices. Look +# on raw crypto devices as well as inside LVM volumes this time. + +# The user will be prompted for a passphrase if a LUKS header was found. + for dev in ahci0 ata0 usb0 ${lvm}; do + cryptomount "(${dev})" + done +# 3) encrypted devices/partitions + for i in 0 1; do + for part in 1 2 3 4 5; do + for type in ahci ata; do + cryptomount "(${type}${i},${part})" + done + done + done + +# 3) encrypted devices/partitions + search_grub crypto +# 4) LVM inside LUKS containers + for vol in ${lvm}; do + try_user_config "(${vol})" + done + + # Last resort, if all else fails + set root=ahci0,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 + + # Last resort (for GA-G41-ES2L which uses IDE emulation mode for SATA) + 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 +} +menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' { + search_isolinux ahci +} +menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' { + search_isolinux usb +} +menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { + insmod ata + for dev in ata0 ata1 ata2 ata3 ahci1; do + try_isolinux_config "(${dev})" + done +} +menuentry 'Load standard configuration (grub.cfg) inside of CBFS [t]' --hotkey='t' { + set root='(cbfsdisk)' + configfile /grub.cfg +} +menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { + search_grub usb +} +menuentry 'Poweroff [p]' --hotkey='p' { + halt +} +menuentry 'Reboot [r]' --hotkey='r' { + reboot +} +menuentry 'Load MemTest86+ [m]' --hotkey='m' { + set root='memdisk' + linux16 /memtest.bin +} -- cgit v1.2.3-70-g09d2 From 6d0cb7a80b6c564e272e770783897772e5aeb8b8 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Sun, 30 Jul 2017 03:52:03 -0400 Subject: Make minor formatting changes to GRUB config files --- projects/grub/install/txtmode/grub.cfg | 12 ++++++++++++ projects/grub/install/txtmode/grubtest.cfg | 12 ++++++++++++ projects/grub/install/vesafb/grub.cfg | 21 ++++++++++++++++----- projects/grub/install/vesafb/grubtest.cfg | 21 ++++++++++++++++----- 4 files changed, 56 insertions(+), 10 deletions(-) (limited to 'projects/grub/install/txtmode/grubtest.cfg') diff --git a/projects/grub/install/txtmode/grub.cfg b/projects/grub/install/txtmode/grub.cfg index 34d2a09a..329be946 100644 --- a/projects/grub/install/txtmode/grub.cfg +++ b/projects/grub/install/txtmode/grub.cfg @@ -38,6 +38,7 @@ function try_user_config { done done } + function search_grub { for i in 0 1; do # raw devices @@ -48,6 +49,7 @@ function search_grub { done done } + function try_isolinux_config { set root="${1}" for dir in '' /boot; do @@ -58,6 +60,7 @@ function try_isolinux_config { fi done } + function search_isolinux { for i in 0 1; do # raw devices @@ -68,6 +71,7 @@ function search_isolinux { done done } + menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB2 handles (almost) every possible disk setup, but only the location of # /boot is actually important since GRUB2 only loads the user's config. @@ -134,31 +138,39 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o fi done } + menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' { search_isolinux ahci } + menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' { search_isolinux usb } + menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata for dev in ata0 ata1 ata2 ata3 ahci1; do try_isolinux_config "(${dev})" done } + menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' { set root='(cbfsdisk)' configfile /grubtest.cfg } + menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } + menuentry 'Poweroff [p]' --hotkey='p' { halt } + menuentry 'Reboot [r]' --hotkey='r' { reboot } + menuentry 'Load MemTest86+ [m]' --hotkey='m' { set root='memdisk' linux16 /memtest.bin diff --git a/projects/grub/install/txtmode/grubtest.cfg b/projects/grub/install/txtmode/grubtest.cfg index c979d4a5..db12a1d8 100644 --- a/projects/grub/install/txtmode/grubtest.cfg +++ b/projects/grub/install/txtmode/grubtest.cfg @@ -38,6 +38,7 @@ function try_user_config { done done } + function search_grub { for i in 0 1; do # raw devices @@ -48,6 +49,7 @@ function search_grub { done done } + function try_isolinux_config { set root="${1}" for dir in '' /boot; do @@ -58,6 +60,7 @@ function try_isolinux_config { fi done } + function search_isolinux { for i in 0 1; do # raw devices @@ -68,6 +71,7 @@ function search_isolinux { done done } + menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB2 handles (almost) every possible disk setup, but only the location of # /boot is actually important since GRUB2 only loads the user's config. @@ -134,31 +138,39 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o fi done } + menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' { search_isolinux ahci } + menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' { search_isolinux usb } + menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata for dev in ata0 ata1 ata2 ata3 ahci1; do try_isolinux_config "(${dev})" done } + menuentry 'Load standard configuration (grub.cfg) inside of CBFS [t]' --hotkey='t' { set root='(cbfsdisk)' configfile /grub.cfg } + menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } + menuentry 'Poweroff [p]' --hotkey='p' { halt } + menuentry 'Reboot [r]' --hotkey='r' { reboot } + menuentry 'Load MemTest86+ [m]' --hotkey='m' { set root='memdisk' linux16 /memtest.bin diff --git a/projects/grub/install/vesafb/grub.cfg b/projects/grub/install/vesafb/grub.cfg index c2c14356..40061053 100644 --- a/projects/grub/install/vesafb/grub.cfg +++ b/projects/grub/install/vesafb/grub.cfg @@ -9,6 +9,7 @@ insmod usbms insmod usbserial_pl2303 insmod usbserial_ftdi insmod usbserial_usbdebug +insmod png # Serial and keyboard configuration, very important. serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 @@ -20,16 +21,16 @@ terminal_output --append cbmemc gfxpayload=keep terminal_output --append gfxterm +# Prettify GRUB +background_image (cbfsdisk)/background.png +loadfont (memdisk)/dejavusansmono.pf2 + # Default to first option, automatically boot after 1 second set default="0" set timeout=1 # This is useful when using 'cat' on long files on GRUB terminal set pager=1 -insmod png - -background_image (cbfsdisk)/background.png -loadfont (memdisk)/dejavusansmono.pf2 function try_user_config { set root="${1}" @@ -42,6 +43,7 @@ function try_user_config { done done } + function search_grub { for i in 0 1; do # raw devices @@ -52,6 +54,7 @@ function search_grub { done done } + function try_isolinux_config { set root="${1}" for dir in '' /boot; do @@ -62,6 +65,7 @@ function try_isolinux_config { fi done } + function search_isolinux { for i in 0 1; do # raw devices @@ -72,6 +76,7 @@ function search_isolinux { done done } + menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB2 handles (almost) every possible disk setup, but only the location of # /boot is actually important since GRUB2 only loads the user's config. @@ -138,29 +143,35 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o fi done } + menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' { search_isolinux ahci } + menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' { search_isolinux usb } + menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata for dev in ata0 ata1 ata2 ata3 ahci1; do try_isolinux_config "(${dev})" done } + menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' { set root='(cbfsdisk)' configfile /grubtest.cfg } + menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } + menuentry 'Poweroff [p]' --hotkey='p' { halt } + menuentry 'Reboot [r]' --hotkey='r' { reboot } - diff --git a/projects/grub/install/vesafb/grubtest.cfg b/projects/grub/install/vesafb/grubtest.cfg index bd6f4560..d0e0b46e 100644 --- a/projects/grub/install/vesafb/grubtest.cfg +++ b/projects/grub/install/vesafb/grubtest.cfg @@ -9,6 +9,7 @@ insmod usbms insmod usbserial_pl2303 insmod usbserial_ftdi insmod usbserial_usbdebug +insmod png # Serial and keyboard configuration, very important. serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 @@ -20,16 +21,16 @@ terminal_output --append cbmemc gfxpayload=keep terminal_output --append gfxterm +# Prettify GRUB +background_image (cbfsdisk)/background.png +loadfont (memdisk)/dejavusansmono.pf2 + # Default to first option, automatically boot after 1 second set default="0" set timeout=1 # This is useful when using 'cat' on long files on GRUB terminal set pager=1 -insmod png - -background_image (cbfsdisk)/background.png -loadfont (memdisk)/dejavusansmono.pf2 function try_user_config { set root="${1}" @@ -42,6 +43,7 @@ function try_user_config { done done } + function search_grub { for i in 0 1; do # raw devices @@ -52,6 +54,7 @@ function search_grub { done done } + function try_isolinux_config { set root="${1}" for dir in '' /boot; do @@ -62,6 +65,7 @@ function try_isolinux_config { fi done } + function search_isolinux { for i in 0 1; do # raw devices @@ -72,6 +76,7 @@ function search_isolinux { done done } + menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB2 handles (almost) every possible disk setup, but only the location of # /boot is actually important since GRUB2 only loads the user's config. @@ -138,29 +143,35 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o fi done } + menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' { search_isolinux ahci } + menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' { search_isolinux usb } + menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata for dev in ata0 ata1 ata2 ata3 ahci1; do try_isolinux_config "(${dev})" done } + menuentry 'Load standard configuration (grub.cfg) inside of CBFS [t]' --hotkey='t' { set root='(cbfsdisk)' configfile /grub.cfg } + menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } + menuentry 'Poweroff [p]' --hotkey='p' { halt } + menuentry 'Reboot [r]' --hotkey='r' { reboot } - -- cgit v1.2.3-70-g09d2 From df551a9b84016b9cf0f77d9a59999d055ee0885a Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 31 Jul 2017 00:31:01 -0400 Subject: Load MemTest86+ from cbfsdisk instead of memdisk This makes generating grub.elf more straightforward by not having to make separate ELF files for txtmode and vesafb just because of MemTest86+. --- projects/grub/install/txtmode/grub.cfg | 3 +-- projects/grub/install/txtmode/grubtest.cfg | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'projects/grub/install/txtmode/grubtest.cfg') diff --git a/projects/grub/install/txtmode/grub.cfg b/projects/grub/install/txtmode/grub.cfg index 329be946..17c09e63 100644 --- a/projects/grub/install/txtmode/grub.cfg +++ b/projects/grub/install/txtmode/grub.cfg @@ -172,6 +172,5 @@ menuentry 'Reboot [r]' --hotkey='r' { } menuentry 'Load MemTest86+ [m]' --hotkey='m' { - set root='memdisk' - linux16 /memtest.bin + linux16 (cbfsdisk)/memtest.bin } diff --git a/projects/grub/install/txtmode/grubtest.cfg b/projects/grub/install/txtmode/grubtest.cfg index db12a1d8..c957dd49 100644 --- a/projects/grub/install/txtmode/grubtest.cfg +++ b/projects/grub/install/txtmode/grubtest.cfg @@ -172,6 +172,5 @@ menuentry 'Reboot [r]' --hotkey='r' { } menuentry 'Load MemTest86+ [m]' --hotkey='m' { - set root='memdisk' - linux16 /memtest.bin + linux16 (cbfsdisk)/memtest.bin } -- cgit v1.2.3-70-g09d2 From fd6ce61d732b8b9b13d29e72ce6455b8fc6cb603 Mon Sep 17 00:00:00 2001 From: Andrew Robbins Date: Mon, 31 Jul 2017 01:00:58 -0400 Subject: Adjust placement of MemTest86+ GRUB menu entry --- projects/grub/install/txtmode/grub.cfg | 8 ++++---- projects/grub/install/txtmode/grubtest.cfg | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'projects/grub/install/txtmode/grubtest.cfg') diff --git a/projects/grub/install/txtmode/grub.cfg b/projects/grub/install/txtmode/grub.cfg index 17c09e63..c668544b 100644 --- a/projects/grub/install/txtmode/grub.cfg +++ b/projects/grub/install/txtmode/grub.cfg @@ -163,6 +163,10 @@ menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } +menuentry 'Load MemTest86+ [m]' --hotkey='m' { + linux16 (cbfsdisk)/memtest.bin +} + menuentry 'Poweroff [p]' --hotkey='p' { halt } @@ -170,7 +174,3 @@ menuentry 'Poweroff [p]' --hotkey='p' { menuentry 'Reboot [r]' --hotkey='r' { reboot } - -menuentry 'Load MemTest86+ [m]' --hotkey='m' { - linux16 (cbfsdisk)/memtest.bin -} diff --git a/projects/grub/install/txtmode/grubtest.cfg b/projects/grub/install/txtmode/grubtest.cfg index c957dd49..6ffeace7 100644 --- a/projects/grub/install/txtmode/grubtest.cfg +++ b/projects/grub/install/txtmode/grubtest.cfg @@ -163,6 +163,10 @@ menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' { search_grub usb } +menuentry 'Load MemTest86+ [m]' --hotkey='m' { + linux16 (cbfsdisk)/memtest.bin +} + menuentry 'Poweroff [p]' --hotkey='p' { halt } @@ -170,7 +174,3 @@ menuentry 'Poweroff [p]' --hotkey='p' { menuentry 'Reboot [r]' --hotkey='r' { reboot } - -menuentry 'Load MemTest86+ [m]' --hotkey='m' { - linux16 (cbfsdisk)/memtest.bin -} -- cgit v1.2.3-70-g09d2