Sat, 09 Feb 2008

Time for GRUB2?

My Apple Powerbook 5,4 just booted for the first time using GRUB, with no manual intervention, from Apple chime to GDM prompt. This is a great milestone for GRUB2 on powerpc-ieee1275 and OpenFirmware, as until now, multiple problems in the loader would drop you to OF console straight away, although other PowerPC hardware with other firmware implementations did manage to work.

Recent fixes by Pavel in the core and some other minor fixes for the userland utils have taken grub2 to the point where it is usable on most PowerPC hardware. On Apple, the only minor issue remaining is grub-probe insisting on (hd) not being a valid device name, so for now I have to trick it into believing it's really (hd1).

In parallel, many other GRUB2 improvements haven't stopped hitting CVS in the last months, which have seen how new contributors joined grub-devel and helped GRUB2 get the great momentum it's enjoying right now. Vesa, Robert and Bean have been really active lately, and have fixed long standing issues or written a lot of new code. One of the features GRUB2 acquired recently was image loading for background images. Much more powerful than the implementation in GRUB Legacy, GRUB2 can now read images in multiple formats, can handle up to 24bit colour and render a menu in arbitrary resolutions. The menu can now show UTF-8, and the Debian package will configure a pretty theme that matches the rest of the system if desktop-base is installed:


GRUB2 speaking UTF-8 Catalan

Although I'm not sure if GRUB2 is completely up-to-par with GRUB Legacy on i386/amd64, it seems the tricky bits, like video, LVM, RAID and the standard filesystems are supported and working. What GRUB2 needs now, in order to finally replace the aging and upstream-lacking GRUB Legacy you probably have installed, is massive testing. Debian has traditionally been a testbed for GRUB Legacy patches, and is also the platform where GRUB2 is being more widely tested. Having GRUB2 included in lenny's debian-installer would be a great step forward, and by the looks, I think we're well on time to manage this.

Replacing GRUB Legacy with GRUB2 is trivial. On PCs, just install the grub-pc package. You'll be offered to keep GRUB Legacy, but with an added menu entry to chainload GRUB2. If you're worried that GRUB2 might fail on your hardware, accept this, and try to load GRUB2 from GRUB. If it works, you then know you can get rid of GRUB Legacy completely and keep GRUB2 in the MBR.

On PowerPC-based Macs, you'll have to work around the small issue I mentioned above. Install the grub-ieee1275 package. You also need a very recent powerpc-ibm-utils package, which was just uploaded to unstable.

Mount your bootstrap partition, probably /dev/hda2 in /boot/grub, and generate a device.map file with grub-mkdevicemap. Check the contents. If your first device name lacks a drive number such as (hd), it's probably correct, although this will make things fail later. Change it to (hd0) for now. As grub-install relies on grub-probe, you'll have to generate your grub image by hand.

Copy all .mod files in /usr/lib/grub/powerpc-ieee1275 to your bootstrap partition, and generate a core.img:

root@powerpc:/boot/grub# grub-mkimage -d . -o /boot/grub/core.img *.mod
root@powerpc:/boot/grub# update-grub
root@powerpc:/boot/grub# nvsetenv boot-device hd:2,core.img

The generated grub.cfg will have references to (hd0,X), which you'll have to correct back to (hd,X) if necessary for your OpenFirmware. After this, you are probably ready to reboot, cross two fingers and get a warm "Welcome to GNU GRUB!" message at boot, which will then be followed by a standard GRUB menu, but on your nice PowerPC box. Unfortunately, the eye candy in the screenshot above isn't available yet in this platform, as it lacks VESA. Does someone in the audience want to contribute a video driver for powerpc? :)

I#d like to try out grub2, but the grub-pc package conflicts with the grub package. Why is that?

Posted by oscar at Sat Feb 9 21:12:23 2008

From grub2's changelog:

* Add grub to Conflicts/Replaces.  Too many commands with the same name, even if they don't use the same path yet (but will likely do in the future, see #361929).

But don't worry: removing the grub package won't remove GRUB's files from /boot/grub, nor will it remove it from the MBR--so even if grub2 does not work, you will still be able to boot up. And you can always remove grub-pc and install grub again if you want to go back.

Posted by Sam Morris at Sat Feb 9 22:04:10 2008

Holy cow!  I never heard the grub2 was being developed for PPC, this is good news.

Posted by Dirk Gently at Sun Feb 10 00:56:48 2008

The grub-pc package conflicts with grub. I decided to trust Jordi Mallach and went for installing. Then a reboot, I chose the grub2 option in the grub menu, and all went fine...

But now I'd like to remove the grub legacy stuff... how can I do?

Posted by Stefano Costa at Sun Feb 10 01:03:35 2008

As hinted by Stefano, the grub-pc package description didn't make me very confortable, and if it weren't for your (Jordi's) post I would have avoided grub2 till it became The-grub.

Configuring it seems a lot more involved but all is looking good so far, neat. And thank you for posting this entry :)

Now I wonder how should I call my entries to take advantage of the UTF-8 support... :) (Using proverbs as in your screenshot doesn't sound very natural :P)

Posted by Toni Corvera at Sun Feb 10 02:30:08 2008

Personally, I can hardly wait for the ability to boot from LVM and RAID without a /boot partition.

Posted by Anonymous at Sun Feb 10 10:03:30 2008

Is the recent powerpc-ibm-utils package really needed? If that is the case then I should file a sync bug in Ubuntu.

I would like to try grub2 on my iBook G4 and thanks for your Debian/Ubuntu specific howto.

Posted by Onkar at Sun Feb 10 17:49:43 2008

Toni, rm'ing the old GRUB Legacy files (/boot/grub/stage and menu.lst) and running grub-install "(hd0)" and then update-grub should suffice in most cases.

Onkar, the recent utils are really needed, as GRUB2 relies on some new options only available in 1.0.5.

As for booting without /boot on RAID and LVM, I'd say the current snapshot should be able, although there are some reported cases where there are problems. But it should work. Do give it a spin!

Posted by Jordi at Sun Feb 10 23:39:22 2008

Oh, I had no problem replacing GRUB Legacy, didn't remove anything manually, IIRC I just dpkg-reconfigure'd grub-pc disabling the chainloaded GRUB2 + grub-install + update-grub.

My problem was not installing GRUB2 but realising I could test it safely.

P.S.: RAID+LVM support? Awesome.

Posted by Toni Corvera at Mon Feb 11 14:42:25 2008

When I install grub-pc, the original grub package gets uninstalled.
I'm just wondering, how come the original grub is still booting?

Posted by Olaf van der Spek at Tue Feb 12 11:35:48 2008

Olaf, it's still in /boot/grub, and installed in your MBR, until you replace it with GRUB2.

Posted by Jordi at Tue Feb 12 13:58:47 2008

I tried your instructions for PowerPC, and it works really well for the most part, thanks!

Just two comments:
* The sentence "Copy all .mod files in /usr/lib/grub/powerpc-ieee1275" should instead be, "Copy all files" (not only *.mod), since otherwise grub-mkimage will complain about missing ./kernel.elf.
* On my Mac Mini, special characters (e.g. the up arrow and down arrow character in the help below the GRUB boot screen) don't display correctly, and also colors don't work (the entire screen is just black, with white text), is this the same on your PPC machine also?

And a question: Will this procedure have to be followed in the same way when a new or updated kernel is installed?

Thanks!

Posted by Bram Senders at Wed Feb 13 14:18:10 2008

Bram, for kernel updates, while grub-probe is broken, you'll have to do the update-grub part, that is, correcting your device.map, updating grub.cfg and correcting it to point to the right device.

As for how it looks, yes, this is unfortunately normal as no graphical support is yet written, and apparently it'll be tricky to write proper boxes and so on this OpenFirmware stuff. But it'll come, with time. :)

Posted by Jordi at Thu Feb 14 03:00:51 2008

I installed grub-pc. There were no questions asked (are they asked in debconf?). I did grub-install to get it on my MBR. (I was previously using lilo). The system.map stuff looked fine. I have /boot on LVM, and / etc. on LVM underneath crypt.

On boot I get the rescue prompt. I've only just discovered that there's zero documentation for GRUB2.

Posted by Jon at Thu Feb 14 10:57:30 2008

Jon, if you're using the latest version, you should be getting the reason for getting dropped to rescue mode.

I fear it might be related to crypt LVM though.

People in #grub are normally very responsive.

Posted by Jordi at Thu Feb 14 13:55:22 2008