Ubuntu – New to Linux, I’m getting this recurring error “ERROR ”update-grub“ returned an error: exit status 1 ” please advise

20.04grub2

I get this error when trying to update my system, all appears to be functioning, but I am new to Linux so I may be missing something

ben@ben-laptop:~$ sudo apt -y upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  libllvm9
Use 'sudo apt autoremove' to remove it.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Requesting to save current system state
Successfully saved as "autozsys_k3262n"
Setting up linux-image-5.4.0-40-generic (5.4.0-40.44) ...
Processing triggers for linux-image-5.4.0-40-generic (5.4.0-40.44) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-40-generic
I: The initramfs will attempt to resume from /dev/sda2
I: (UUID=a9642385-eacc-4155-b29f-90ba3692f639)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
/usr/sbin/grub-probe: error: failed to get canonical path of `bpool/BOOT/ubuntu_0qqeus'.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.4.0-40-generic (--configure):
 installed linux-image-5.4.0-40-generic package post-installation script s
ubprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.4.0-40-generic
ZSys is adding automatic system snapshot to GRUB menu
ERROR "update-grub" returned an error: exit status 1 
E: Sub-process /usr/bin/dpkg returned an error code (1)

If I run update-grub by itself I get

ben@ben-laptop:~$ sudo update-grub [sudo] password for
ben:  /usr/sbin/grub-probe: error: failed to get canonical path of
`bpool/BOOT/ubuntu_0qqeus'. 

Best Answer

I recently had the exact same issue with Kubuntu 20.04. The problem is that the /boot partition has run out of spare space to update the kernel properly. Hence it repeatedly fails on each retry (i.e. sudo apt upgrade). You can check this by running df-H and if the Avail space is low (say under 100MB) for the /boot mount then you may run into the issue you are seeing. First try sudo apt clean and sudo apt autoremove then sudo apt upgrade to see if it automatically clears up space to fix the error. If not, see my solution below.

To fix it you need to free up the space on your /boot. How I did it:

  1. Run sudo dpkg --list | egrep -i --color 'linux-image|linux-headers' to give you a list of installed kernels and kernel-headers in your /boot.
  2. Now you need to uninstall all of the ones you dont want EXCEPT the current kernel (find out current kernel by running uname -r). You probably should KEEP any kernel newer than the current kernel too.
  3. Uninstall each kernel and kernel-header you dont want using:
    sudo apt purge {kernel-package-name}
    
    For example I ran:
    sudo apt purge linux-image-5.4.0-26-generic
    ...
    sudo apt purge linux-headers-5.4.0-26-generic
    ...
    sudo apt purge linux-image-5.4.0-33-generic
    ...
    sudo apt purge linux-headers-5.4.0-33-generic
    ...
    And so on...
    
  4. Once you have removed enough kernels to free up space, restart your PC then try sudo apt update and sudo apt upgrade again and see if it succeeds and the error message goes away.

In future when it fills up again you may have to repeat this. I always thought the old kernels should get removed automatically or by using sudo apt clean and/or sudo apt autoremove but it seems not the case on some installs.

If anyone knows how to auto-remove old kernels please share

Related Question