The following outlines how to install and use Grub2 in Fedora. It will be an ongoing How-To as more of the tools involved are added upstream
Small History... I came over from Canonical/Ubuntu and was surprised to see that Grub2 was not that widely used or even developed..
I found this blog posting from Hedayat Vatankhah at his blogsite and this is what I did to replace the Ubuntu Grub2 with Fedora grub2 with the os-prober that Hedayat ported to Fedora and installing grub2
1: Install os-prober
Code:
sudo yum install os-prober
2: Install grub2 using yum
Code:
sudo yum install grub2
3: Install grub2 to the mba
Code:
sudo grub2-install /dev/sda
4: edit /etc/default/grub
Code:
sudo gedit /etc/default/grub
and add this line
Code:
GRUB_DISTRIBUTOR=$(sed "s/.*(\(.*\))/\1/" /etc/system-release)
This fixes this bug in Grub2 that does not correctly identify Fedora distribution name in the proper syntax
You can also add
to set what the default boot is ... In my case it is the 3rd boot line (Remember that in grub the first item is 0, the second is one the third is two etc etc etc)
You can also add
the default is 5.. If you want 5 then this is not needed... If you want more then add it to what you want
Note
Anytime this file is changed you must run the command outlined in step 4
4: Now run this to update grub.cfg
Note
You will need to run this same thing any time there is a new kernel added anywhere on your system
Code:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Thats it.. When you reboot, it will be Fedoras grub2 and the same options are always there..
This is what my finished /boot/grub2/grub.cfg looks like
Code:
#
# /boot/grub2/grub.cfg
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="2"
if [ ${prev_saved_entry} ]; then
set saved_entry=${prev_saved_entry}
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z ${boot_once} ]; then
saved_entry=${chosen}
save_env saved_entry
fi
}
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
set locale_dir=($root)/boot/grub2/locale
set lang=en
insmod gettext
set timeout=5
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/10_linux ###
menuentry "Lovelock GNU/Linux, with Linux 2.6.39-0.rc4.git2.0.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.39-0.rc4.git2.0.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.39-0.rc4.git2.0.fc15.x86_64.img
}
menuentry "Lovelock GNU/Linux, with Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.39-0.rc4.git2.0.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.39-0.rc4.git2.0.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.39-0.rc4.git2.0.fc15.x86_64.img
}
menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-24.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.38.5-24.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.38.5-24.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.38.5-24.fc15.x86_64.img
}
menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-24.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.38.5-24.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.38.5-24.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.38.5-24.fc15.x86_64.img
}
menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-22.fc15.x86_64" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.38.5-22.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.38.5-22.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.38.5-22.fc15.x86_64.img
}
menuentry "Lovelock GNU/Linux, with Linux 2.6.38.5-22.fc15.x86_64 (recovery mode)" --class lovelock --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod ext2
set root='(hd0,6)'
search --no-floppy --fs-uuid --set 951268a2-e667-4181-978c-526c0b71cf02
echo Loading Linux 2.6.38.5-22.fc15.x86_64 ...
linux /boot/vmlinuz-2.6.38.5-22.fc15.x86_64 root=UUID=951268a2-e667-4181-978c-526c0b71cf02 ro single quiet rhgb
echo Loading initial ramdisk ...
initrd /boot/initramfs-2.6.38.5-22.fc15.x86_64.img
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Ubuntu 10.10 (10.10) (on /dev/sda1)" {
insmod ext2
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 788582ac-a45e-4289-8fc3-36d3caaa0137
linux /boot/vmlinuz-2.6.38-020638-generic root=/dev/sda1
initrd /boot/initrd.img-2.6.38-020638-generic
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# 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.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###
Note
I am using Fedora 15 .. this should work with any Fedora release that supports grub2
I want to stress again that this is an ongoing project and will be updated as the changes happen
EDIT
May 8 2011
I got grub2 1.99~rc2 up and functioning perfectly with os-prober
If you compile grub2 1.99~rc2 you must create
/usr/local/etc/default
and then copy the file grub from /etc/default to /usr/local/etc/default
This will then read and parse the grub file information