So i did a mistake of using Grub Customizer and then did another while trying to restore previous config by following instructions in /etc/grub.d/backup/RESTORE_INSTRUCTIONS
, which led to corrupting my grub config files.
Now when i try to run sudo update-grup
i get
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
The resulting grub.cfg.new
is empty (it contains only the initial comment about it being generated).
I have tried to reinstall the grub according to this answer by
sudo apt-get purge grub-pc grub-common
but it no longer works. First the apt
complained about unmet dependencies and when i added grub2-common grub-pc-bin
to the list to be removed, it told me it needs to install these instead
... grub-common:i386 grub-efi-amd64 grub2-common:i386 ...
After some hesitation i accepted it, and let those packages install with the intention to replace them back aftewards, but i ran into this again during installation
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
...
dpkg: error processing package grub-pc (--configure):
installed grub-pc package post-installation script subprocess returned error exit status 1
So apparently the update-group
is now part of the post-install script, and if it fails the package fails to install. So now i'm in a state where dependencies are broken in both ways and neither of the grub versions is properly installed and cannot be fixed.
The configuration files of the grub
(/etc/default/grub
and /etc/grub.d/*
) were never removed and overwritten during the purge. And if i delete them manually, they are never installed again.
Is there anything i can do to save my installation of the OS now?
/etc/grub.d
folder? Maybe copying in the correctly formed files will help me. – Youda008 Nov 12 '22 at 23:18sudo apt update
andsudo apt -f install
to fix any loose ends. Then, runsudo apt install --reinstall -o Dpkg::Options::="--force-confmiss" grub-pc grub-common grub2-common grub-pc-bin
– mchid Nov 12 '22 at 23:24sudo mv /boot/grub/grub.cfg.new /boot/grub/grubdotcfgdotnewdotbackup
so that you have a backup of the file if needed. The force confmiss option in the reinstall command I provided should cause the reinstall to overwrite and/or replace any existing and/or missing configuration files. – mchid Nov 12 '22 at 23:28sudo rm /boot/grub/grub.cfg.new
. It's empty, and contains no information. – waltinator Nov 12 '22 at 23:30sudo apt -f install
ends with the same post-install script error fromgrub-pc
. The second command ends withInternal Error, No file name for grub-pc:amd64
– Youda008 Nov 12 '22 at 23:32/etc/default/grub
. Did you make any changes to that file or any other grub files? If so, which file did you change? You can easily download a replacement file if you know which file you need (which file you edited). – mchid Nov 12 '22 at 23:44/etc/grub.d/backup
folder created by Grub Customizer as was in the RESTORE-INSTRUCTIONS, and it broke. Where can i download a replacement? I would like to see whole directory structure. – Youda008 Nov 12 '22 at 23:52apt download packagename
and then you have to extract the files. However, you should probably remove (purge) grub-customizer and get the original amd64 versions reinstalled and the i386 versions uninstalled first and foremost. Also, move or remove anygrub.cfg
files if needed (if it gives you an error during the reinstall). – mchid Nov 13 '22 at 00:13sudo apt install --reinstall -o Dpkg::Options::="--force-confnew" packagename
should replace old configuration files with new ones (of course, replace "packagename" with the actual names of the packages). – mchid Nov 13 '22 at 00:19sudo grub-install
For Boot-Repair: https://help.ubuntu.com/community/Boot-Repair – oldfred Nov 13 '22 at 03:43--force-confnew
ended up with the same post-install error. However, manually downloading the package file and extracting the config files from it into /etc fixed the problem and now evenapt -f install
finally finishes. – Youda008 Nov 13 '22 at 08:36