mmga

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

grub.cfg (4594B)


      1 set prefix=(memdisk)/boot/grub
      2 
      3 insmod nativedisk
      4 insmod ehci
      5 insmod ohci
      6 insmod uhci
      7 insmod usb
      8 insmod usbms
      9 insmod usbserial_pl2303
     10 insmod usbserial_ftdi
     11 insmod usbserial_usbdebug
     12 
     13 # Serial and keyboard configuration, very important.
     14 serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
     15 terminal_input --append  serial
     16 terminal_output --append serial
     17 terminal_input --append at_keyboard
     18 terminal_output --append cbmemc
     19 
     20 gfxpayload=keep
     21 terminal_output --append gfxterm
     22 
     23 # Default to first option, automatically boot after 1 second
     24 set default="0"
     25 set timeout=5
     26 
     27 # This is useful when using 'cat' on long files on GRUB terminal
     28 set pager=1
     29 insmod jpeg
     30 
     31 background_image (cbfsdisk)/background.jpg
     32 loadfont (memdisk)/dejavusansmono.pf2
     33 
     34 keymap usqwerty
     35 function try_user_config {
     36 	set root="${1}"
     37 	for dir in boot grub grub2 boot/grub boot/grub2; do
     38 		for name in '' autoboot_ libreboot_ coreboot_; do
     39 			if [ -f /"${dir}"/"${name}"grub.cfg ]; then
     40 				configfile /"${dir}"/"${name}"grub.cfg
     41 			fi
     42 		done
     43 	done
     44 }
     45 function search_grub {
     46 	for i in 0 1 2 3; do
     47 		# raw devices
     48 		try_user_config "(${1}${i})"
     49 		for part in 1 2 3 4 5; do
     50 			# MBR/GPT partitions
     51 			try_user_config "(${1}${i},${part})"
     52 		done
     53 	done
     54 }
     55 function try_isolinux_config {
     56 	set root="${1}"
     57 	for dir in '' /boot; do
     58 		if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
     59 			syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
     60 		elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
     61 			syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
     62 		fi
     63 	done
     64 }
     65 function search_isolinux {
     66 	for i in 0 1; do
     67 		# raw devices
     68 		try_isolinux_config "(${1}${i})"
     69 		for part in 1 2 3 4 5; do
     70 			# MBR/GPT partitions
     71 			try_isolinux_config "(${1}${i},${part})"
     72 		done
     73 	done
     74 }
     75 menuentry 'Load Operating System (incl. fully encrypted disks)  [o]' --hotkey='o' {
     76 # GRUB2 handles (almost) every possible disk setup, but only the location of
     77 # /boot is actually important since GRUB2 only loads the user's config.
     78 
     79 # LVM, RAID, filesystems and encryption on both raw devices and partitions in
     80 # all various combinations need to be supported. Since full disk encryption is
     81 # possible with GRUB2 as payload and probably even used by most users, this
     82 # configuration tries to load the operating system in the following way:
     83 
     84 # 1. Look for user configuration on unencrypted devices first to avoid
     85 # unnecessary decryption routines in the following order:
     86 
     87 #	1) raw devices and MBR/GPT partitions
     88 	search_grub ahci
     89     search_grub ata
     90 #	2) LVM and RAID which might be used accross multiple devices
     91 	lvm="lvm/matrix-rootvol lvm/matrix-boot"
     92 	raid="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"
     93 	for vol in ${lvm} ${raid}; do
     94 		try_user_config "(${vol})"
     95 	done
     96 # 2. In case no configuration could be found, try decrypting devices. Look
     97 # on raw crypto devices as well as inside LVM volumes this time.
     98 
     99 #	The user will be prompted for a passphrase if a LUKS header was found.
    100 	for dev in ahci0 ata0 ${lvm}; do
    101 		cryptomount "(${dev})"
    102 	done
    103 #	3) encrypted devices/partitions
    104 	for i in 0 1; do
    105 		for part in 1 2 3 4 5; do
    106             for type in ahci ata; do
    107     			cryptomount "(${type}${i},${part})"
    108             done
    109 		done
    110 	done
    111 
    112 #	3) encrypted devices/partitions
    113 	search_grub crypto
    114 #	4) LVM inside LUKS containers
    115 	for vol in ${lvm}; do
    116 		try_user_config "(${vol})"
    117 	done
    118 
    119     # Last resort, if all else fails
    120     set root=ahci0,1
    121     for p in / /boot/; do
    122         if [ -f "${p}vmlinuz" ]; then
    123             linux ${p}vmlinuz root=/dev/sda1 rw
    124             if [ -f "${p}initrd.img" ]; then
    125                 initrd ${p}initrd.img
    126             fi
    127         fi
    128     done
    129 
    130     # Last resort (for GA-G41-ES2L which uses IDE emulation mode for SATA)
    131     set root=ata0,1
    132     for p in / /boot/; do
    133         if [ -f "${p}vmlinuz" ]; then
    134             linux ${p}vmlinuz root=/dev/sda1 rw
    135             if [ -f "${p}initrd.img" ]; then
    136                 initrd ${p}initrd.img
    137             fi
    138         fi
    139     done
    140 }
    141 menuentry 'Search ISOLINUX menu (AHCI)  [a]' --hotkey='a' {
    142 	search_isolinux ahci
    143 }
    144 menuentry 'Search ISOLINUX menu (USB)  [u]' --hotkey='u' {
    145 	search_isolinux usb
    146 }
    147 menuentry 'Search ISOLINUX menu (CD/DVD)  [d]' --hotkey='d' {
    148 	insmod ata
    149 	for dev in ata0 ata1 ata2 ata3 ahci1; do
    150 		try_isolinux_config "(${dev})"
    151 	done
    152 }
    153 menuentry 'Load test configuration (grubtest.cfg) inside of CBFS  [t]' --hotkey='t' {
    154 	set root='(cbfsdisk)'
    155 	configfile /grubtest.cfg
    156 }
    157 menuentry 'Search for GRUB2 configuration on external media  [s]' --hotkey='s' {
    158 	search_grub usb
    159 }
    160 menuentry 'Poweroff  [p]' --hotkey='p' {
    161 	halt
    162 }
    163 menuentry 'Reboot  [r]' --hotkey='r' {
    164 	reboot
    165 }
    166