grubtest.cfg 4.4 KB

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