Score:1

cannot use `sudo apt install` any packages - sudo apt --fix broken install error

za flag
guo

I cannot use sudo apt install any packages I have tried sudo apt --fix broken install

however it keep hitting dependencies error.

$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  linux-image-5.11.0-41-generic
Suggested packages:
  fdutils linux-doc | linux-hwe-5.11-source-5.11.0 linux-hwe-5.11-tools
The following NEW packages will be installed:
  linux-image-5.11.0-41-generic
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
7 not fully installed or removed.
Need to get 0 B/11.5 MB of archives.
After this operation, 11.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 259233 files and directories currently installed.)
Preparing to unpack .../linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb ...
Unpacking linux-image-5.11.0-41-generic (5.11.0-41.45~20.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb (--unpack):
 unable to open '/boot/vmlinuz-5.11.0-41-generic.dpkg-new': Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Score:1
za flag
guo

The blocking is due to antivirus program. Removed them:

sudo dpkg --purge mfedx 
sudo dpkg --purge mcafeetp 
sudo dpkg --purge mcafeeespaac 
sudo dpkg --purge mcafeeespfileaccess 
Sudo dpkg --purge mcafeeesp 
sudo dpkg --purge mcafeert 
sudo dpkg --purge mfecma 
sudo dpkg --purge mfert
Score:1
my flag

You can easily fix this issue!

You need to force overwrite the files, probably the last time you ran apt upgrade, a kernel upgrade was there. It seems like you are probably using an antivirus, if yes then diable it and proceed, and if no then proceed

So after making sure your antivirus services are disabled run -

sudo dpkg -i --force-overwrite /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb

Now the problem should be gone

Meaning of what we did

Normally, some antivirus services doesn't let tools like Dpkg to acess /boot directory in order to provide security but when there is a kernel upgrade Dpkg is forced to access the /boot directory, without it, it cannot install kernel, the antivirus wasn't allowing Dpkg to use /boot so disabling antivirus will allow Dpkg to use /boot

After that, we ran a command, that command does nothing but allow Dpkg to forceoverwrite the directory in which the package (kernel) linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb was installed, So that Dpkg can reinstall it.

Confirming everything

First of all run
sudo apt --fix-broken install
to confirm the fix.

Then make sure the kernel is installed by
sudo apt-get upgrade

Now after this is done you may want to clean the computer by running
sudo apt clean && sudo apt autoremove

I hope so, I helped

guo avatar
za flag
guo
I tried to force overwrite. error dpkg: error processing archive /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb (--install): unable to open '/boot/vmlinuz-5.11.0-41-generic.dpkg-new': Operation not permitted Errors were encountered while processing: /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb
guo avatar
za flag
guo
i am using corp laptop. no antivirus, or does it means the IT blocks something?
Someone avatar
my flag
@guo yeah, I think so there must be some issue with any kind of blocking service, I would recommend running `sudo rm -rf /var/cache/apt/archives/*.deb`
Someone avatar
my flag
Also, please run `sudo apt upgrade` afterwards @guo
Someone avatar
my flag
@guo are you sure you are not using any antivirus service? There must be something as it simply says cannot open /boot
Someone avatar
my flag
Look at this answer - https://askubuntu.com/a/1374271/1460940 by me the person is facing the same issue as you but it is because of unmet dependencies instead of /var problem but he also has the same issue and was fixed by disabling antivirus.
Someone avatar
my flag
IDK what is a corp laptop, can you please elaborate @guo and again make sure you have nothing even similar to antivirus! The error message clearly says that it is due to an antivirus that is not allowing dpkg to access /boot
guo avatar
za flag
guo
corporate laptop. maybe that is IT policies blocking it. anyway i will raise to IT. thanks!
guo avatar
za flag
guo
found another thread i uninstall all mcafee , all working now sudo dpkg --purge mfedx sudo dpkg --purge mcafeetp sudo dpkg --purge mcafeeespaac sudo dpkg --purge mcafeeespfileaccess sudo dpkg --purge mcafeeesp sudo dpkg --purge mcafeert sudo dpkg --purge mfecma sudo dpkg --purge mfert
Someone avatar
my flag
@guo Can you post a detailed answer
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.