osdetect.cfg 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. # Sample GRUB script to autodetect operating systems
  2. #
  3. # Copyright (C) 2010 Free Software Foundation, Inc.
  4. #
  5. # GRUB is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # GRUB is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. set saved_root=$root
  18. function freebsd_ufs_variants {
  19. set device=$1
  20. set fstype=$2
  21. set uuid=$3
  22. menuentry "FreeBSD (on $fstype $device)" $device $uuid {
  23. set root=$2
  24. set uuid=$3
  25. freebsd /boot/kernel/kernel
  26. set FreeBSD.acpi_load=YES
  27. set FreeBSD.hint.acpi.0.disabled=0
  28. set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
  29. frebsd_loadenv /boot/device.hints
  30. }
  31. menuentry "FreeBSD (on $fstype $device) (single)" $device $uuid {
  32. set root=$2
  33. set uuid=$3
  34. freebsd /boot/kernel/kernel --single
  35. set FreeBSD.acpi_load=YES
  36. set FreeBSD.hint.acpi.0.disabled=0
  37. set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
  38. frebsd_loadenv /boot/device.hints
  39. }
  40. menuentry "FreeBSD (on $fstype $device) (verbose)" $device $uuid {
  41. set root=$2
  42. set uuid=$3
  43. freebsd /boot/kernel/kernel --verbose
  44. set FreeBSD.acpi_load=YES
  45. set FreeBSD.hint.acpi.0.disabled=0
  46. set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
  47. frebsd_loadenv /boot/device.hints
  48. }
  49. menuentry "FreeBSD (on $fstype $device) (without ACPI)" $device $uuid {
  50. set root=$2
  51. set uuid=$3
  52. freebsd /boot/kernel/kernel --verbose
  53. unset FreeBSD.acpi_load
  54. set FreeBSD.hint.acpi.0.disabled=1
  55. set FreeBSD.loader.acpi_disabled_by_user=1
  56. set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
  57. frebsd_loadenv /boot/device.hints
  58. }
  59. menuentry "FreeBSD (on $fstype $device) (safe mode)" $device $uuid {
  60. set root=$2
  61. set uuid=$3
  62. freebsd /boot/kernel/kernel --verbose
  63. unset FreeBSD.acpi_load
  64. set FreeBSD.hint.acpi.0.disabled=1
  65. set FreeBSD.loader.acpi_disabled_by_user=1
  66. set FreeBSD.hint.apic.0.disabled=1
  67. set FreeBSD.hw.ata.ata_dma=0
  68. set FreeBSD.hw.ata.atapi_dma=0
  69. set FreeBSD.hw.ata.wc=0
  70. set FreeBSD.hw.eisa_slots=0
  71. set FreeBSD.hint.kbdmux.0.disabled=1
  72. set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
  73. frebsd_loadenv /boot/device.hints
  74. }
  75. }
  76. function freebsd_zfs_variants {
  77. set device=$1
  78. set fstype=zfs
  79. menuentry "FreeBSD (on $fstype $device)" $device {
  80. set root=$2
  81. freebsd /@/boot/kernel/kernel
  82. set FreeBSD.acpi_load=YES
  83. set FreeBSD.hint.acpi.0.disabled=0
  84. freebsd_module_elf /@/boot/kernel/opensolaris.ko
  85. freebsd_module_elf /@/boot/kernel/zfs.ko
  86. freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
  87. probe -l -s name $root
  88. set FreeBSD.vfs.root.mountfrom=zfs:$name
  89. freebsd_loadenv /@/boot/device.hints
  90. }
  91. menuentry "FreeBSD (on $fstype $device) (single)" $device {
  92. set root=$2
  93. freebsd /@/boot/kernel/kernel --single
  94. set FreeBSD.acpi_load=YES
  95. set FreeBSD.hint.acpi.0.disabled=0
  96. freebsd_module_elf /@/boot/kernel/opensolaris.ko
  97. freebsd_module_elf /@/boot/kernel/zfs.ko
  98. freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
  99. probe -l -s name $root
  100. set FreeBSD.vfs.root.mountfrom=zfs:$name
  101. freebsd_loadenv /@/boot/device.hints
  102. }
  103. menuentry "FreeBSD (on $fstype $device) (verbose)" $device {
  104. set root=$2
  105. freebsd /@/boot/kernel/kernel --verbose
  106. set FreeBSD.acpi_load=YES
  107. set FreeBSD.hint.acpi.0.disabled=0
  108. freebsd_module_elf /@/boot/kernel/opensolaris.ko
  109. freebsd_module_elf /@/boot/kernel/zfs.ko
  110. freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
  111. probe -l -s name $root
  112. set FreeBSD.vfs.root.mountfrom=zfs:$name
  113. freebsd_loadenv /@/boot/device.hints
  114. }
  115. menuentry "FreeBSD (on $fstype $device) (without ACPI)" $device {
  116. set root=$2
  117. freebsd /@/boot/kernel/kernel --verbose
  118. unset FreeBSD.acpi_load
  119. set FreeBSD.hint.acpi.0.disabled=1
  120. set FreeBSD.loader.acpi_disabled_by_user=1
  121. freebsd_module_elf /@/boot/kernel/opensolaris.ko
  122. freebsd_module_elf /@/boot/kernel/zfs.ko
  123. freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
  124. probe -l -s name $root
  125. set FreeBSD.vfs.root.mountfrom=zfs:$name
  126. freebsd_loadenv /@/boot/device.hints
  127. }
  128. menuentry "FreeBSD (on $fstype $device) (safe mode)" $device {
  129. set root=$2
  130. freebsd /@/boot/kernel/kernel --verbose
  131. unset FreeBSD.acpi_load
  132. set FreeBSD.hint.acpi.0.disabled=1
  133. set FreeBSD.loader.acpi_disabled_by_user=1
  134. set FreeBSD.hint.apic.0.disabled=1
  135. set FreeBSD.hw.ata.ata_dma=0
  136. set FreeBSD.hw.ata.atapi_dma=0
  137. set FreeBSD.hw.ata.wc=0
  138. set FreeBSD.hw.eisa_slots=0
  139. set FreeBSD.hint.kbdmux.0.disabled=1
  140. freebsd_module_elf /@/boot/kernel/opensolaris.ko
  141. freebsd_module_elf /@/boot/kernel/zfs.ko
  142. freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
  143. probe -l -s name $root
  144. set FreeBSD.vfs.root.mountfrom=zfs:$name
  145. freebsd_loadenv /@/boot/device.hints
  146. }
  147. }
  148. insmod regexp
  149. for dev in (*); do
  150. # $device: parenthesis removed from $dev
  151. regexp -s device '\((.*)\)' $dev
  152. # $fstype: filesystem type identified
  153. probe -s fstype -f $dev
  154. # uuid: filesystem UUID
  155. probe -s uuid -u $dev
  156. if test -f ($device)/isolinux/isolinux.cfg ; then
  157. menuentry "ISOLINUX config (on $device)" $device {
  158. set root=$2
  159. syslinux_configfile -i /isolinux/isolinux.cfg
  160. }
  161. fi
  162. if test -f ($device)/bootmgr -a -f ($device)/boot/bcd; then
  163. menuentry "Windows Vista bootmgr (on $device)" $device {
  164. set root=$2
  165. chainloader +1
  166. }
  167. elif test -f ($device)/ntldr -a \
  168. -e ($device)/ntdetect.com -a -f ($device)/boot.ini; then
  169. menuentry "Windows NT/2000/XP loader (on $device)" $device {
  170. set root=$2
  171. regexp -s devnum 'hd([0-9]+)' $root
  172. if test "$devnum" != "0"; then
  173. drivemap -s hd0 $root
  174. fi
  175. chainloader +1
  176. }
  177. elif test -f ($device)/windows/win.com; then
  178. menuentry "Windows 98/ME (on $device)" $device {
  179. set root=$2
  180. regexp -s devnum 'hd([0-9]+)' $root
  181. if test "$devnum" != "0"; then
  182. drivemap -s hd0 $root
  183. fi
  184. chainloader +1
  185. }
  186. elif test -f ($device)/io.sys -a -f ($device)/command.com; then
  187. menuentry "MS-DOS (on $device)" $device {
  188. set root=$2
  189. regexp -s devnum 'hd([0-9]+)' $root
  190. if test "$devnum" != "0"; then
  191. drivemap -s hd0 $root
  192. fi
  193. chainloader +1
  194. }
  195. elif test -f ($device)/kernel.sys; then
  196. menuentry "FreeDOS (on $device)" $device {
  197. set root=$2
  198. regexp -s type '([fh])d[0-9]+' $root
  199. regexp -s devnum '[fh]d([0-9]+)' $root
  200. if test $type = 'h' -a "$devnum" != "0"; then
  201. drivemap -s hd0 $root
  202. fi
  203. chainloader +1
  204. }
  205. elif test "$fstype" = ufs1 -o "$fstype" = ufs2 -a \
  206. -e ($device)/boot/kernel/kernel -a \
  207. -e ($device)/boot/device.hints; then
  208. freebsd_ufs_variants $device $fstype $uuid
  209. elif test "$fstype" = zfs -a \
  210. -e ($device)/@/boot/kernel/kernel -a \
  211. -e ($device)/@/boot/device.hints; then
  212. freebsd_zfs_variants $device
  213. elif test "$fstype" = hfsplus -a -f ($device)/mach_kernel; then
  214. menuentry "Mac OS X/Darwin" $device $uuid {
  215. set root=$2
  216. set uuid=$3
  217. insmod vbe
  218. do_resume=0
  219. if [ /var/vm/sleepimage -nt10 / ]; then
  220. if xnu_resume /var/vm/sleepimage; then
  221. do_resume=1
  222. fi
  223. fi
  224. if [ $do_resume = 1 ]; then
  225. xnu_uuid $uuid uuid
  226. if [ -f /Extra/DSDT.aml ]; then
  227. acpi -e /Extra/DSDT.aml
  228. fi
  229. xnu_kernel /mach_kernel boot-uuid=${uuid} rd=*uuid
  230. if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
  231. xnu_mkext /System/Library/Extensions.mkext
  232. else
  233. xnu_mkext /System/Library/Extensions
  234. fi
  235. if [ -f /Extra/Extensions.mkext ]; then
  236. xnu_mkext /Extra/Extensions.mkext
  237. fi
  238. if [ -d /Extra/Extensions ]; then
  239. xnu_kextdir /Extra/Extensions
  240. fi
  241. if [ -f /Extra/devtree.txt ]; then
  242. xnu_devtree /Extra/devtree.txt
  243. fi
  244. if [ -f /Extra/splash.jpg ]; then
  245. insmod jpeg
  246. xnu_splash /Extra/splash.jpg
  247. fi
  248. if [ -f /Extra/splash.png ]; then
  249. insmod png
  250. xnu_splash /Extra/splash.png
  251. fi
  252. if [ -f /Extra/splash.tga ]; then
  253. insmod tga
  254. xnu_splash /Extra/splash.tga
  255. fi
  256. fi
  257. }
  258. else
  259. set root=$device
  260. for file in /boot/vmlinuz-* /boot/linux-*; do
  261. if test -f $file; then
  262. regexp -s version '/boot/vmlinuz-(.*)' $file
  263. regexp -s version '/boot/linux-(.*)' $file
  264. menuentry "Linux $file" $device $uuid $file $version {
  265. set root=$2
  266. set uuid=$3
  267. set kernel=$4
  268. set version=$5
  269. linux $kernel root=UUID=$uuid ro
  270. if test -f /boot/initrd-$version.img; then
  271. initrd /boot/initrd-$version.img
  272. elif test -f /boot/initrd.img-$version; then
  273. initrd /boot/initrd.img-$version
  274. elif test -f /boot/initrd-$version; then
  275. initrd /boot/initrd-$version
  276. fi
  277. }
  278. menuentry "Linux $file (single)" $device $uuid $file $version {
  279. set root=$2
  280. set uuid=$3
  281. set kernel=$4
  282. set version=$5
  283. linux $kernel root=UUID=$uuid ro single
  284. if test -f /boot/initrd-$version.img; then
  285. initrd /boot/initrd-$version.img
  286. elif test -f /boot/initrd.img-$version; then
  287. initrd /boot/initrd.img-$version
  288. elif test -f /boot/initrd-$version; then
  289. initrd /boot/initrd-$version
  290. fi
  291. }
  292. fi
  293. done
  294. fi
  295. done
  296. set root=$saved_root