libreboot

my branch of libreboot
git clone git://git.hazbo.co.uk/libreboot.git
Log | Files | Refs | README

common.cfg (3895B)


      1 function try_user_config {
      2 	set root="${1}"
      3 	for dir in boot grub grub2 boot/grub boot/grub2; do
      4 		for name in libreboot_ autoboot_ librecore_ coreboot_ ''; do
      5 			if [ -f /"${dir}"/"${name}"grub.cfg ]; then
      6                 unset superusers
      7 				configfile /"${dir}"/"${name}"grub.cfg
      8 			fi
      9 		done
     10 	done
     11 }
     12 function search_grub {
     13 	for i in 0 1; do
     14 		# raw devices
     15 		try_user_config "(${1}${i})"
     16 		for part in 1 2 3 4 5; do
     17 			# MBR/GPT partitions
     18 			try_user_config "(${1}${i},${part})"
     19 		done
     20 	done
     21 }
     22 function try_isolinux_config {
     23 	set root="${1}"
     24 	for dir in '' /boot; do
     25 		if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
     26 			syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
     27 		elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
     28 			syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
     29 		fi
     30 	done
     31 }
     32 function search_isolinux {
     33 	for i in 0 1; do
     34 		# raw devices
     35 		try_isolinux_config "(${1}${i})"
     36 		for part in 1 2 3 4 5; do
     37 			# MBR/GPT partitions
     38 			try_isolinux_config "(${1}${i},${part})"
     39 		done
     40 	done
     41 }
     42 menuentry 'Load Operating System (incl. fully encrypted disks)  [o]' --hotkey='o' {
     43 # GRUB2 handles (almost) every possible disk setup, but only the location of
     44 # /boot is actually important since GRUB2 only loads the user's config.
     45 
     46 # LVM, RAID, filesystems and encryption on both raw devices and partitions in
     47 # all various combinations need to be supported. Since full disk encryption is
     48 # possible with GRUB2 as payload and probably even used by most users, this
     49 # configuration tries to load the operating system in the following way:
     50 
     51 # 1. Look for user configuration on unencrypted devices first to avoid
     52 # unnecessary decryption routines in the following order:
     53 
     54 #	1) raw devices and MBR/GPT partitions
     55 	search_grub ahci
     56     search_grub ata
     57 #	2) LVM and RAID which might be used accross multiple devices
     58 	lvm="lvm/matrix-rootvol lvm/matrix-boot"
     59 	raid="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"
     60 	for vol in ${lvm} ${raid}; do
     61 		try_user_config "(${vol})"
     62 	done
     63 # 2. In case no configuration could be found, try decrypting devices. Look
     64 # on raw crypto devices as well as inside LVM volumes this time.
     65 
     66 #	The user will be prompted for a passphrase if a LUKS header was found.
     67 	for dev usb1 usb0 ahci1 ahci0 ata1 ata0 ${lvm}; do
     68 		cryptomount "(${dev})"
     69 	done
     70 #	3) encrypted devices/partitions
     71 	for i in 1 0; do
     72 		for part in 1 2 3 4 5; do
     73             for type in usb ahci ata; do
     74     			cryptomount "(${type}${i},${part})"
     75             done
     76 		done
     77 	done
     78 
     79 #	3) encrypted devices/partitions
     80 	search_grub crypto
     81 #	4) LVM inside LUKS containers
     82 	for vol in ${lvm}; do
     83 		try_user_config "(${vol})"
     84 	done
     85 
     86     # Last resort, if all else fails
     87     set root=ahci0,1
     88     for p in / /boot/; do
     89         if [ -f "${p}vmlinuz" ]; then
     90             linux ${p}vmlinuz root=/dev/sda1 rw
     91             if [ -f "${p}initrd.img" ]; then
     92                 initrd ${p}initrd.img
     93             fi
     94         fi
     95     done
     96 
     97     # Last resort (for GA-G41-ES2L which uses IDE emulation mode for SATA)
     98     set root=ata0,1
     99     for p in / /boot/; do
    100         if [ -f "${p}vmlinuz" ]; then
    101             linux ${p}vmlinuz root=/dev/sda1 rw
    102             if [ -f "${p}initrd.img" ]; then
    103                 initrd ${p}initrd.img
    104             fi
    105         fi
    106     done
    107 }
    108 menuentry 'Search ISOLINUX menu (AHCI)  [a]' --hotkey='a' {
    109 	search_isolinux ahci
    110 }
    111 menuentry 'Search ISOLINUX menu (USB)  [u]' --hotkey='u' {
    112 	search_isolinux usb
    113 }
    114 menuentry 'Search ISOLINUX menu (CD/DVD)  [d]' --hotkey='d' {
    115 	insmod ata
    116 	for dev in ata0 ata1 ata2 ata3 ahci1; do
    117 		try_isolinux_config "(${dev})"
    118 	done
    119 }
    120 menuentry 'Load test configuration (grubtest.cfg) inside of CBFS  [t]' --hotkey='t' {
    121 	set root='(cbfsdisk)'
    122 	configfile /grubtest.cfg
    123 }
    124 menuentry 'Search for GRUB2 configuration on external media  [s]' --hotkey='s' {
    125 	search_grub usb
    126 }
    127 menuentry 'Poweroff  [p]' --hotkey='p' {
    128 	halt
    129 }
    130 menuentry 'Reboot  [r]' --hotkey='r' {
    131 	reboot
    132 }