grub.cfg 7.0 KB

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