[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


Switching from Lilo to Grub2 (legacy/mode bios mbr)


Introduction

If you use UEFI and/or GPT, then don't use this. If you still want to use it, you can probably set your UEFI to BIOS legacy mode and deactivate GPT. This is meant to be simple. For now it's how to do it after you installed and booted into your new Slackware installation. I'll add later extra steps how to do it in a shell after the installation but before rebooting.

Summary:

cd /etc/grub.d/
chmod -x 20_linux_xen 30_os_prober 30_uefi_firmware 41_custom
nano /etc/grub.d/40_custom
grub-mkconfig -o /boot/grub/grub.cfg
nano /boot/grub/grub.cfg
grub-install /dev/sda

Preparations

cd /etc/grub.d

Deactivate autoconfig files according to your need, example:

chmod -x 20_linux_xen 30_os_prober 30_uefi_firmware 41_custom


Generating a useful template (optional)

Grub2 is not very intuitive to write a config entries for, so you can modify a good example to your need instead. Pipe some examples to a file:

grub-mkconfig > examples.file

Copy one of the examples to another file or overwrite the current file with one example only. (Including curly brackets)

Then append the example in the file to the custom grub entry file: (You need to append the info into the file, as you need to preserve the uncommented info already there, lest it should not work.)

cat examples.file >> 40_custom


Edit custom config

Edit the custom entry to fit whatever you want to do..

nano /etc/grub.d/40_custom

Some useful tools you can use for info here: blkid, fstab

If you run into an unbootable system, boot from Slackware USB/DVD and follow the instructions there to boot with the USB/DVD Kernel into your root file system. Like:
huge.s root=/dev/sdaX initrd= ro

Ps. By root is meant the location of your Slackware root and could be for example /dev/sda5

Config

Once you are ready or think so, you can prepare grub: (this generates the config file from any executable files in /etc/grub.d/ and replaces editing menu.lst from grub1)

grub-mkconfig -o /boot/grub/grub.cfg

The above generates the necessary files in /boot/grub including the config file. Every time you CHANGE anything in the config folder /etc/grub.d/, you need to run the above command again for it to take effect. You can now inspect the /boot/grub/grub.cfg file to evaluate if it looks right.

Install

Then INSTALL grub: (this example installs to master boot record on the first disk, you could install it to a boot disk or elsewhere instead..)

grub-install /dev/sda

You should be given feedback about it being successfull or not. Then cross your fingers and reboot.

You don't need to repeat this last step if you reconfigure grub. The step before it just replaces menu.lst, so once grub is installed, it reads the generated config file “dynamically”

Sources

* Originally written by zeebra

 howtos:misc:lilo_to_grub_bios_mbr ()