#!/bin/bash # Script to check whether a Debian/Ubuntu system will experience boot problems from https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1889556 / https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1889509 # https://www.redradishtech.com/display/~jturner/2020/07/30/symbol+%27grub_calloc%27+not+found+--+how+to+fix+on+AWS pass() { echo "All good. $*" exit } fail() { echo >&2 "Reboot may fail! $*" exit 1 } if [[ -d /sys/firmware/efi ]]; then pass "System uses EFI, not BIOS, so is not affected" fi if zgrep -q "LP: #1889556" /usr/share/doc/grub-pc/changelog.Debian.gz; then pass "grub version has fixed the bug #1889556" fi command -v debconf-get-selections >/dev/null || sudo apt-get install debconf-utils devices="$(sudo debconf-get-selections | awk '$1=="grub-pc" && $2 == "grub-pc/install_devices" {print $4}')" if [[ -z $devices ]]; then pass "Although your grub is vulnerable to the bug, your debconf system has no preset devices to install grub onto. You will be prompted for a device when next running dpkg-reconfigure grub-pc" fi for device in $devices; do [[ -e $device ]] || fail "Your grub version does not fix the bug, and grub is configured to install to nonexistent device $device. Please upgrade grub and/or 'dpkg-reconfigure grub-pc' until you are sure grub is installed on the correct boot device" done fail "Your grub version does not fix the bug. Please run 'dpkg-reconfigure grub-pc', select the correct boot device, and verify that grub gets installed on it without error."