# Super Grub Disk - osdetect.cfg # Copyright (C) 2009,2010,2011,2012,2013,2014,2015 Adrian Gibanel Lopez. # # Super Grub Disk 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. # # Super Grub Disk 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 Super Grub Disk. If not, see . set option_title=$"Operating Systems" function freebsd_ufs_variants { set device="$1" set fstype="$2" set uuid="$3" menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device $uuid { set root="$2" set uuid="$3" kfreebsd /boot/kernel/kernel set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid kfreebsd_loadenv /boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device $uuid { set root="$2" set uuid="$3" kfreebsd /boot/kernel/kernel -s set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid kfreebsd_loadenv /boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device $uuid { set root="$2" set uuid="$3" kfreebsd /boot/kernel/kernel -v set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid kfreebsd_loadenv /boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device $uuid { set root="$2" set uuid="$3" kfreebsd /boot/kernel/kernel -v unset kFreeBSD.acpi_load set kFreeBSD.hint.acpi.0.disabled=1 set kFreeBSD.loader.acpi_disabled_by_user=1 set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid kfreebsd_loadenv /boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device $uuid { set root="$2" set uuid="$3" kfreebsd /boot/kernel/kernel -v unset kFreeBSD.acpi_load set kFreeBSD.hint.acpi.0.disabled=1 set kFreeBSD.loader.acpi_disabled_by_user=1 set kFreeBSD.hint.apic.0.disabled=1 set kFreeBSD.hw.ata.ata_dma=0 set kFreeBSD.hw.ata.atapi_dma=0 set kFreeBSD.hw.ata.wc=0 set kFreeBSD.hw.eisa_slots=0 set kFreeBSD.hint.kbdmux.0.disabled=1 set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid kfreebsd_loadenv /boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid { set root="$2" kfreebsd /boot/loader } } function freebsd_zfs_variants { set device="$1" set fstype=zfs menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device { set root="$2" kfreebsd /@/boot/kernel/kernel set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 kfreebsd_module_elf /@/boot/kernel/opensolaris.ko kfreebsd_module_elf /@/boot/kernel/zfs.ko kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache probe -l -s name $root set kFreeBSD.vfs.root.mountfrom=zfs:$name kfreebsd_loadenv /@/boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device { set root="$2" kfreebsd /@/boot/kernel/kernel -s set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 kfreebsd_module_elf /@/boot/kernel/opensolaris.ko kfreebsd_module_elf /@/boot/kernel/zfs.ko kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache probe -l -s name $root set kFreeBSD.vfs.root.mountfrom=zfs:$name kfreebsd_loadenv /@/boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device { set root="$2" kfreebsd /@/boot/kernel/kernel -v set kFreeBSD.acpi_load=YES set kFreeBSD.hint.acpi.0.disabled=0 kfreebsd_module_elf /@/boot/kernel/opensolaris.ko kfreebsd_module_elf /@/boot/kernel/zfs.ko kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache probe -l -s name $root set kFreeBSD.vfs.root.mountfrom=zfs:$name kfreebsd_loadenv /@/boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device { set root="$2" kfreebsd /@/boot/kernel/kernel -v unset kFreeBSD.acpi_load set kFreeBSD.hint.acpi.0.disabled=1 set kFreeBSD.loader.acpi_disabled_by_user=1 kfreebsd_module_elf /@/boot/kernel/opensolaris.ko kfreebsd_module_elf /@/boot/kernel/zfs.ko kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache probe -l -s name $root set kFreeBSD.vfs.root.mountfrom=zfs:$name kfreebsd_loadenv /@/boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device { set root="$2" kfreebsd /@/boot/kernel/kernel -v unset kFreeBSD.acpi_load set kFreeBSD.hint.acpi.0.disabled=1 set kFreeBSD.loader.acpi_disabled_by_user=1 set kFreeBSD.hint.apic.0.disabled=1 set kFreeBSD.hw.ata.ata_dma=0 set kFreeBSD.hw.ata.atapi_dma=0 set kFreeBSD.hw.ata.wc=0 set kFreeBSD.hw.eisa_slots=0 set kFreeBSD.hint.kbdmux.0.disabled=1 kfreebsd_module_elf /@/boot/kernel/opensolaris.ko kfreebsd_module_elf /@/boot/kernel/zfs.ko kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache probe -l -s name $root set kFreeBSD.vfs.root.mountfrom=zfs:$name kfreebsd_loadenv /@/boot/device.hints } menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid { set root="$2" kfreebsd /@/boot/loader } } function get_efis { blockdev="$1" blockfs="$2" efis="" if [ "$blockfs" = "fat" ]; then for efi in \ ($blockdev)/efi/*/*.efi \ ($blockdev)/efi/*/*/*.efi \ ($blockdev)/*.efi \ ($blockdev)/*/*.efi \ ($blockdev)/EFI/*/*.EFI \ ($blockdev)/EFI/*/*/*.EFI \ ($blockdev)/*.EFI \ ($blockdev)/*/*.EFI \ ($blockdev)/EFI/*/*.efi \ ($blockdev)/EFI/*/*/*.efi \ ($blockdev)/efi/*/*.EFI \ ($blockdev)/efi/*/*/*.EFI \ ; do if [ -f "$efi" ] ; then efis="$efis $efi" fi done if [ -n "$efis" ]; then return 0 fi fi return 1 } function osx_entry_add { set device="$1" set uuid="$2" set kerncmd="$3" set arch="$4" set args="$5" set desc="$6" menuentry "${finaloption_tab_str}Mac OS X/Darwin $arch-bit ($device) - $desc" $device $uuid $kerncmd $args { set root="$2" set uuid="$3" set kerncmd="$4" set args="$5" insmod all_video set do_resume=0 if [ /var/vm/sleepimage -nt10 / ]; then if xnu_resume /var/vm/sleepimage; then set do_resume=1 fi fi if [ $do_resume = 0 ]; then xnu_uuid ${uuid} uuid if [ -f /Extra/DSDT.aml ]; then acpi -e /Extra/DSDT.aml fi if [ /kernelcache -nt /System/Library/Extensions ]; then $kerncmd /kernelcache boot-uuid=${uuid} rd=*uuid $args else $kerncmd /mach_kernel boot-uuid=${uuid} rd=*uuid $args if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then xnu_mkext /System/Library/Extensions.mkext else xnu_kextdir /System/Library/Extensions fi 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/devprop.bin ]; then xnu_devprop_load /Extra/devprop.bin 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 } } function run_option { source "${prefix}/tools.cfg" set saved_root=$root insmod regexp for dev in (*); do # $device: parenthesis removed from $dev regexp -s device '\((.*)\)' $dev # Discard floppy and cdrom devices in search # But search them if their search has been inforced if searchindevice "$device" ; then # $fstype: filesystem type identified probe -s fstype -f $dev # uuid: filesystem UUID probe -s uuid -u $dev if test -f ($device)/bootmgr -a -f ($device)/boot/bcd; then menuentry "${finaloption_tab_str}Windows Vista ($device)" $device { set root="$2" chainloader +1 } elif test -f ($device)/ntldr -a \ -e ($device)/ntdetect.com -a -f ($device)/boot.ini; then menuentry "${finaloption_tab_str}Windows NT/2000/XP ($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 "${finaloption_tab_str}Windows 98/ME ($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 "${finaloption_tab_str}MS-DOS ($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 "${finaloption_tab_str}FreeDOS ($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 -a -d ($device)/Users; then osx_entry_add $device $uuid "xnu_kernel" "32" "-v" "Verbose Mode" osx_entry_add $device $uuid "xnu_kernel" "32" "-x" "Safe Mode" osx_entry_add $device $uuid "xnu_kernel" "32" "-s" "Single User" osx_entry_add $device $uuid "xnu_kernel" "32" "-f" "Ignore Caches" osx_entry_add $device $uuid "xnu_kernel64" "64" "-v" "Verbose Mode" osx_entry_add $device $uuid "xnu_kernel64" "64" "-x" "Safe Mode" osx_entry_add $device $uuid "xnu_kernel64" "64" "-s" "Single User" osx_entry_add $device $uuid "xnu_kernel64" "64" "-f" "Ignore Caches" elif get_efis $device $fstype; then for efi in $efis; do menuentry "${finaloption_tab_str}$efi ($device)" "$efi" "$device" { efi_device="$3" efi="$2" if [ "$grub_platform" = "efi" ]; then root="$efi_device" chainloader "$efi" else echo $"Sorry, but we are booted via BIOS and can not load this OS." echo $"Please try booting SG2D via UEFI." echo $"Press escape to return to the menu" sleep --interruptible 9999 fi } done else set root=$device for file in /boot/vmlinuz-* /boot/linux-* /boot/kernel-genkernel-*; do if test -f $file; then regexp -s version '/boot/vmlinuz-(.*)' $file regexp -s version '/boot/linux-(.*)' $file regexp -s version '/boot/kernel-genkernel-(.*)' $file menuentry "${finaloption_tab_str}Linux $file ($device)" $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 elif test -f /boot/initramfs-genkernel-$version; then initrd /boot/initramfs-genkernel-$version fi } menuentry "${finaloption_tab_str}Linux $file (single) ($device)" $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 elif test -f /boot/initramfs-genkernel-$version; then initrd /boot/initramfs-genkernel-$version fi } fi done fi fi done set root=$saved_root }