Grub2 and Fedora…

Posted: August 8, 2010 in fedora

Fedora Linux  uses still grub legacy as boot loader and I have to say there is no great need to change it as I like it. I’ve also seen a page about Grub2 from Jeremy Katz and his efforts around grub2.

The other day I’ve decided to check grub2 and started with a simple ‘yum install grub2‘… amazing thing is that by default after installing the package it made an entry on the grub legacy from where we could chain load grub2. This is interesting because it provided the opportunity of testing it properly without harming the MBR when experimenting.

By default it doesn’t create a config file with grub2-mkconfig. So this is actually the very first step needed. I’ve also noticed that it didn’t picked up my Windows 7 partitions. I do have the need of Windows 7 to be installed due to some proprietary software I require, and since I have a valid OEM licence for it, I also take the opportunity to use all the Windows fonts in Linux and using msttcorefonts. This was the only flaw I’ve noticed with the grub2 package available for Fedora.

Now… this can be easilly solved. On /etc/grub.d/40_custom users can add custom entries (Windows boot loader is installed on /dev/sda1 on my system), and so I added:


menuentry "Windows 7 Home Premium" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid
chainloader +1 }

The disk partition identifiers have changed in grub2 and no longer they start in 0, instead they start with 1. So /dev/sda1 is actually (hd0,1) is grub2 and would be (hd0,0) in grub legacy.

Grub2 grub2-mkconfig now generates properly the very own basic config for my system.

At this point I’ve found the second flaw in grub2 packaging. Most people want to use grub2 due to the gfxmode. Users need to have a font in pf2 format for this. Grub2 documentation referes often and recomends to use unifont in pf2 format, and also includes a tool to convert the font to the desired format (though virtually grub2 can operate with any font supported by freetype).

I couldn’t find a package with this font, so I needed to download unifont from Unifoundry and convert it with “grub2-mkfont -o /boot/grub2/unifont.pf2 /path/to/font/unifont.pcf“. Permission sanity check so that grub can actually see the font!

At this point, there’s two ways of finishing to configure grub, being the first edit directly the /etc/grub2.cfg config file or eventually tweak the /etc/grub.d/ scripts so that grub2-mkconfig can generate properly the config file for your system tweaked with your options.

I’ve decided to hack the config file I had generated earlier and made the replacements necessary by hand.

I’ve added the following:


# load font module & load unifont.pf2. loadfont can only be used after font module being loaded
# keep in mind that paths on config file refer to /boot/ which is the root of grub2. By using /grub2 we're actually pointing to /boot/grub2 from the filesystem root.
insmod font
loadfont /grub2/unifont.pf2

# load the modules I need
insmod vbe
insmod gfxterm
insmod png

# load the stuff I need
set gfxmode="1366x768x32"
set gfxpayload=keep
terminal_output gfxterm
terminal gfxterm
use_bg=true
background_image /grub2/goddard-1366x768.png

A fun “shutdown now -frn” and everything seemed to work properly.

The scripts from /etc/grub.d are not tweaked for Fedora, and they would actually require some care for the future. Another fun part on grub2 is that the config file can actually run shell script and lots of cool customizations can be done here… The integration of grub2 with Fedora is somehow needed of some tweaking… and I might be submitting soon a small patch for the /etc/grub.d scripts to fix some stuff.

This package is really interesting and except for the lack of unifont (make a dependency on it?) and detection of Windows partition works pretty well giving a nice cool boot menu for people’s systems. The screen does flicker 1 time between grub2 and plymouth loading.

Nice package and I’m looking forward to the day when it gets integrated with Fedora as the default boot loader. For sure something that on a personal level I would love to see happen.

Finally! grub2-install /dev/sda… done.

Another cool alternative as a bootloader is Chameleon developed by the OSX86 community. Though it requires some patching is also offers good functionality and tweaking! but that is a different story and a far more complex boot loader to install.

Comments
  1. korbe says:

    Another alternativ is Burg. It’s based on Grub and add more option and a better UI.

    See many screenshots here: http://code.google.com/p/burg/wiki/Screenshots

    The code page: http://code.google.com/p/burg/

  2. aborrecido says:

    Another thing I’ve just noticed is that the current grub2 package (grub2-1.98-2.fc13.x86_64) doesn’t ship with ‘grub2-emu’ which is nice to test stuff out… while performing a ‘yum whatprovides */grub2-emu’ it returns that the previous (??) package did shiped it (grub2-1.97.2-1.fc13.x86_64).

  3. grubtester says:

    grub can query for whether the user is on, for example, the console vs the serial port. that was the first thing I checked in grub2 and it failed. i didn’t see a reason to go further.

  4. taljurf says:

    Thx for the identifiers info
    I was intending to try grub2, so i would have wrecked the whole thing :)
    I want to try it, since i found that it supports booting from iso files on the hd.

    I had hard times with Chameleon, until i finally gave up :(

    • aborrecido says:

      I don’t believe you would wreck stuff by installing the fedora repo rpm, in fact I would advice you to try it.

      After you install the rpm, you can chainload grub2 from grub legacy, which is cool since it allows you to tweak it without harming the MBR and ensuring you have a way to boot your system.

      The /etc/grub.d scripts need some tweaking but it’s just stetical/branding issues as for the default entries they add “GNU/Linux description”. They can be tweaked to read sys vars and build the same description that grub legacy uses. But they do work.

      Only thing that really didnt worked out was the detection of windows volumes and adding the entries to the menu, which isn’t much of a deal.

      As for the font missing, it’s only required for those who want to enable gfxmode.

      But it does work flawlessly if you care to tweak it a bit, it’s really a pretty nice package from GNU :)

Leave a reply to aborrecido Cancel reply