NOTE: you can use the grub-mkconfig utility to generate a grub.cfg file for you. Other operating systems can be detected and will be added to the configuration only if os-prober is also installed. os-prober is currently only avaible in Debian and Ubuntu.
GRUB 2 uses new bashish scripting language that is used to build menus. At startup file grub.cfg will be read and executed.
Please note that partition numbering has been changed to start from 1 (in grub legacy it started from 0).
Example menu entrys can be found in docs/grub.cfg in the source or in the Debian/Ubuntu package in /usr/share/doc/grub-pc/examples/grub.cfg.
Here is an simple example:
# Timeout for menu
set timeout=10
# Set default boot entry as Entry 0
set default=0
# Entry 0 - Load Linux kernel
menuentry "My Linux Kernel on (hd0,1)" {
set root=(hd0,1)
linux /vmlinuz root=/dev/hda1
initrd /initrd
}
# Entry 1 - Chainload another bootloader
menuentry "Chainload my OS" {
set root=(hd0,3)
chainloader +1
}
Support for booting Memtest86+ via the "linux16" command:
# For booting Memtest86+
menuentry "Memtest86+" {
set root=(hd0,1)
linux16 /memtest86+.bin
}
Boot first Linux and Initrd found (UUID Kernel support)
# Timeout for menu
set timeout=10
# Set default boot entry as Entry 0
set default=0
# Entry 0 - Load first Kernel and Initrd (initrd support)
menuentry "First Kernel and Initrd" {
set sgd_vmlinuz_path=/vmlinuz
set sgd_initrd_path=/initrd.img
search --set=sgd_linux_kernel -f $sgd_vmlinuz_path
search --set=sgd_linux_initrd -f $sgd_initrd_path
probe -u ($sgd_linux_kernel) --set=sgd_root_uuid
set root=($sgd_linux_kernel)
linux ($sgd_linux_kernel)$sgd_vmlinuz_path root=UUID=$sgd_root_uuid
initrd ($sgd_linux_initrd)$sgd_initrd_path
boot
}