Every time I install or remove a package I get LVM2 error [duplicate]
I need help dealing with this error. I run Ubuntu Budgie 18.04LTS.
anon@computer:~$ sudo dpkg --configure -a
Setting up lvm2 (2.02.176-4.1ubuntu3) ...
update-initramfs: deferring update (trigger activated)
Failed to restart lvm2-lvmetad.service: Unit lvm2-lvmetad.socket is masked.
invoke-rc.d: initscript lvm2-lvmetad, action "restart" failed.
● lvm2-lvmetad.service - LVM2 metadata daemon
Loaded: loaded (/lib/systemd/system/lvm2-lvmetad.service; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:lvmetad(8)
dpkg: error processing package lvm2 (--configure):
installed lvm2 package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.130ubuntu3.1) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-23-generic
Errors were encountered while processing:
lvm2
anon@computer:~$
The above is pretty much what I see while installing/removing packages as well.
I'm fairly new to linux. I can't figure out how to fix this. Reinstalling LVM2 package doesn't help, nor dpkg --configure -a
or dpkg --configure lvm2
.
However, I can install and remove packages just fine, seemingly including lvm2 itself.
I also tried:
anon@computer:~$ sudo service lvm2-lvmetad start
Failed to start lvm2-lvmetad.service: Unit lvm2-lvmetad.socket is masked.
anon@computer:~$ sudo systemctl enable lvm2-lvmetad.socket
Failed to enable unit: Unit file /etc/systemd/system/lvm2-lvmetad.socket is masked.
Then I tried the fix linked here and that didn't work either. After checking the lvmetad manpage I did:
anon@computer:~$ sudo pvscan --cache
[sudo] password for anon:
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
anon@computer:~$
And lastly I've also tried cycling power, updating and upgrading everything etc. I'm out of ideas, please.
Update: I tried the suggested unmasking the socket directly. At first it seemed to work as when I enabled then started the lvm2-lvmetad service it didn't say failed. The I tried upgrading packages and the same error persists.
anon@computer:~$ sudo systemctl unmask lvm2-lvmetad.socket
Removed /etc/systemd/system/lvm2-lvmetad.socket.
anon@computer:~$ sudo systemctl enable lvm2-lvmetad.socket
anon@computer:~$ sudo service lvm2-lvmetad start
anon@computer:~$ sudo pvscan --cache
anon@computer:~$ sudo apt update && sudo apt upgrade
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease
Hit:6 http://ppa.launchpad.net/otto-kesselgulasch/gimp/ubuntu bionic InRelease
Hit:7 http://ppa.launchpad.net/tista/adapta/ubuntu bionic InRelease
Hit:8 http://ppa.launchpad.net/ubuntubudgie/backports/ubuntu bionic InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up lvm2 (2.02.176-4.1ubuntu3) ...
update-initramfs: deferring update (trigger activated)
Failed to restart lvm2-lvmpolld.service: Unit lvm2-lvmpolld.socket is masked.
invoke-rc.d: initscript lvm2-lvmpolld, action "restart" failed.
● lvm2-lvmpolld.service - LVM2 poll daemon
Loaded: loaded (/lib/systemd/system/lvm2-lvmpolld.service; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:lvmpolld(8)
dpkg: error processing package lvm2 (--configure):
installed lvm2 package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.130ubuntu3.1) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-23-generic
Errors were encountered while processing:
lvm2
E: Sub-process /usr/bin/dpkg returned an error code (1)
anon@computer:~$
Still getting the error during package management.
Edit: fixed. See my comment for details It was a broken lvm2 dependency.
Solution 1:
What worked for me was to completely get rid of lvm2 and then reinstall it:
$ sudo apt purge lvm2 && sudo apt install lvm2
After the purge (split above commands) you could also check if /etc/lvm
is gone. If not delete it.
It was not enough to apt remove lvm2
.
rm -rf /etc/lvm2
did not work for me or at least was not enough.
Solution 2:
I had the exact same problem after upgrading to 18.10 beta.
What worked for me:
rm -rf /etc/lvm
apt-get install --reinstall lvm2