6

I have problem updating linux kernel on my Ubuntu server.

When I ran:

sudo apt update && sudo apt dist-upgrade -y

It will failed on:

Setting up linux-image-5.4.0-89-generic (5.4.0-89.100) ...
Bus error
dpkg: error processing package linux-image-5.4.0-89-generic (--configure):
 installed linux-image-5.4.0-89-generic package post-installation script subprocess returned error exit status 135
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 5.4.0.89.93); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-modules-extra-5.4.0-89-generic:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not configured yet.
  Package linux-image-unsigned-5.4.0-89-generic is not installed.

dpkg: error processing package linux-modules-extra-5.4.0-89-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-5.4.0-89-generic
 linux-image-generic
 linux-generic
 linux-modules-extra-5.4.0-89-generic
[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 146
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried to run the following command

sudo apt autoremove -y
sudo apt install -f
sudo dpkg --configure -a

but still it will fail on linux-image-5.4.0-89-generic.

I also ran:

sudo update-initramfs -u -k all                                             

and the output is like this:

perl: warning: Setting locale failed.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_ALL = (unset),
    LC_TIME = "id_ID.UTF-8",
    LC_TIME = "id_ID.UTF-8",
    LC_MONETARY = "id_ID.UTF-8",
    LC_MONETARY = "id_ID.UTF-8",
    LC_ADDRESS = "id_ID.UTF-8",
    LC_ADDRESS = "id_ID.UTF-8",
    LC_TELEPHONE = "id_ID.UTF-8",
    LC_TELEPHONE = "id_ID.UTF-8",
    LC_NAME = "id_ID.UTF-8",
    LC_NAME = "id_ID.UTF-8",
    LC_MEASUREMENT = "id_ID.UTF-8",
    LC_MEASUREMENT = "id_ID.UTF-8",
    LC_IDENTIFICATION = "id_ID.UTF-8",
    LC_IDENTIFICATION = "id_ID.UTF-8",
    LC_NUMERIC = "id_ID.UTF-8",
    LC_NUMERIC = "id_ID.UTF-8",
    LC_PAPER = "id_ID.UTF-8",
    LC_PAPER = "id_ID.UTF-8",
    LANG = "en_US.UTF-8"
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
update-initramfs: Generating /boot/initrd.img-5.4.0-88-generic
I: The initramfs will attempt to resume from /dev/sda4
I: (UUID=4a962a4e-7061-4272-9682-0d011eb67596)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-5.4.0-86-generic
I: The initramfs will attempt to resume from /dev/sda4
I: (UUID=4a962a4e-7061-4272-9682-0d011eb67596)
I: Set the RESUME variable to override this.

Currently I am afraid to reboot my server as I thought it can make me lose the access to my server.

Is there any solution for this?

Update 1:

I tried to run:

sudo apt install linux-image-unsigned-5.4.0-89-generic

and I got another error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode intel-microcode iucode-tool linux-modules-extra-5.4.0-89-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  dctrl-tools dkms wireguard-dkms
Suggested packages:
  debtags menu fdutils linux-doc | linux-source-5.4.0 linux-tools
The following packages will be REMOVED:
  linux-generic linux-image-5.4.0-89-generic linux-image-generic
The following NEW packages will be installed:
  dctrl-tools dkms linux-image-unsigned-5.4.0-89-generic wireguard-dkms
0 upgraded, 4 newly installed, 3 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 9394 kB of archives.
After this operation, 2828 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ubuntu.mirrors.ovh.net/ubuntu focal/main amd64 dctrl-tools amd64 2.24-3 [61.5 kB]
Get:2 http://ubuntu.mirrors.ovh.net/ubuntu focal-updates/main amd64 dkms all 2.8.1-5ubuntu2 [66.8 kB]
Get:3 http://ubuntu.mirrors.ovh.net/ubuntu focal-updates/universe amd64 wireguard-dkms all 1.0.20201112-1~20.04.1 [254 kB]
Get:4 http://ubuntu.mirrors.ovh.net/ubuntu focal-updates/main amd64 linux-image-unsigned-5.4.0-89-generic amd64 5.4.0-89.100 [9011 kB]
Fetched 9394 kB in 2s (5967 kB/s)                                
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "id_ID.UTF-8",
    LC_MONETARY = "id_ID.UTF-8",
    LC_ADDRESS = "id_ID.UTF-8",
    LC_TELEPHONE = "id_ID.UTF-8",
    LC_NAME = "id_ID.UTF-8",
    LC_MEASUREMENT = "id_ID.UTF-8",
    LC_IDENTIFICATION = "id_ID.UTF-8",
    LC_NUMERIC = "id_ID.UTF-8",
    LC_PAPER = "id_ID.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 176597 files and directories currently installed.)
Removing linux-generic (5.4.0.89.93) ...
Selecting previously unselected package dctrl-tools.
(Reading database ... 176595 files and directories currently installed.)
Preparing to unpack .../dctrl-tools_2.24-3_amd64.deb ...
Unpacking dctrl-tools (2.24-3) ...
Selecting previously unselected package dkms.
Preparing to unpack .../dkms_2.8.1-5ubuntu2_all.deb ...
Unpacking dkms (2.8.1-5ubuntu2) ...
Selecting previously unselected package wireguard-dkms.
Preparing to unpack .../wireguard-dkms_1.0.20201112-1~20.04.1_all.deb ...
Unpacking wireguard-dkms (1.0.20201112-1~20.04.1) ...
dpkg: linux-image-5.4.0-89-generic: dependency problems, but removing anyway as you requested:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is to be removed.
  Package linux-image-unsigned-5.4.0-89-generic is not installed.
 linux-image-generic depends on linux-image-5.4.0-89-generic.

(Reading database ... 176821 files and directories currently installed.)
Removing linux-image-5.4.0-89-generic (5.4.0-89.100) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
/var/lib/dpkg/info/linux-image-5.4.0-89-generic.postrm ... removing pending trigger
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-89-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-88-generic
Found initrd image: /boot/initrd.img-5.4.0-88-generic
Found linux image: /boot/vmlinuz-5.4.0-86-generic
Found initrd image: /boot/initrd.img-5.4.0-86-generic
done
dpkg: linux-image-generic: dependency problems, but removing anyway as you requested:
 wireguard depends on wireguard-dkms (>= 0.0.20200121-2) | wireguard-modules (>= 0.0.20191219); however:
  Package wireguard-dkms is not configured yet.
  Package wireguard-modules is not installed.
  Package linux-image-generic which provides wireguard-modules is to be removed.

Removing linux-image-generic (5.4.0.89.93) ...
Selecting previously unselected package linux-image-unsigned-5.4.0-89-generic.
(Reading database ... 176815 files and directories currently installed.)
Preparing to unpack .../linux-image-unsigned-5.4.0-89-generic_5.4.0-89.100_amd64.deb ...
Unpacking linux-image-unsigned-5.4.0-89-generic (5.4.0-89.100) ...
Setting up linux-image-unsigned-5.4.0-89-generic (5.4.0-89.100) ...
Bus error
dpkg: error processing package linux-image-unsigned-5.4.0-89-generic (--configure):
 installed linux-image-unsigned-5.4.0-89-generic package post-installation script subprocess returned error exit status 135
Setting up dctrl-tools (2.24-3) ...
dpkg: dependency problems prevent configuration of linux-modules-extra-5.4.0-89-generic:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not installed.
  Package linux-image-unsigned-5.4.0-89-generic is not configured yet.

dpkg: error processing package linux-modules-extra-5.4.0-89-generic (--configure):
 dependency problems - leaving unconfigured
Setting up dkms (2.8.1-5ubuntu2) ...
Setting up wireguard-dkms (1.0.20201112-1~20.04.1) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Loading new wireguard-1.0.20201112 DKMS files...
Building for 5.4.0-88-generic 5.4.0-89-generic
Building initial module for 5.4.0-88-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-88-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod.......

DKMS: install completed.
Building initial module for 5.4.0-89-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-89-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod.......(bad exit status: 135)

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-89-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.4.0-89-generic/
rmdir: failed to remove '': No such file or directory
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod.....(bad exit status: 135)

DKMS: uninstall completed.
Error! Problems with depmod detected.  Automatically uninstalling this module.
DKMS: Install Failed (depmod problems).  Module rolled back to built state.
dpkg: error processing package wireguard-dkms (--configure):
 installed wireguard-dkms package post-installation script subprocess returned error exit status 6
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
 linux-image-unsigned-5.4.0-89-generic
 linux-modules-extra-5.4.0-89-generic
 wireguard-dkms
[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 146
E: Sub-process /usr/bin/dpkg returned an error code (1)

Update 2:

Tried to install the generic kernel again:

sudo apt install linux-image-5.4.0-89-generic

But get the same error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode intel-microcode iucode-tool linux-modules-extra-5.4.0-89-generic
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  fdutils linux-doc | linux-source-5.4.0 linux-tools
The following packages will be REMOVED:
  linux-image-unsigned-5.4.0-89-generic
The following NEW packages will be installed:
  linux-image-5.4.0-89-generic
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/8990 kB of archives.
After this operation, 505 kB disk space will be freed.
Do you want to continue? [Y/n] 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "id_ID.UTF-8",
    LC_MONETARY = "id_ID.UTF-8",
    LC_ADDRESS = "id_ID.UTF-8",
    LC_TELEPHONE = "id_ID.UTF-8",
    LC_NAME = "id_ID.UTF-8",
    LC_MEASUREMENT = "id_ID.UTF-8",
    LC_IDENTIFICATION = "id_ID.UTF-8",
    LC_NUMERIC = "id_ID.UTF-8",
    LC_PAPER = "id_ID.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: linux-image-unsigned-5.4.0-89-generic: dependency problems, but removing anyway as you requested:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not installed.
  Package linux-image-unsigned-5.4.0-89-generic is to be removed.

(Reading database ... 176817 files and directories currently installed.)
Removing linux-image-unsigned-5.4.0-89-generic (5.4.0-89.100) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-89-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-88-generic
Found initrd image: /boot/initrd.img-5.4.0-88-generic
Found linux image: /boot/vmlinuz-5.4.0-86-generic
Found initrd image: /boot/initrd.img-5.4.0-86-generic
done
Selecting previously unselected package linux-image-5.4.0-89-generic.
(Reading database ... 176815 files and directories currently installed.)
Preparing to unpack .../linux-image-5.4.0-89-generic_5.4.0-89.100_amd64.deb ...
Unpacking linux-image-5.4.0-89-generic (5.4.0-89.100) ...
Setting up linux-image-5.4.0-89-generic (5.4.0-89.100) ...
Bus error
dpkg: error processing package linux-image-5.4.0-89-generic (--configure):
 installed linux-image-5.4.0-89-generic package post-installation script subprocess returned error exit status 135
Setting up wireguard-dkms (1.0.20201112-1~20.04.1) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Removing old wireguard-1.0.20201112 DKMS files...

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-88-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.4.0-88-generic/
rmdir: failed to remove '': No such file or directory
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod........

DKMS: uninstall completed.

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-89-generic (x86_64)
-------------------------------------

Status: This module version was INACTIVE for this kernel.
depmod.......(bad exit status: 135)

DKMS: uninstall completed.

------------------------------
Deleting module version: 1.0.20201112
completely from the DKMS tree.
------------------------------
Done.
Loading new wireguard-1.0.20201112 DKMS files...
Building for 5.4.0-88-generic 5.4.0-89-generic
Building initial module for 5.4.0-88-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-88-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod......

DKMS: install completed.
Building initial module for 5.4.0-89-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-89-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod.....(bad exit status: 135)

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-89-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.4.0-89-generic/
rmdir: failed to remove '': No such file or directory
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod.....(bad exit status: 135)

DKMS: uninstall completed.
Error! Problems with depmod detected.  Automatically uninstalling this module.
DKMS: Install Failed (depmod problems).  Module rolled back to built state.
dpkg: error processing package wireguard-dkms (--configure):
 installed wireguard-dkms package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of linux-modules-extra-5.4.0-89-generic:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not configured yet.
  Package linux-image-unsigned-5.4.0-89-generic is not installed.

dpkg: error processing package linux-modules-extra-5.4.0-89-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-5.4.0-89-generic
 wireguard-dkms
 linux-modules-extra-5.4.0-89-generic
[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 146
E: Sub-process /usr/bin/dpkg returned an error code (1)

Update 3:

As mentioned on comment, I ran the following:

sudo apt --fix-broken install

And the output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  amd64-microcode intel-microcode iucode-tool linux-modules-extra-5.4.0-89-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "id_ID.UTF-8",
    LC_MONETARY = "id_ID.UTF-8",
    LC_ADDRESS = "id_ID.UTF-8",
    LC_TELEPHONE = "id_ID.UTF-8",
    LC_NAME = "id_ID.UTF-8",
    LC_MEASUREMENT = "id_ID.UTF-8",
    LC_IDENTIFICATION = "id_ID.UTF-8",
    LC_NUMERIC = "id_ID.UTF-8",
    LC_PAPER = "id_ID.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up linux-image-5.4.0-89-generic (5.4.0-89.100) ...
Bus error
dpkg: error processing package linux-image-5.4.0-89-generic (--configure):
 installed linux-image-5.4.0-89-generic package post-installation script subprocess returned error exit status 135
Setting up wireguard-dkms (1.0.20201112-1~20.04.1) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Removing old wireguard-1.0.20201112 DKMS files...

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-88-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.4.0-88-generic/
rmdir: failed to remove '': No such file or directory
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod...

DKMS: uninstall completed.

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-89-generic (x86_64)
-------------------------------------

Status: This module version was INACTIVE for this kernel.
depmod.....(bad exit status: 135)

DKMS: uninstall completed.

------------------------------
Deleting module version: 1.0.20201112
completely from the DKMS tree.
------------------------------
Done.
Loading new wireguard-1.0.20201112 DKMS files...
Building for 5.4.0-88-generic 5.4.0-89-generic
Building initial module for 5.4.0-88-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-88-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod...

DKMS: install completed.
Building initial module for 5.4.0-89-generic
Done.

wireguard.ko:
Running module version sanity check.

Good news! Module version 1.0.20201112 for wireguard.ko
exactly matches what is already found in kernel 5.4.0-89-generic.
DKMS will not replace this module.
You may override by specifying --force.

depmod.....(bad exit status: 135)

-------- Uninstall Beginning --------
Module:  wireguard
Version: 1.0.20201112
Kernel:  5.4.0-89-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:
 - Uninstallation
   - Deleting from: /lib/modules/5.4.0-89-generic/
rmdir: failed to remove '': No such file or directory
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod.....(bad exit status: 135)

DKMS: uninstall completed.
Error! Problems with depmod detected.  Automatically uninstalling this module.
DKMS: Install Failed (depmod problems).  Module rolled back to built state.
dpkg: error processing package wireguard-dkms (--configure):
 installed wireguard-dkms package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of linux-modules-extra-5.4.0-89-generic:
 linux-modules-extra-5.4.0-89-generic depends on linux-image-5.4.0-89-generic | linux-image-unsigned-5.4.0-89-generic; however:
  Package linux-image-5.4.0-89-generic is not configured yet.
  Package linux-image-unsigned-5.4.0-89-generic is not installed.

dpkg: error processing package linux-modules-extra-5.4.0-89-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-5.4.0-89-generic
 wireguard-dkms
 linux-modules-extra-5.4.0-89-generic
[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 146
E: Sub-process /usr/bin/dpkg returned an error code (1)
4
  • I already ran the command and turn out to be another error. I updated the question with the new output.
    – khgasd652k
    Oct 27, 2021 at 15:35
  • I updated the question with the output from apt --fix-broken install. Please kindly check.
    – khgasd652k
    Oct 27, 2021 at 15:53
  • Did you happen to remove some folders ? The locale problem irritates me. Or did you try to change the language via terminal?
    – kanehekili
    Oct 27, 2021 at 21:58
  • From zsh history, no folder was deleted in a few months. As for the languange warning, it's been on my server since 18.04 LTS. I just ignore it. I am confused as normally ran sudo apt update && sudo apt dist-upgrade -y will run smoothly, but on this kernel version suddenly shows that error.
    – khgasd652k
    Oct 28, 2021 at 0:55

1 Answer 1

6

The error log of apt -f install suggests that there are errors with the post-installation script of the following packages:

  • linux-image-5.4.0-89-generic
  • wireguard-dkms
  • linux-modules-extra-5.4.0-89-generic (dependency issues)

This generally means that one or another command from the post-installation (shell-script) failed due to issues with the configuration files.


METHOD #1: First, try force overwriting the files:

sudo dpkg -i --force-overwrite var/cache/apt/archives/linux-image*
sudo dpkg -i --force-overwrite var/cache/apt/archives/wireguard-dkms*
sudo dpkg -i --force-overwrite var/cache/apt/archives/linux-module*
sudo apt --fix-broken install

Meaning:-

  • Here, the --force-overwrite argument will force dpkg to place the files regardless of the errors. The error message seems to normal and not destructive, you can run the commands without any fear.

  • In the last command the --fix-broken argument will reconfigure/reprocess the error packages.


If this didn't work then you need to remove the post-installation script of the packages:

sudo rm /var/lib/dpkg/info/linux-image-5.4.0-89-generic.postinst
sudo rm /var/lib/dpkg/info/wireguard-dkms.postinst
sudo rm /var/lib/dpkg/info/linux-modules-extra-5.4.0-89-generic.postinst

Then run a force-install:

sudo apt --fix-broken install

Then run an autoremove:

sudo apt autoremove && sudo apt clean

Meaning:-

  • The post-installation script of the package consists of commands to be run after the installation is complete to tell other applications about the installation of the package. Removing that will not do any harm as running --fix-broken install already ran the post-installation script.

After running the commands mentioned above, make sure to run these commands:

sudo apt update && sudo apt upgrade && sudo apt autoremove && sudo apt clean && sudo apt autoclean && sudo apt --fix-broken install
1
  • Thank you, the errors can be fixed with your first method. Currently I am marking your answer as the best answer, later when I need to reboot my server and there is no problem on booting, I will also update the question with the answer as well. Again, thank you for your help
    – khgasd652k
    Oct 28, 2021 at 4:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .