The two common boot loaders for Linux systems are GRUB and LILO. The former is more commonly used, the latter is older.

How does a user programmatically know which boot loader is active? Only one bootloader can be active, but some systems might have both installed. While observing the boot menu is an obvious answer, that approach is not programmatic.

A common suggestion found on the copypasta web is the following:

dd if=/dev/sda bs=512 count=1 2>&1 | strings | grep LILO

This command likely will fail. When both bootloaders are installed and LILO has been used at least once, then the command will return a positive result even when GRUB is the active bootloader.

I have not tested fully but I am trying a modified approach:

dd if=/dev/sda bs=512 count=1 2>&1 | strings | grep LILO | wc -l

If the number of lines in the result is equal to 2 then LILO likely is the active bootloader. Otherwise GRUB is the likely active bootloader.

Posted: Category: Usability Tagged: General

Next: No Router

Previous: lddlibc4 command not found