Every time I install or remove a package I get LVM2 error
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
Related videos on Youtube
![Chris](https://lh6.googleusercontent.com/-eun5D-PuK38/AAAAAAAAAAI/AAAAAAAAcMg/wkAwkCoc2l4/photo.jpg?sz=256)
Chris
Updated on September 18, 2022Comments
-
Chris almost 2 years
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
ordpkg --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.
-
juniorRubyist about 6 yearsIf you use LVM, this might not be a good omen.
-
steeldriver about 6 yearsDid you try unmasking the socket specifically? i.e.
sudo systemctl unmask lvm2-lvmetad.socket
-
Chris about 6 yearsI think I just fixed it. I purged lvm2 then ran
apt autoremove
to get rid of leftover files. Then I reinstalled it with its dependencies. It seems like the issue wasn't in lvm2 but in one or more of the dependencies. Reinstalling all of that fixed it. -
Shadow Man almost 6 years@Chris Thanks! I was seeing the same issue on my debian system and the only way to fix it was
sudo apt-get purge lvm2
(since using aptitude wanted to uninstall loads of other packages when I told it to purge lvm2, and using "L" to re-install just wasn't working) followed by re-installing lvm2 (I did that part withsudo aptitude
like normal) then rebooting and the new kernel now has lvm support as well as my virtualbox guest daemon running. -
dess over 5 years@Chris Joining to thanks,
sudo apt -y purge lvm2 && sudo apt -y autoremove && sudo apt -y install lvm2
did the trick for me. Probably, there was some errors in lvm2/deps packages chains (clean 18.04 install, LVM installed as dependency). Would you possibly post your solution as an answer? -
Insideup about 3 years20.04 LTS success with this after failing with the accepted answer posted by m02ph3u5
-
-
dess over 5 yearsThanks, but no luck:
E: Internal Error, No file name for lvm2:amd64
. -
lrkwz almost 4 yearswhat do you mean with "/ was not enough"? newbies could be led to issue "rm -rf /"
-
m02ph3u5 almost 4 yearsThanks, I edited the paragraph.
-
Arun over 3 years
sudo apt purge lvm2 && sudo apt install lvm2
these steps affect existing files ? -
m02ph3u5 over 3 years@Arun of course, given that lvm2 is installed
-
bdutta74 about 3 yearsWorks on Ubuntu 20.04 as well.