Restoring The GRUB.cfg

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
MoonJumper
Level 2
Level 2
Posts: 78
Joined: Mon Jan 28, 2019 1:05 pm
Location: Aberdeen, Scotland

Restoring The GRUB.cfg

Post by MoonJumper »

Hello Forum, What is the best way to make a back up copy of the, "GRUB.cfg"file and how would that copy be reinstated should the need arise? MoonJumper.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29615
Joined: Wed Jul 06, 2011 3:58 am

Re: Restoring The GRUB.cfg

Post by xenopeek »

grub.cfg is a generated file. You can simply run sudo update-grub to re-generate it. You should generally not be editing grub.cfg manually but instead edit your /etc/default/grub and run the update-grub afterwards. What need do you have to manually edit it?
Image
User avatar
MoonJumper
Level 2
Level 2
Posts: 78
Joined: Mon Jan 28, 2019 1:05 pm
Location: Aberdeen, Scotland

Re: Restoring The GRUB.cfg

Post by MoonJumper »

Many thanks for your reply xenopeek, yes I know that the grub.cfg file is not meant to be edited directly. I have two separate drives, both dual boot, Mint 19.2 an XP, not connected at the same time. Both had the same broken links showing at boot up on the Grub menu. On the first drive I successfully deleted the broken link by editing out that link, by copying the menu entries from the grub.cfg file, omitting the entry for the broken link. Then pasting those menu entries into the etc/grub.d/40_custom, file, saving it and then updating grub. However on my second drive with the same broken link, doing the same procedure, the link still shows on the grub menu at boot up. All guidance appreciated as to solving this issue on my second drive set up. MoonJumper.
User avatar
Jo-con-Ël
Level 11
Level 11
Posts: 3596
Joined: Sun Jun 20, 2021 12:41 pm
Location: donde habita el olvido

Re: Restoring The GRUB.cfg

Post by Jo-con-Ël »

No need to modify that /boot/grub/grub.cfg file as it is said. If broken links means GRUB menu entries that are not working (not for Mint installed on that drive but for other systems as Windows XP), you will need to create 40_custom file with right menu entries as you did and also avoid grub to create them again .
From terminal edit /etc/default/grub (sudo nano /etc/default/grub) and add this line
GRUB_DISABLE_OS_PROBER=true
Save grub file (press Ctrl+O and then Enter) and close editor (Ctrl+X).
Do not forget to run sudo update-grub.
Maybe you just forgot it last time.

Also If errors on creating 40_custom entries, a new grub.cfg file would not be created and the old one preserved but you would see warnings/errors on terminal...

In that case, or if GRUB menu remains the same, post back following codes result and confirm you have not installed Grub Customizer

Code: Select all

cat /etc/default/grub
cat /etc/grub.d/40_custom
Arrieritos semos y en el camino nos encontraremos.
User avatar
MoonJumper
Level 2
Level 2
Posts: 78
Joined: Mon Jan 28, 2019 1:05 pm
Location: Aberdeen, Scotland

Re: Restoring The GRUB.cfg

Post by MoonJumper »

Hello Jo-con-Ël, Many thanks for your guidance. What will adding this line - GRUB_DISABLE_OS_PROBER=true - Do? I thought that OS_ PROBER detects Windows OS's such as XP and Win 7! No, I have not installed Grub Customizer. Best regards, MoonJumper.
User avatar
Jo-con-Ël
Level 11
Level 11
Posts: 3596
Joined: Sun Jun 20, 2021 12:41 pm
Location: donde habita el olvido

Re: Restoring The GRUB.cfg

Post by Jo-con-Ël »

Yes, that line prevent scanning other systems, i.e. 30_os-prober wont be executed when running sudo update-grub.

40_custom will be executed in the same way, so once you have created custom menu entries with right "links" to Windows 7 and XP you don't need grub scan for those systems. In other case, without that line, update-grub would restore wrong "links" and duplicate right ones on menu.
Last edited by Jo-con-Ël on Mon Jul 04, 2022 2:04 am, edited 1 time in total.
Arrieritos semos y en el camino nos encontraremos.
User avatar
trytip
Level 14
Level 14
Posts: 5367
Joined: Tue Jul 05, 2016 1:20 pm

Re: Restoring The GRUB.cfg

Post by trytip »

timeshift will keep a backup of your system, provided you don't let timeshift do automated snapshot which will add up to less hard drive space.
other than that what i do is rightclick /boot folder as Root and then rightclick on /boot/grub/grub.cfg and Compress
when your system borks, you can boot live mint or any distro, and decompress it as Root again
Image
Locked

Return to “Installation & Boot”