每次安装或删除软件包时都会出现 LVM2 错误

每次安装或删除软件包时都会出现 LVM2 错误

我需要帮助来处理此错误。我运行的是 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:~$ 

以上内容几乎就是我在安装/删除软件包时看到的内容。我对 Linux 还不太熟悉。我不知道如何修复此问题。重新安装 LVM2 软件包没有帮助,或也dpkg --configure -a没有dpkg --configure lvm2。但是,我可以正常安装和删除软件包,似乎包括 lvm2 本身。

我也尝试过:

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.

然后我尝试修复链接在这里但这也没用。查看 lvmetad 手册页后,我做了:

anon@computer:~$ sudo pvscan --cache
[sudo] password for anon:                 
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
anon@computer:~$

最后,我还尝试了循环电源、更新和升级一切等等。我没有主意了,请问一下。

更新:我尝试了建议的直接取消屏蔽套接字。起初它似乎有效,因为当我启用并启动 lvm2-lvmetad 服务时,它没有显示失败。我尝试升级软件包,但同样的错误仍然存​​在。

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:~$ 

包管理期间仍然出现错误。

编辑:已修复。详情请参阅我的评论。这是 lvm2 依赖关系损坏。

答案1

对我有用的是完全地删除 lvm2 然后重新安装它:

$ sudo apt purge lvm2 && sudo apt install lvm2

清除后(拆分上述命令),您还可以检查是否/etc/lvm已消失。如果没有,请将其删除。
这还不够apt remove lvm2

rm -rf /etc/lvm2对我来说没用,或者至少不够。

答案2

升级到 18.10 beta 后我遇到了完全相同的问题。

对我有用的是:

rm -rf /etc/lvm
apt-get install --reinstall lvm2

相关内容