Monday, 30 January 2012

Joggler: Improving GRUB

This is part of my series on running an unmodified Debian on the Joggler. See here for other posts on the same topic.

As explained in my last post, the problem with running a standard Debian kernel (or most other prebuild modern Linux kernels) is that GRUB loads them at the "wrong" address - that is, the address that older versions of the Linux kernel boot protocol expected. Because of the Joggler's weird (and possibly broken) EFI memory map, the kernel needs to be loaded using the new boot protocol 2.10, so that GRUB can choose a correctly aligned address that doesn't overlap any of the EFI mapped areas. However, GRUB 1.99 doesn't support this.

I spoke to Matthew Garrett about this problem, who knows a great deal about EFI booting (and about hideous workarounds for broken hardware). He had a patch in progress already to add this support to GRUB, which I experimented with and gave a few tweaks until it worked on the Joggler. I gave him the modified patch back and hopefully he'll be able to get it tested on more platforms and integrated into GRUB proper, but until then, it does work on the Joggler.

So, if you want to build a GRUB that works on the Joggler right now, just grab the GRUB 1.99 tarball and apply my version of Matthew's patch to it. You don't need any other patches; the Joggler GRUB patch on other sites is used to add EFI GOP video support, which is already included in 1.99.

With this patch, a normal modern kernel which requests 16MB alignment and is relocatable will be loaded at 32MB, to avoid the area at 16MB which is in use by EFI. This is aligned, so the kernel won't attempt to move itself at start, but it won't be the address the kernel is compiled to run at so there will be a tiny (seriously, very tiny) amount of time spent at boot applying the relocations to make it run from 32MB. The standard Debian kernel used to run the installer works fine, and if you also include one of the installer initrd images then the installer boots. There are several problems with trying to actually use the installer, however, so while it boots and you can get to a shell to explore the device, I haven't run out of problems to address yet.

So, as far as GRUB is concerned, if this patch (or a derivative of it) can get into the GRUB tree, then future versions of GRUB (including, say, Debian prebuilt binary packages) will work just fine on the Joggler without any special preparation.

UPDATE: This has now happened, see my post here :)


  1. Hi Tom,

    I've been going down similar lines to your work but with a slight twist. The realisation I've had with the Joggler is the IO is very poor. Even using a USB disk is rather slow due to the inherent overhead. I did investigate the onboard PATA disk (I'm the guy who wired a SATA port on JogglerWiki) but that wasn't really practical.

    This all led me to NFS. Now I'm no Linux kernel engineer but it should be simple enough to create a lightweight boot partition with a network aware copy of Grub (I had trouble with this) which fires up a patched copy of the linux kernel that mounts the root partition via NFS.

    The problem I've had is simply getting grub network aware - do you have any thoughts?

    The second thought I had was on similar lines to your debian-installer adventure. Loading a lightweight copy of linux which has the appropriate rtl8*** modules, uses initrd+fstab to mount and NFS share and finally chroot.

    If you have any hints feel free to drop me a line.

    (side note: good to see another londoner!)

  2. Not Tom. :)

    Grub only supports PXE networking, as far as I know, which doesn't exist on EFI machines. (see ). You probably want to just drop the kernel and initramfs image on the internal flash. Hopefully Grub 2.00 (which is heading for freeze now) will be able to run on the joggler without modification, pending a couple of patches being accepted.

    As for the kernel, you don't need to patch it to support root-on-NFS, any random distro kernel will do that. However, if you're using wired ethernet you will need to add an extra script to the initramfs which sets the MAC address to something valid.