Greetings. Since there doesn't seem to be any sort of step-by-step guide for setting up grub on PowerPC, and because I've had problems with building Yaboot, I've decided to have a go at writing it.

There's two ways of setting up grub, either semi-automatically using grub-install, or manually using grub-mkimage[1]. In both cases, a bootstrap partition that can be read by openfirmware is needed, with the default (and minimum) 800K bootstrap partition being sufficient.

Preparation:

Before we can begin, we need to install grub. It's currently masked, so unmasking is necessary:

If you take a look at the created directory tree in /tmp/bootstrap, you'll see that (the current version of) grub mimics the filesystem layout of OSX, this is presumably for extra compatibility with external tools. However, what it doesn't seem to do is set up the file type for the boot script and it doesn't bless the folder which contains it, this can be corrected with the following set of commands:

It should now be possible to launch grub with the default "boot hd:,\\:tbxi" command on the open firmware prompt, or perhaps "boot hd:number,\\:tbxi" if you have other bootable partitions that precede the bootstrap partition, or "boot hd:number,\System\Library\CoreServices\BootX" in case open firmware doesn't for some reason detect the medium as bootable.

The next step is configuring grub using the standard means:

Code:

# vi /etc/default/grub
# grub-mkconfig --output=/boot/grub/grub.cfg

After this, reboot, and hope for the best

B) Manual installation:

In case you're having trouble with the semi-automatic installation, or would like to have more fine-grained control over the installation process, you can install grub manually[1].

The first step is to install grub's modules and to set up a preliminary configuration file in the /boot directory:

Replace <UUID> with the UUID of your root partition, and If you have an explicit boot partition, remove the "/boot" prefix from the paths in the above configuration. If you don't use an initrd, remove the two lines that deal with it as well. And of course, if you use a different root filesystem than ext4, edit the rootfstype= option as well.

Next, we need a built-in configuration file that will be physically baked into the bootable grub image:

Now replace <UUID> with the UUID of your boot partition, and again, if you have an explicit boot partition instead of it being a folder in your root partition, delete the "/boot" prefix from the paths.

The next step is to create a file with the list of modules you want to build into the image, in my case it is:

Make sure that the module for the file system of your boot partition is in this list. Additionally, if you're using LVM or LDM, you might need the "lvm.mod" and "ldm.mod" modules, for RAID you may need "diskfilter.mod" "raid5rec.mod" "raid6rec.mod", for an encrypted boot you may need the appropriate crypto modules and to add an invocation of "cryptomount -u <drive>" to your config. See util/grub-install.c (in particular, invocations of grub_install_push_module ()).

You can find dependency information for the modules in the file /usr/lib/grub/powerpc-ieee1275/moddep.lst

With the list of modules ready, you can now generate a bootable image of grub:

It should now be possible to boot grub with an explicit invocation of "boot hd:number,\grub.img". If you would like grub to be bootable using the default "boot hd:,\\:tbxi" command, a boot script is needed, here's an example[2] of one that just boots grub:

I found that on my machine (a Titanium PowerBook G4), there need to be at least 3 files in the blessed directory for it to work, so we'll copy the modules.list file as well:

Code:

# hcopy -r modules.list :modules.list

We can now unmount the bootstrap partition, and try to reboot and see if it works:

Code:

# humount

It should now be possible to launch grub with the default "boot hd:,\\:tbxi" command on the open firmware prompt, or perhaps "boot hd:number,\\:tbxi" if you have other bootable partitions that precede the bootstrap partition, or "boot hd:number,\grub.img" in case open firmware doesn't for some reason detect the medium as bootable.

Graphical console for the manual installation:

The default look of grub on open firmware (with the manual method, at least) is pretty crummy, but thankfully, there is a framebuffer driver for the open firmware framebuffer in grub, and it's pretty easy to enable.

Thanks for this write-up! I was able to get grub to work, using the automatic configuration. However, I hit a bit of a snag when I tried launching xorg. It seems likely to be some sort of modesetting or framebuffer issue.

Hmmm... I know GRUB messes with the vga= option on PCs, but I didn't think it messed with video= ... perhaps gfxpayload might be the culprit.

I'd double check that the option actually gets passed to the kernel:

Code:

$ cat /proc/cmdline

and also doble check that you added the option to the right field (GRUB_CMDLINE_LINUX) of /etc/default/grub and re-generated the config in /boot/grub/grub.cfg afterwards, making sure to check whether it is there._________________GNU is as new as gold is old.

Thanks for the help. I checked /proc/cmdline and can confirm it's getting passed. I also put it in the correct spot in /etc/default/grub and confirmed in /boot/grub/grub.cfg. I also added the gfxpayload=text option this time, and have the same issues. Bummer.

Since it's getting passed to the kernel, I suspect that grub's also passing some other options to the video driver that then make it fail with X; I'd try explicitly setting the video options, eg. on my machine I pass radeonfb.mode_option=1152x768-32_________________GNU is as new as gold is old.

No, the commands are all for Gentoo, the guide assumes you already have a Gentoo system deployed (from a stage3 archive) and chrooted into (from a Live CD)
, installing the bootloader is a part of the installation procedure from a Live CD.

Also, while I share your enthusiasm for RISC and PowerPC hardware, I think that for learning to use GNU/Linux, it might be better to first start with something more widely supported (Like a Raspberry Pi), as I think it would be a shame if the many stumbling blocks that using obscure hardware unfortunately brings would discourage you from the system.

Also Adelie might be an interesting distro to check out, they support PowerPC as a tier-1 platform, and unlike Gentoo, you don't have to compile everything yourself and wait hours upon hours for things to get set up._________________GNU is as new as gold is old.