grub.cfg 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 part_msdos
  9. insmod ext2
  10. insmod lvm
  11. insmod gcry_rijndael
  12. insmod gcry_sha256
  13. insmod luks
  14. insmod cryptodisk
  15. # insmod usbserial_pl2303
  16. # insmod usbserial_ftdi
  17. # insmod usbserial_usbdebug
  18. insmod gfxmenu
  19. insmod gfxterm_menu
  20. insmod gfxterm_background
  21. insmod chain
  22. insmod jpeg
  23. # Serial and keyboard configuration, very important.
  24. # serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
  25. # terminal_input --append serial
  26. # terminal_output --append serial
  27. terminal_input --append at_keyboard
  28. terminal_output --append cbmemc
  29. gfxpayload=keep
  30. terminal_output --append gfxterm
  31. set menu_color_normal=white/black
  32. set menu_color_highlight=white/cyan
  33. # Default to first option, automatically boot after 1 second
  34. set default="0>0"
  35. set timeout=1
  36. # This is useful when using 'cat' on long files on GRUB terminal
  37. set pager=1
  38. # Set a background image from CBFS
  39. background_image (cbfsdisk)/background.jpg
  40. # Set DejaVu Sans Mono as the default font
  41. loadfont (cbfsdisk)/dejavusansmono.pf2
  42. # Default keymap
  43. keymap usqwerty
  44. function try_user_config {
  45. set root="${1}"
  46. for dir in boot grub grub2 boot/grub boot/grub2; do
  47. for name in '' autoboot_ libreboot_ coreboot_; do
  48. if [ -f /"${dir}"/"${name}"grub.cfg ]; then
  49. unset superusers
  50. configfile /"${dir}"/"${name}"grub.cfg
  51. fi
  52. done
  53. done
  54. }
  55. function search_grub {
  56. for i in 0 1; do
  57. # raw devices
  58. try_user_config "(${1}${i})"
  59. for part in 1 2 3 4 5; do
  60. # MBR/GPT partitions
  61. try_user_config "(${1}${i},${part})"
  62. done
  63. done
  64. }
  65. function try_isolinux_config {
  66. set root="${1}"
  67. for dir in '' /boot; do
  68. if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
  69. syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
  70. elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
  71. syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
  72. fi
  73. done
  74. }
  75. function search_isolinux {
  76. for i in 0 1; do
  77. # raw devices
  78. try_isolinux_config "(${1}${i})"
  79. for part in 1 2 3 4 5; do
  80. # MBR/GPT partitions
  81. try_isolinux_config "(${1}${i},${part})"
  82. done
  83. done
  84. }
  85. menuentry 'Qubes, with Xen hypervisor' --class qubes --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-simple-1c874f0f-b41d-4120-8058-b327554c11bf' {
  86. set root='hd0,msdos1'
  87. if [ x$feature_platform_search_hint = xy ]; then
  88. search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 55e7e06a-cad4-4a8d-ba89-9205493e87d7
  89. else
  90. search --no-floppy --fs-uuid --set=root 55e7e06a-cad4-4a8d-ba89-9205493e87d7
  91. fi
  92. echo 'Loading Xen 4.8.3 ...'
  93. if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
  94. xen_rm_opts=
  95. else
  96. xen_rm_opts="no-real-mode edd=off"
  97. fi
  98. multiboot /xen-4.8.3.gz placeholder console=none dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ${xen_rm_opts}
  99. echo 'Loading Linux 4.14.18-1.pvops.qubes.x86_64 ...'
  100. module /vmlinuz-4.14.18-1.pvops.qubes.x86_64 placeholder iomem=relaxed root=/dev/mapper/qubes_dom0-root ro rd.luks.uuid=luks-8453f049-6322-4e5d-b05a-a6c4688fd3a5 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.preliminary_hw_support=1 rhgb quiet rd.qubes.hide_all_usb
  101. echo 'Loading initial ramdisk ...'
  102. module --nounzip /initramfs-4.14.18-1.pvops.qubes.x86_64.img
  103. }
  104. menuentry 'Qubes, with Xen hypervisor FDE' --class qubes --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-simple-1c874f0f-b41d-4120-8058-b327554c11bf' {
  105. cryptomount -a
  106. set root='lvm/qubes_dom0-boot'
  107. if [ x$feature_platform_search_hint = xy ]; then
  108. search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 55e7e06a-cad4-4a8d-ba89-9205493e87d7
  109. else
  110. search --no-floppy --fs-uuid --set=root 55e7e06a-cad4-4a8d-ba89-9205493e87d7
  111. fi
  112. echo 'Loading Xen 4.8.3 ...'
  113. if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
  114. xen_rm_opts=
  115. else
  116. xen_rm_opts="no-real-mode edd=off"
  117. fi
  118. multiboot /xen-4.8.3.gz placeholder console=none dom0_mem=min:1024M dom0_mem=max:4096M iommu=no-igfx ${xen_rm_opts}
  119. echo 'Loading Linux 4.14.18-1.pvops.qubes.x86_64 ...'
  120. module /vmlinuz-4.14.18-1.pvops.qubes.x86_64 placeholder iomem=relaxed root=/dev/mapper/qubes_dom0-root ro rd.luks.uuid=luks-8453f049-6322-4e5d-b05a-a6c4688fd3a5 rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.preliminary_hw_support=1 rhgb quiet rd.qubes.hide_all_usb
  121. echo 'Loading initial ramdisk ...'
  122. module --nounzip /initramfs-4.14.18-1.pvops.qubes.x86_64.img
  123. }
  124. submenu 'Boot from a LUKS+LVM setup [l]' --hotkey='l' {
  125. menuentry 'Linux-libre kernel' {
  126. cryptomount -a
  127. set root='lvm/matrix-system'
  128. linux /boot/vmlinuz-linux-libre root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  129. initrd /boot/initramfs-linux-libre.img
  130. }
  131. menuentry 'Linux-libre-lts kernel' {
  132. cryptomount -a
  133. set root='lvm/matrix-system'
  134. linux /boot/vmlinuz-linux-libre-lts root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  135. initrd /boot/initramfs-linux-libre-lts.img
  136. }
  137. menuentry 'Linux-libre-grsec kernel' {
  138. cryptomount -a
  139. set root='lvm/matrix-system'
  140. linux /boot/vmlinuz-linux-libre-grsec root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  141. initrd /boot/initramfs-linux-libre-grsec.img
  142. }
  143. menuentry 'Linux kernel' {
  144. cryptomount -a
  145. set root='lvm/matrix-system'
  146. linux /boot/vmlinuz-linux root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  147. initrd /boot/initramfs-linux.img
  148. }
  149. menuentry 'Linux-lts kernel' {
  150. cryptomount -a
  151. set root='lvm/matrix-system'
  152. linux /boot/vmlinuz-linux-lts root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  153. initrd /boot/initramfs-linux-lts.img
  154. }
  155. menuentry 'Linux-grsec kernel' {
  156. cryptomount -a
  157. set root='lvm/matrix-system'
  158. linux /boot/vmlinuz-linux-grsec root=/dev/matrix/system cryptdevice=/dev/sda1:lvm cryptkey=rootfs:/etc/keyfile resume=/dev/mapper/matrix-swap
  159. initrd /boot/initramfs-linux-grsec.img
  160. }
  161. }
  162. menuentry 'Load operating system from HDD [o]' --hotkey='o' {
  163. # GRUB2 handles (almost) every possible disk setup, but only the location of
  164. # /boot is actually important since GRUB2 only loads the user's config.
  165. # LVM, RAID, filesystems and encryption on both raw devices and partitions in
  166. # all various combinations need to be supported. Since full disk encryption is
  167. # possible with GRUB2 as payload and probably even used by most users, this
  168. # configuration tries to load the operating system in the following way:
  169. # 1. Look for user configuration on unencrypted devices first to avoid
  170. # unnecessary decryption routines in the following order:
  171. # 1) raw devices and MBR/GPT partitions
  172. search_grub ahci
  173. search_grub ata
  174. # 2) LVM and RAID which might be used accross multiple devices
  175. lvm="lvm/matrix-rootvol lvm/matrix-boot"
  176. raid="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"
  177. for vol in ${lvm} ${raid}; do
  178. try_user_config "(${vol})"
  179. done
  180. # 2. In case no configuration could be found, try decrypting devices. Look
  181. # on raw crypto devices as well as inside LVM volumes this time.
  182. # The user will be prompted for a passphrase if a LUKS header was found.
  183. for dev in ahci0 ata0 ${lvm}; do
  184. cryptomount "(${dev})"
  185. done
  186. # 3) encrypted devices/partitions
  187. for i in 0 1; do
  188. for part in 1 2 3 4 5; do
  189. for type in ahci ata; do
  190. cryptomount "(${type}${i},${part})"
  191. done
  192. done
  193. done
  194. # 3) encrypted devices/partitions
  195. search_grub crypto
  196. # 4) LVM inside LUKS containers
  197. for vol in ${lvm}; do
  198. try_user_config "(${vol})"
  199. done
  200. # Last resort, if all else fails
  201. set root=ahci0,1
  202. for p in / /boot/; do
  203. if [ -f "${p}vmlinuz" ]; then
  204. linux ${p}vmlinuz root=/dev/sda1 rw
  205. if [ -f "${p}initrd.img" ]; then
  206. initrd ${p}initrd.img
  207. fi
  208. fi
  209. done
  210. # Last resort (for GA-G41-ES2L which uses IDE emulation mode for SATA)
  211. set root=ata0,1
  212. for p in / /boot/; do
  213. if [ -f "${p}vmlinuz" ]; then
  214. linux ${p}vmlinuz root=/dev/sda1 rw
  215. if [ -f "${p}initrd.img" ]; then
  216. initrd ${p}initrd.img
  217. fi
  218. fi
  219. done
  220. }
  221. submenu 'Search for systems on external media [u]' --hotkey="u" {
  222. menuentry 'Search ISOLINUX menu (USB) [u]' --hotkey='u' {
  223. search_isolinux usb
  224. }
  225. menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' {
  226. search_isolinux ahci
  227. }
  228. menuentry 'Search ISOLINUX menu (CD/DVD) [d]' --hotkey='d' {
  229. insmod ata
  230. for dev in ata0 ata1 ata2 ata3 ahci1; do
  231. try_isolinux_config "(${dev})"
  232. done
  233. }
  234. menuentry 'Search for GRUB2 configuration on external media [s]' --hotkey='s' {
  235. search_grub usb
  236. }
  237. menuentry 'Load test configuration (grubtest.cfg) inside of CBFS [t]' --hotkey='t' {
  238. set root='(cbfsdisk)'
  239. configfile /grubtest.cfg
  240. }
  241. menuentry 'Chainload bootloader on external media [c]' --hotkey='c' {
  242. set root='(usb0)'
  243. chainloader +1
  244. }
  245. }
  246. menuentry 'Reboot [r]' --hotkey='r' {
  247. reboot
  248. }
  249. menuentry 'Poweroff [p]' --hotkey='p' {
  250. halt
  251. }