Grub2 notes

Since most of the documentation I see on Grub2 at this point is written for Ubuntu, and Fedora does it differently, this page is more of a reminder to myself.

These commands are for Fedora 16 in its alpha stage. I don't know how many of them will change. Please consider this a work in progress.

Making changes.

One doesn't edit /boot/grub2/grub.cfg. Instead, one edits /etc/default/grub. There, one can remove, for example, the rhgb and quiet entries in the menu, so that one can see what's happening during boot, or change the default timeout. After editing it, one must then run
grub2-mkconfig -o /boot/grub2/grub.cfg

The -o is for the output file--if you don't give it, then no changes are actually made.

Adding entries to your grub menu.

RH based systems have always been pretty bad at detecting other Linux installations. I don't know if this has changed with grub2 or not, but at least through F15, it only automatically detects other RH based and Windows installations. If you want to add another entry, add an entry to /etc/grub.d/40_custom. While old grub would count disks and partitions starting at 0, so that /dev/sda1 would be hd0,0, grub2, while still counting disks at 0, starts partitions at 1. So, /dev/sda1 will be sd0,1. Assuming you have installed, for example, ArchLinux on /dev/sda6
menuentry "ArchLinux" {
set root='(hd0,6)'
linux /boot/vmlinuz-linux
initrd /boot/initramfs-linux.img
}

If using chainloading then,after the setroot line, instead of linux and initrd, it would look like
menuentry "ArchLinux" {
set root='(hd0,6)'
chainloader (hd0,6)+1
}

When done, once again, one would run grub2-mkconfig -o /boot/grub/grub.cfg.

Alternate method

Some folks, including at least one person on the Fedora testing list, found that editing 40_custom and running grub2-mkconfig didn't work. That person posted an alternate method, that worked for them.

Instead of adding those lines to /etc/grub.d/40_custom, one can create a file /boot/grub2/custom.cfg. If one looks at /etc/grub.d/41_custom (as opposed to 40_custom) in Fedora, they will see that it says if /boot/grub2/custom.cfg exists, then source it. So, if one creates a custom.cfg file with the entry given above, i.e.
menuentry "ArchLinux" {
set root='(hd0,6)'
linux /boot/vmlinuz-linux
initrd /boot/initramfs-linux.img
}

upon reboot, the ArchLinux line should be visible. One advantage of having a custom.cfg file is that one doesn't have to run grub2-mkconfig after making any changes, the file will always be read upon boot.

If usng FreeBSD as another system, the chainloader syntax should work For example with FreeBSD on partition 3
menuentry "FreeBSD" {
set root='(hd0,3)'
chainloader (hd0,3)+1
}

Note that there is no space between the (hd0,3) and the +1. I found that if I put in the space, that is, wrote it as (hd0,3) +1, it wouldn't work, giving me an error of
invalid file name `'.

I've found that both Ubuntu and Fedora seem to sometimes, though not always, have issues finding other systems. In addition, if you're using, say, Ubuntu's grub, then update Fedora, it might not find it until you once again update grub in Ubuntu. So, my personal preference is to decide upon one as the main grub. In /etc/default/grub, I will then add the line
GRUB_DISABLE_OS_PROBER=true
Then, update grub. In Ubuntu just run sudo update-grub, in Fedora, the
command would be grub2-mkconfig -o /boot/grub2/grub.cfg.  Now, this
means it will be up to me to add a chainloader entry each time I install
another system.  

For me, this is the easiest way to do it. It also tends to keep grub menus smaller--if I don't do this, then each system running grub2, even if grub2 is in that systems root partition rather than the mbr, will show all systems that it's found on the machine.