Grub Customizer - How to revert when update-grub failed

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
fehlix
Developer
Posts: 12624
Joined: Wed Apr 11, 2018 5:09 pm

Grub Customizer - How to revert when update-grub failed

#1 Post by fehlix »

Grub Customizer - How to revert when update-grub failed

For those who sometimes suffer from a broken Grub menu...

Grub Customizer is a powerful tool to adjust and modify the GRUB menu.
Due to it's complex nature of how GRUB generates the GRUB menu it
happens sometimes after using Grub Customizer the generation of grub menu
through update-grub fails. The grub menu script itself are generated through
meta-scripts. There seem to be no easy way to fix or to find out the
reason for those failure.

Grub Customizer itself comes with a "Revert" option. The first stepp to
recover from a failed grub-menu generation might be to revert to the
original state using the build in Revert-option with Grub Customizer.

In the case when the provided "Revert"-option still can not solve the
create failure situation the following script may help to restore to
the GRUB defaults.

script file : restore-grub.sh

Code: Select all

#!/bin/bash

# fehlix - 2019-10-23
#
# restore GRUB defaults from Grub Customizer backup

echo "${0##*/} :  restoring GRUB defaults from Grub Customizer backup"
[ ! -d /etc/grub.d/backup ] && echo "Grub Customizer Backup not found! - exit " && exit 1

# sanity checks
[ -z "${BASH_VERSION-}" ] && exec /bin/bash $0
[ "$(id -u)" != 0       ] && sudo -k && exec sudo /bin/bash $0

# backup GC
BACKUP=GC_$(date +%Y-%m-%d_%H.%M.%S).bak
cp -a /boot/grub         /boot/grub.${BACKUP}
cp    /etc/default/grub  /etc/default/grub.${BACKUP}
mv    /etc/grub.d        /etc/grub.d.${BACKUP}
mkdir /etc/grub.d

# restore GRUB
set -x
cp -a /etc/grub.d.${BACKUP}/backup/boot_grub/*   /boot/grub
cp    /etc/grub.d.${BACKUP}/backup/default_grub  /etc/default/grub
cp    /etc/grub.d.${BACKUP}/backup/etc_grub_d/*  /etc/grub.d
chmod +x /etc/grub.d/??_*
echo "Done."

HTH
:puppy:

User avatar
oops
Posts: 1891
Joined: Tue Apr 10, 2018 5:07 pm

Re: Grub Customizer - How to revert when update-grub failed

#2 Post by oops »

Merci fehlix for the tuto and the script.

FI: I now only use MX tool instead : "mx-boot-options "
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
Protokol
Posts: 18
Joined: Fri Apr 13, 2018 10:46 am

Re: Grub Customizer - How to revert when update-grub failed

#3 Post by Protokol »

hello,
thanks you so much, your script saved my life after messing around with grub customizer !

thanks again, cheers !
Hewlett-Packard Compaq Presario CQ71 Notebook
Kernel: 4.19.0-12-amd64 x86_64
Desktop: MX-19.2_x64 patito feo May 31 2020
Graphics: Intel Mobile 4 Series Integrated Graphics
Ram : 4GB

Post Reply

Return to “Tips & Tricks by users”