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/>.
18 function pathname { regexp -s 2:"$2" '^(\(.*\))?(/.*)$' "$1"; }
19 function devname { regexp -s "$2" '^(\(.*\)).*$' "$1"; }
21 function loopback_iso_entry {
26 if test -f /boot/grub/loopback.cfg; then
27 cfgpath=/boot/grub/loopback.cfg
28 elif test -f /grub/loopback.cfg; then
29 cfgpath=/grub/loopback.cfg
34 echo loopback.cfg $isopath: yes
35 menuentry "Boot GRUB Loopback Config from ${realdev}${isopath}" "$realdev" "$isopath" "$cfgpath" {
41 loopback loopdev_cfg "${device}${iso_path}"
42 set root=(loopdev_cfg)
44 loopback -d loopdev_cfg
49 function grml_iso_entry {
55 for dir in /boot/grml /boot/grmlsmall /boot/grmlmedium; do
56 if ! test -f ${dir}/linux26 -a -f ${dir}/initrd.gz; then continue; fi
58 echo grml $isopath: yes
60 menuentry "GRML Linux from ${realdev}${isopath}" \
61 "$realdev" "$isopath" "$dir" {
66 loopback loopdev_grml "${device}${isopath}"
67 set root=(loopdev_grml)
68 linux $grmldir/linux26 findiso="$isopath" apm=power-off quiet \
70 initrd $grmldir/initrd.gz
71 loopback -d loopdev_grml
77 function pmagic_iso_entry {
82 if ! test -f /pmagic/bzImage -a -f /pmagic/initramfs; then return 1; fi
84 echo pmagic $isopath: yes
85 menuentry "Parted Magic from ${realdev}${isopath}" "$realdev" "$isopath" {
89 loopback loopdev_pmagic "${device}${isopath}"
90 set root=(loopdev_pmagic)
91 linux /pmagic/bzImage iso_filename="$isopath" edd=off noapic \
92 load_ramdisk=1 prompt_ramdisk=0 rw sleep=10 loglevel=0 \
94 initrd /pmagic/initramfs
95 loopback -d loopdev_pmagic
100 function sidux_iso_entry {
106 for kernel in /boot/vmlinuz-*-sidux-*; do
107 if ! test -f "$kernel"; then continue; fi
108 regexp -s 1:v1 -s 2:v2 '/boot/vmlinuz-(.*)-sidux-(.*)' "$kernel"
110 initrd="/boot/initrd.img-$v1-sidux-$v2"
111 if ! test -f "$initrd"; then continue; fi
114 echo sidux $isopath: yes
115 menuentry "Sidux vmlinux-$v1-sidux-$v2 from ${realdev}${isopath}" "$realdev" "$isopath" "$kernel" "$initrd" {
121 loopback loopdev_sidux "${device}${isopath}"
122 set root=(loopdev_sidux)
123 linux $kernel fromiso=$isopath boot=fll quiet
125 loopback -d loopdev_sidux
131 function slax_iso_entry {
136 if ! test -f /boot/vmlinuz -a -f /boot/initrd.gz; then return 1; fi
138 echo slax $isopath: yes
139 menuentry "Slax Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
143 loopback loopdev_slax "${device}${isopath}"
144 set root=(loopdev_slax)
145 linux /boot/vmlinuz from=$isopath ramdisk_size=6666 root=/dev/ram0 rw
146 initrd /boot/initrd.gz
147 loopback -d loopdev_slax
152 function tinycore_iso_entry {
157 if ! test -f /boot/bzImage -a -f /boot/tinycore.gz; then return 1; fi
159 echo tinycore $isopath: yes
160 menuentry "Tinycore Linux from ${realdev}${isopath}" "$realdev" "$isopath" {
164 loopback loopdev_tiny "${device}${isopath}"
165 set root=(loopdev_tiny)
167 initrd /boot/tinycore.gz
168 loopback -d loopdev_tiny
173 function casper_iso_entry {
178 if ! test -f /casper/vmlinuz; then return 1; fi
180 for f in /casper/initrd.*z; do
181 if ! test -f "$f"; then continue; fi
184 if test -z "$initrd"; then return 1; fi
186 echo casper $isopath: yes
187 menuentry "Casper based Linux from ${realdev}${isopath}" "$realdev" "$isopath" "$initrd" {
192 loopback loopdev_casper "${device}${isopath}"
193 set root=(loopdev_casper)
194 linux /casper/vmlinuz boot=casper iso-scan/filename="$isopath" quiet splash noprompt keyb="$langcode" \
195 debian-installer/language="$langcode" console-setup/layoutcode?="$langcode" --
197 loopback -d loopdev_casper
206 for dir in $isodirs; do
207 for file in ${dev}${dir}/*.iso ${dev}${dir}/*.ISO; do
208 if ! test -f "$file"; then continue; fi
210 pathname $file isopath
211 if test -z "$dev" -o -z "$isopath"; then continue; fi
213 if ! loopback loopdev_scan "$file"; then continue; fi
215 set root=(loopdev_scan)
217 if loopback_iso_entry $dev $isopath (loopdev_scan); then true;
218 elif grml_iso_entry $dev $isopath (loopdev_scan); then true;
219 elif pmagic_iso_entry $dev $isopath (loopdev_scan); then true;
220 elif sidux_iso_entry $dev $isopath (loopdev_scan); then true;
221 elif slax_iso_entry $dev $isopath (loopdev_scan); then true;
222 elif tinycore_iso_entry $dev $isopath (loopdev_scan); then true;
223 elif casper_iso_entry $dev $isopath (loopdev_scan); then true;
227 loopback -d loopdev_scan
237 terminal_output --append serial
238 # terminal_input --append serial
243 scan_isos /iso /boot/iso