booting non linux stuff with grub

I wanted to boot from CD on an old system without CD-boot support in BIOS. Smart Bootmanager is helpful, but I had no floppies around anymore. So, why not boot Smart Bootmanager from GRUB? But how do you boot non-linux stuff with grub (grub2, that is)? I looked in the GRUB-config files for memtest86 and imitated those. The following is a script that I have as /etc/grub.d/39_advanced_custom and it boots /boot/memdisk.bin with /boot/sbootmgr.dsk as its ramdisk.

#!/bin/sh

. /usr/lib/grub/grub-mkconfig_lib
LX=linux16
INITRD=initrd16

MEMDISKPATH=$( make_system_path_relative_to_its_root "/boot/memdisk.bin" )
SBMPATH=$( make_system_path_relative_to_its_root "/boot/sbootmgr.dsk" )

echo "Found CDROM boot image: $MEMDISKPATH" >&2

cat << EOF
menuentry "Smart BootManager" {
        $LX     $MEMDISKPATH
        $INITRD $SBMPATH
}
EOF

The effect is that GRUB loads Smart Bootmanager which in turn let me boot from CD.

After studying the result of this script I learned how to add custom entries using plain /etc/grub.d/40_custom instead:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Smart BootManager" {
        linux16 /memdisk.bin
        initrd16 /sbootmgr.dsk
}

## And while we're at it, here is how to netboot the squeeze installer
menuentry "Squeeze netboot installer" {
    linux /linux-squeeze-netboot
    initrd /initrd.gz-squeeze-netboot
}

Then just run

update-grub

And you're done.

Once you understand how it works, the debian way of using /etc/<package-name>.d/your-files-go-here is elegant. However, when the package supplied scripts are advanced, it is a bit hard to see what they are doing - and to understand what your own script is expected to do.

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 17, 2019