1
# Sample GRUB script to autodetect operating systems
3
# Copyright (C) 2010 Free Software Foundation, Inc.
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.
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.
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/>.
20
function freebsd_ufs_variants {
25
menuentry "FreeBSD (on $fstype $device)" $device $uuid {
29
freebsd /boot/kernel/kernel
30
set FreeBSD.acpi_load=YES
31
set FreeBSD.hint.acpi.0.disabled=0
32
set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
33
frebsd_loadenv /boot/device.hints
36
menuentry "FreeBSD (on $fstype $device) (single)" $device $uuid {
40
freebsd /boot/kernel/kernel --single
41
set FreeBSD.acpi_load=YES
42
set FreeBSD.hint.acpi.0.disabled=0
43
set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
44
frebsd_loadenv /boot/device.hints
47
menuentry "FreeBSD (on $fstype $device) (verbose)" $device $uuid {
51
freebsd /boot/kernel/kernel --verbose
52
set FreeBSD.acpi_load=YES
53
set FreeBSD.hint.acpi.0.disabled=0
54
set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
55
frebsd_loadenv /boot/device.hints
58
menuentry "FreeBSD (on $fstype $device) (without ACPI)" $device $uuid {
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.vfs.root.mountfrom=ufs:ufsid/$uuid
67
frebsd_loadenv /boot/device.hints
70
menuentry "FreeBSD (on $fstype $device) (safe mode)" $device $uuid {
74
freebsd /boot/kernel/kernel --verbose
75
unset FreeBSD.acpi_load
76
set FreeBSD.hint.acpi.0.disabled=1
77
set FreeBSD.loader.acpi_disabled_by_user=1
78
set FreeBSD.hint.apic.0.disabled=1
79
set FreeBSD.hw.ata.ata_dma=0
80
set FreeBSD.hw.ata.atapi_dma=0
81
set FreeBSD.hw.ata.wc=0
82
set FreeBSD.hw.eisa_slots=0
83
set FreeBSD.hint.kbdmux.0.disabled=1
84
set FreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
85
frebsd_loadenv /boot/device.hints
89
function freebsd_zfs_variants {
93
menuentry "FreeBSD (on $fstype $device)" $device {
96
freebsd /@/boot/kernel/kernel
97
set FreeBSD.acpi_load=YES
98
set FreeBSD.hint.acpi.0.disabled=0
99
freebsd_module_elf /@/boot/kernel/opensolaris.ko
100
freebsd_module_elf /@/boot/kernel/zfs.ko
101
freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
102
probe -l -s name $root
103
set FreeBSD.vfs.root.mountfrom=zfs:$name
104
freebsd_loadenv /@/boot/device.hints
107
menuentry "FreeBSD (on $fstype $device) (single)" $device {
110
freebsd /@/boot/kernel/kernel --single
111
set FreeBSD.acpi_load=YES
112
set FreeBSD.hint.acpi.0.disabled=0
113
freebsd_module_elf /@/boot/kernel/opensolaris.ko
114
freebsd_module_elf /@/boot/kernel/zfs.ko
115
freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
116
probe -l -s name $root
117
set FreeBSD.vfs.root.mountfrom=zfs:$name
118
freebsd_loadenv /@/boot/device.hints
121
menuentry "FreeBSD (on $fstype $device) (verbose)" $device {
124
freebsd /@/boot/kernel/kernel --verbose
125
set FreeBSD.acpi_load=YES
126
set FreeBSD.hint.acpi.0.disabled=0
127
freebsd_module_elf /@/boot/kernel/opensolaris.ko
128
freebsd_module_elf /@/boot/kernel/zfs.ko
129
freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
130
probe -l -s name $root
131
set FreeBSD.vfs.root.mountfrom=zfs:$name
132
freebsd_loadenv /@/boot/device.hints
135
menuentry "FreeBSD (on $fstype $device) (without ACPI)" $device {
138
freebsd /@/boot/kernel/kernel --verbose
139
unset FreeBSD.acpi_load
140
set FreeBSD.hint.acpi.0.disabled=1
141
set FreeBSD.loader.acpi_disabled_by_user=1
142
freebsd_module_elf /@/boot/kernel/opensolaris.ko
143
freebsd_module_elf /@/boot/kernel/zfs.ko
144
freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
145
probe -l -s name $root
146
set FreeBSD.vfs.root.mountfrom=zfs:$name
147
freebsd_loadenv /@/boot/device.hints
150
menuentry "FreeBSD (on $fstype $device) (safe mode)" $device {
153
freebsd /@/boot/kernel/kernel --verbose
154
unset FreeBSD.acpi_load
155
set FreeBSD.hint.acpi.0.disabled=1
156
set FreeBSD.loader.acpi_disabled_by_user=1
157
set FreeBSD.hint.apic.0.disabled=1
158
set FreeBSD.hw.ata.ata_dma=0
159
set FreeBSD.hw.ata.atapi_dma=0
160
set FreeBSD.hw.ata.wc=0
161
set FreeBSD.hw.eisa_slots=0
162
set FreeBSD.hint.kbdmux.0.disabled=1
163
freebsd_module_elf /@/boot/kernel/opensolaris.ko
164
freebsd_module_elf /@/boot/kernel/zfs.ko
165
freebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
166
probe -l -s name $root
167
set FreeBSD.vfs.root.mountfrom=zfs:$name
168
freebsd_loadenv /@/boot/device.hints
174
# $device: parenthesis removed from $dev
175
regexp -s device '\((.*)\)' $dev
176
# $fstype: filesystem type identified
177
probe -s fstype -f $dev
178
# uuid: filesystem UUID
179
probe -s uuid -u $dev
181
if test -f ($device)/isolinux/isolinux.cfg ; then
182
menuentry "ISOLINUX config (on $device)" $device {
184
syslinux_configfile -i /isolinux/isolinux.cfg
187
if test -f ($device)/bootmgr -a -f ($device)/boot/bcd; then
188
menuentry "Windows Vista bootmgr (on $device)" $device {
192
elif test -f ($device)/ntldr -a \
193
-e ($device)/ntdetect.com -a -f ($device)/boot.ini; then
194
menuentry "Windows NT/2000/XP loader (on $device)" $device {
196
regexp -s devnum 'hd([0-9]+)' $root
197
if test "$devnum" != "0"; then
198
drivemap -s hd0 $root
202
elif test -f ($device)/windows/win.com; then
203
menuentry "Windows 98/ME (on $device)" $device {
205
regexp -s devnum 'hd([0-9]+)' $root
206
if test "$devnum" != "0"; then
207
drivemap -s hd0 $root
211
elif test -f ($device)/io.sys -a -f ($device)/command.com; then
212
menuentry "MS-DOS (on $device)" $device {
214
regexp -s devnum 'hd([0-9]+)' $root
215
if test "$devnum" != "0"; then
216
drivemap -s hd0 $root
220
elif test -f ($device)/kernel.sys; then
221
menuentry "FreeDOS (on $device)" $device {
223
regexp -s type '([fh])d[0-9]+' $root
224
regexp -s devnum '[fh]d([0-9]+)' $root
225
if test $type = 'h' -a "$devnum" != "0"; then
226
drivemap -s hd0 $root
230
elif test "$fstype" = ufs1 -o "$fstype" = ufs2 -a \
231
-e ($device)/boot/kernel/kernel -a \
232
-e ($device)/boot/device.hints; then
234
freebsd_ufs_variants $device $fstype $uuid
236
elif test "$fstype" = zfs -a \
237
-e ($device)/@/boot/kernel/kernel -a \
238
-e ($device)/@/boot/device.hints; then
240
freebsd_zfs_variants $device
242
elif test "$fstype" = hfsplus -a -f ($device)/mach_kernel; then
243
menuentry "Mac OS X/Darwin" $device $uuid {
249
if [ /var/vm/sleepimage -nt10 / ]; then
250
if xnu_resume /var/vm/sleepimage; then
254
if [ $do_resume = 1 ]; then
256
if [ -f /Extra/DSDT.aml ]; then
257
acpi -e /Extra/DSDT.aml
259
xnu_kernel /mach_kernel boot-uuid=${uuid} rd=*uuid
260
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
261
xnu_mkext /System/Library/Extensions.mkext
263
xnu_mkext /System/Library/Extensions
265
if [ -f /Extra/Extensions.mkext ]; then
266
xnu_mkext /Extra/Extensions.mkext
268
if [ -d /Extra/Extensions ]; then
269
xnu_kextdir /Extra/Extensions
271
if [ -f /Extra/devtree.txt ]; then
272
xnu_devtree /Extra/devtree.txt
274
if [ -f /Extra/splash.jpg ]; then
276
xnu_splash /Extra/splash.jpg
278
if [ -f /Extra/splash.png ]; then
280
xnu_splash /Extra/splash.png
282
if [ -f /Extra/splash.tga ]; then
284
xnu_splash /Extra/splash.tga
290
for file in /boot/vmlinuz-* /boot/linux-*; do
291
if test -f $file; then
292
regexp -s version '/boot/vmlinuz-(.*)' $file
293
regexp -s version '/boot/linux-(.*)' $file
295
menuentry "Linux $file" $device $uuid $file $version {
301
linux $kernel root=UUID=$uuid ro
302
if test -f /boot/initrd-$version.img; then
303
initrd /boot/initrd-$version.img
304
elif test -f /boot/initrd.img-$version; then
305
initrd /boot/initrd.img-$version
306
elif test -f /boot/initrd-$version; then
307
initrd /boot/initrd-$version
311
menuentry "Linux $file (single)" $device $uuid $file $version {
317
linux $kernel root=UUID=$uuid ro single
318
if test -f /boot/initrd-$version.img; then
319
initrd /boot/initrd-$version.img
320
elif test -f /boot/initrd.img-$version; then
321
initrd /boot/initrd.img-$version
322
elif test -f /boot/initrd-$version; then
323
initrd /boot/initrd-$version