How to change your default GRUB menu

Change your menuentries

Changing internal grub.cfg (coreboot.rom)Back to top of page

Libreboot on X60 means that you have the GRUB payload. GRUB, and it's configs, are stored in SPI memory alongside coreboot/libreboot, as a payload. So what happens when you install a new distro? Of course, now your grub menu is "wrong".

There is an option in the default menu (on libreboot.org pre-compiled X60 ROM) called "scan" which can switch to your distro's grub.cfg, but this can get tedious doing that every time you boot.

So the idea is, that you should ideally change the grub.cfg inside the ROM, so that it'll Just Work like you expect.

The way libreboot's pre-compiled X60 ROM's work is, that there is a grub.cfg inside GRUB memdisk which exists inside the grub payload. Then, that config loads the actual grub.cfg which exists directly inside the root of the cbfs filesystem. This is done intentionally, to make changing the ROM easier without having to touch a compiler.

Changing the internal grub.cfg is possible. Coreboot (and also libreboot) ROM's are not "flat", they contain a file system inside (like ext3/4/btrfs/xfs file systems on most GNU/Linux systems). Inside this file system (contained within the ROM) you can change the files inside, such as adding a new payload or elf file to executed by a payload.

You can also pre-compile the ROM from scratch, but if you only want a new grub.cfg then this isn't really necessary (unless there is a grub module that you need). (and of course, you can also use cbfstool to remove the payload and manually add another, such as a newly compiled grub payload – all without having to recompile libreboot!).

Here is an excellent writeup about CBFS (coreboot filesystem): http://lennartb.home.xs4all.nl/coreboot/col5.html

"cbfstool" is a programme included with coreboot (and libreboot) that can read the contents of the ROM, and lets you change the contents inside.

Download libreboot source code from http://libreboot.org/
Under libreboot_src/coreboot/util/cbfstool, do "make" to compile cbfstool.
Now install flashrom.

Command: cd /path/to/libreboot_src/coreboot/util/cbfstool To compile it, type 'make'. (on Trisquel you should install build-essential. Other distros will differ). cbfstool is also included in the binary archives.

If you want to work with the existing ROM that you have installed, dump a copy of current firmware:
sudo flashrom -p internal -r coreboot.rom

If you are working with a new dump, then you need to take ownership of the file:
$ sudo chown $(whoami):$(whoami) coreboot.rom
Or if you don't have sudo:
# chown correctusername:correctusername coreboot.rom

If you are using a pre-existing coreboot.rom (from libreboot_bin/bin/x60 for instance) then you probably don't need to do this. The 'chown' methods above are only needed if you are working with a ROM that you just dumped with flashrom, since root will have ownership over the file.

If it complains about multiple flash chips, then you have the Macronix, so do that instead:
sudo flashrom -p internal -r coreboot.rom -c "MX25L1605D/MX25L1608D"

Now you have a file called coreboot.rom. This is what was flashed before.

Display contents of ROM:
./cbfstool coreboot.rom print

The coreboot.rom file contains your grub.cfg.

Extract grub.cfg from the ROM:
./cbfstool coreboot.rom extract -n grub.cfg -f grub.cfg

Now you have a grub.cfg in cbfstool directory. Edit it however you wish.

Delete the grub.cfg that remained inside the ROM:
./cbfstool coreboot.rom remove -n grub.cfg

Display ROM contents and now you see grub.cfg no longer exists there:
./cbfstool coreboot.rom print

Add the modified version that you just made:
./cbfstool coreboot.rom add -n grub.cfg -f grub.cfg -t raw

Now display ROM contents again and see that it exists again:
./cbfstool coreboot.rom print

Now re-flash your modified coreboot ROM:
sudo flashrom -p internal -w coreboot.rom

If it complains about multiple flash chips, then you have the Macronix, so do that instead:
sudo flashrom -p internal -w coreboot.rom -c "MX25L1605D/MX25L1608D"

Now, shut it down (full shut down! Not a reboot!). When you boot up again, it'll show grub but with the new grub.cfg config that you just made.