Skip to main content

Bootloader checker

·122 words·1 min
Vimal A R
Author
Vimal A R
Still figuring it out!

A bash code snippet that helps to check if the installed bootloader is Grub or LILO.

1#!/bin/bash
2
3A=`mount | awk '{print $1}' | grep -n /dev/ | grep "1:" | cut -f2 -d ":" | cut -c 1-8` B=`mount | awk '{print $1}' | grep -n /dev/ | grep "1:" | cut -f2 -d ":"`
4
5echo ; echo -e " / mounted on $B \n"; dd if=$A bs=512 count=1 2>&1 | grep GRUB > /dev/null; if [ $? = 0 ] ; then echo -e "The installed bootloader is GRUB.\n" ; fi
6
7dd if=$A bs=512 count=1 2>&1 | grep LILO > /dev/null; if [ $? = 0 ] ; then echo -e "The installed bootloader is LILO.\n" ; fi

Related

·6525 words·31 mins
Get started with GRUB2 # https://www.certdepot.net/rhel7-get-started-grub2/ Note: This is an RHCSA 7 exam objective. Presentation of GRUB2 # GRUB2 is the new Linux bootloader. GRUB2 stands for GRand Unified Bootloader version 2. As GRUB was not maintained for some time and lacked some critical features like GPT management needed to handle disks bigger than 2.4TB, it was decided to start a new version from scratch with modularity in mind.

·309 words·2 mins
Difference between grubx64 and shimx64? # https://askubuntu.com/questions/342365/what-is-the-difference-between-grubx64-and-shimx64 Typically, EFI/ubuntu/grubx64.efi on the EFI System Partition (ESP) is the GRUB binary, and EFI/ubuntu/shimx64.efi is the binary for shim. The latter is a relatively simple program that provides a way to boot on a computer with Secure Boot active. On such a computer, an unsigned version of GRUB won't launch, and signing GRUB with Microsoft's keys is impossible, so shim bridges the gap and adds its own security tools that parallel those of Secure Boot. In practice, shim registers itself with the firmware and then launches a program called grubx64.efi in the directory from which it was launched, so on a computer without Secure Boot (such as a Mac), launching shimx64.efi is just like launching grubx64.efi. On a computer with Secure Boot active, launching shimx64.efi should result in GRUB starting up, whereas launching grubx64.efi directly probably won't work.