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