# Writing a GRUB configuration file

Back to index

# Table of Contents

- Example modifications for grubtest.cfg
  - Trisquel GNU/Linux-libre
  - Parabola GNU/Linux-libre

## Example modifications for grubtest.cfg

These are some common examples of ways in which the grubtest.cfg file can be modified.

### Trisquel GNU/Linux-libre

As an example, on my test system in /boot/grub/grub.cfg (on the HDD/SSD) I see for the main menu entry:

- linux /boot/vmlinuz-3.15.1-gnu.nonpae root=UUID=3a008e14-4871-497b-95e5-fb180f277951 ro crashkernel=384M-2G:64M,2G-:128M quiet splash $vt_handoff
- initrd /boot/initrd.img-3.15.1-gnu.nonpae

ro, quiet, splash, crashkernel=384M-2G:64M,2G-:128M and $vt_handoff can be safely ignored.

I use this to get my partition layout:
$ lsblk

In my case, I have no /boot partition, instead /boot is on the same partition as / on sda1. Yours might be different. In GRUB terms, sda means ahci0. 1 means msdos1, or gpt1, depending on whether I am using MBR or GPT partitioning. Thus, /dev/sda1 is GRUB is (ahci0,msdos1) or (ahci0,gpt1). In my case, I use MBR partitioning so it's (ahci0,msdos1). 'msdos' is a GRUB name simply because this partitioning type is traditionally used by MS-DOS. It doesn't mean that you have a proprietary OS.

Trisquel doesn't keep the filenames of kernels consistent, instead it keeps old kernels and new kernel updates are provided with the version in the filename. This can make GRUB payload a bit tricky. Fortunately, there are symlinks /vmlinuz and /initrd.img so if your /boot and / are on the same partition, you can set GRUB to boot from that. These are also updated automatically when installing kernel updates from your distributions apt-get repositories. Note: when using jxself kernel releases, these are not updated at all and you have to update them manually.

For the GRUB payload grubtest.cfg (in the 'Load Operating System' menu entry), we therefore have (in this example):
set root='ahci0,msdos1'
linux /vmlinuz root=UUID=3a008e14-4871-497b-95e5-fb180f277951
initrd /initrd.img

Optionally, you can convert the UUID to its real device name, for example /dev/sda1 in this case. sdX naming isn't very reliable, though, which is why UUID is used for most distributions.

Alternatively, if your /boot is on a separate partition then you cannot rely on the /vmlinuz and /initrd.img symlinks. Instead, go into /boot and create your own symlinks (update them manually when you install a new kernel update).
$ sudo -s (or su -)
# cd /boot/
# rm -f vmlinuz initrd.img
# ln -s yourkernel ksym
# ln -s yourinitrd isym
# exit

Then your grubtest.cfg menu entry (for payload) becomes like that, for example if / was on sda2 and /boot was on sda1:
set root='ahci0,msdos1'
linux /ksym root=/dev/sda2
initrd /isym

There are lots of possible variations so please try to adapt.

### Parabola GNU/Linux-libre

You can basically adapt the above. Note however that Parabola does not keep old kernels still installed, and the file names are always consistent, so you don't need to boot from symlinks, you can just use the real thing directly.

Back to top of page.

Copyright © 2014, 2015 Francis Rowe <info@gluglug.org.uk>
This document is released under the Creative Commons Attribution-ShareAlike 4.0 International Public License and all future versions. A copy of the license can be found at ../cc-by-sa-4.txt.

This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ../cc-by-sa-4.txt for more information.