21

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.

6
  • If you use LVM, this might not be a good omen. – juniorRubyist Jun 26 '18 at 1:28
  • 2
    Did you try unmasking the socket specifically? i.e. sudo systemctl unmask lvm2-lvmetad.socket – steeldriver Jun 26 '18 at 1:52
  • 2
    I 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. – Chris Jun 26 '18 at 2:32
  • @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 with sudo aptitude like normal) then rebooting and the new kernel now has lvm support as well as my virtualbox guest daemon running. – Shadow Man Jul 9 '18 at 21:13
  • 4
    @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? – dess Dec 14 '18 at 12:02
38

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.

5
  • what do you mean with "/ was not enough"? newbies could be led to issue "rm -rf /" – lrkwz Aug 31 '20 at 11:03
  • Thanks, I edited the paragraph. – m02ph3u5 Sep 2 '20 at 10:35
  • 1
    sudo apt purge lvm2 && sudo apt install lvm2 these steps affect existing files ? – Arun Mar 22 at 16:23
  • 1
    @Arun of course, given that lvm2 is installed – m02ph3u5 Mar 23 at 9:27
  • Works on Ubuntu 20.04 as well. – bdutta74 Apr 12 at 16:26
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
1
  • Thanks, but no luck: E: Internal Error, No file name for lvm2:amd64. – dess Dec 14 '18 at 12:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.