14.04 Upgrade triggers grub-pc failure

19,844

Solution 1

I "elegantly solved" my problem by using the following:

sudo apt-get purge grub-pc grub-common
sudo rm -r /etc/grub.d/
sudo apt-get install grub-pc grub-common
sudo grub-install /dev/sda
sudo update-grub

Deleting the /etc/grub.d/ directory seemed to have gotten rid of whatever 12.04 files I had lurking, allowing 14.04 to get on with installing grub!

Although I would of course recommend making a backup of anything that you are about to delete.

Solution 2

these grub errors have been ongoing for many years and even now on 20.04 ... just run these

sudo apt-get update
sudo apt-get --fix-broken install -y
sudo apt-get -f install -y 
sudo  apt-get -o Dpkg::Options::="--force-confnew" -yy dist-upgrade -yq
sudo apt-get autoremove -yq
sudo apt-get autoclean -y

if output of above shows some flareup then just rerun all of above again and you will be good to go

Share:
19,844

Related videos on Youtube

Rossiar
Author by

Rossiar

Updated on September 18, 2022

Comments

  • Rossiar
    Rossiar over 1 year

    My problem begins with an upgrade from Ubuntu 12.04 LTS to 14.02 LTS. As part of this I received several error messages about not being able to remove old kernels.

    When first booting into 14.02, I checked everything was ok by running sudo apt-get autoremove, the same errors appeared.

    Following a guide online, I ran the following:

    sudo apt-get purge grub-common
    sudo apt-get install grub-pc
    

    The first operation succeeded, removing grub from my pc. The second operation failed with the following:

    Creating config file /etc/default/grub with new version
    Installing for i386-pc platform.
    Installation finished. No error reported.
    Generating grub configuration file ...
    Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
    Found linux image: /boot/vmlinuz-3.13.0-54-generic
    Found initrd image: /boot/initrd.img-3.13.0-54-generic
    Found linux image: /boot/vmlinuz-3.13.0-44-generic
    Found initrd image: /boot/initrd.img-3.13.0-44-generic
    Found linux image: /boot/vmlinuz-3.13.0-40-generic
    Found initrd image: /boot/initrd.img-3.13.0-40-generic
    Adding boot menu entry for EFI firmware configuration
    cat: /video.lst: No such file or directory
    /usr/sbin/grub-probe: error: failed to get canonical path of `'.
    No path or device is specified.
    Usage: grub-probe [OPTION...] [OPTION]... [PATH|DEVICE]
    Try 'grub-probe --help' or 'grub-probe --usage' for more information.
    dpkg: error processing package grub-pc (--configure):
     subprocess installed post-installation script returned error exit status 64
    Errors were encountered while processing:
     grub-pc
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I have tried numerous fixes for this, most of which are documented here. I created a LiveCD before removing grub-common, so I have access to my old partition and can mount and chroot into it.

    But when running update-grub the same error appears, I also cannot run dpkg --configure -a without this occurring.

    I used boot-repair to get a boot summary for my machine, which is a 2 HDD rig with dual boot on the first drive (/dev/sda). With Windows on /dev/sda1 and my Ubuntu partition (also boot) on /dev/sda2.

    Please help me fix this and I promise I won't touch my Ubuntu install ever again. :-)

  • Tsung-Ting Kuo
    Tsung-Ting Kuo almost 8 years
    This does solve the problem, thank you very much!
  • Peter
    Peter about 6 years
    DANGER you might not want to run such rm -r commands ... at the very least, back up what you remove. And also this solution is missing update-initramfs -u which is often important for fixng boot issues.
  • James
    James about 4 years
    I found this question while looking for a solution w.r.t. the message dpkg: error processing package grub-pc (--configure) which I was getting when running apt upgrade. Doing only apt-get purge grub-pc grub-common; apt-get install grub-pc grub-common; update-grub solved the problem.
  • Nikhil Shrivastava
    Nikhil Shrivastava over 3 years
    Hi Scott, could you please help, I am also facing the same issue with my 20.04. I did what you mentioned but I keep on getting: Errors were encountered while processing: grub-pc linux-image-5.4.0-52-generic linux-image-5.4.0-51-generic E: Sub-process /usr/bin/dpkg returned an error code (1). Please help.
  • Arkham Angel
    Arkham Angel over 3 years
    This also fixed a problem for me on 20.10 where ubuntu just decided it didn't want to boot anymore :-(
  • Arkham Angel
    Arkham Angel over 3 years
    Boot-repair has been 0-3 for me.