e2fsprogs logsave Ubuntu 安装失败 unable to make backup link of ‘./usr/bin/chattr‘

最近给服务器从 Ubuntu 18.04 LTS 升级到 20.04 LTS,过程中崩溃,重新尝试执行,提示依赖错误。这时候 apt install 所有的东西都会报错,提示依赖不满足。(这里的报错忘了复制了)执行 apt upgrade 也是一样。(之前一直执着于这一步的报错,百般搜索没能解决问题,大致就是不同的包需求的版本互相不匹配了)

然后按照提示执行 apt --fix-broken install 就会出现下面的报错。

root@server:~# apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  bluez-obexd cryptsetup cryptsetup-bin dconf-cli gir1.2-accountsservice-1.0 gir1.2-atspi-2.0
  gir1.2-gck-1 gir1.2-gcr-3 gir1.2-gdm-1.0 gir1.2-geoclue-2.0 gir1.2-gnomebluetooth-1.0
  gir1.2-gnomedesktop-3.0 gir1.2-graphene-1.0 gir1.2-gweather-3.0 gir1.2-ibus-1.0
  gir1.2-mutter-6 gir1.2-nm-1.0 gir1.2-nma-1.0 gir1.2-rsvg-2.0 gir1.2-soup-2.4
  gir1.2-upowerglib-1.0 gjs gnome-session-bin gnome-session-common gnome-shell-common
  gnupg-l10n gnupg-utils gpg-wks-server ibus-data libaom0 libatasmart4 libblockdev-fs2
  libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2
  libblockdev-utils2 libblockdev2 libcairo-gobject-perl libcairo-perl libcamel-1.2-62
  libcdio-cdda2 libcdio-paranoia2 libcdio17 libcroco3 libcue2 libdvdread7 libebackend-1.2-10
  libebook-1.2-20 libebook-contacts-1.2-2 libebook-contacts-1.2-3 libecal-2.0-1
  libedata-book-1.2-26 libedata-cal-2.0-1 libedataserver-1.2-24 libexempi3 libexempi8
  libexiv2-27 libextutils-depends-perl libextutils-pkgconfig-perl libfile-copy-recursive-perl
  libgail-3-0 libgexiv2-2 libgif7 libgjs0g libglib-object-introspection-perl libglib-perl
  libgmime-3.0-0 libgnome-autoar-0-0 libgsf-1-114 libgsf-1-common libgutenprint-common
  libgutenprint2 libgutenprint9 libinstpatch-1.0-2 libmetacity1 libmozjs-52-0 libmozjs-68-0
  libmtp-common libmtp-runtime libmtp9 libmutter-6-0 liboauth0 libparted-fs-resize0
  libperl5.26 libphonenumber7 libprotobuf10 libpython2.7 libqpdf21 libtracker-control-2.0-0
  libtracker-miner-2.0-0 libtracker-sparql-2.0-0 libudisks2-0 libusbmuxd4 libvpx6
  libzeitgeist-2.0-0 linux-headers-4.15.0-166 linux-headers-4.15.0-166-generic
  linux-image-4.15.0-166-generic linux-modules-4.15.0-166-generic
  linux-modules-extra-4.15.0-166-generic mate-desktop-common metacity-common onboard-common
  pkg-config printer-driver-gutenprint python-crypto python-talloc python3-ibus-1.0 qpdf
  run-one sgml-base tracker tracker-extract tracker-miner-fs udisks2 xubuntu-icon-theme
  xwayland yaru-theme-gnome-shell yelp-xsl zenity-common
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  atril atril-common brltty brltty-x11 e2fsprogs initramfs-tools initramfs-tools-bin
  initramfs-tools-core klibc-utils libatrildocument3 libatrilview3 libbrlapi0.7 libklibc
  liblouis20 libpcre2-32-0 libsoup2.4-1 libsynctex2 libwebkit2gtk-4.0-37 logsave lz4
Suggested packages:
  caja unrar brltty-speechd console-braille gpart fuse2fs e2fsck-static
Recommended packages:
  gvfs e2fsprogs-l10n
The following NEW packages will be installed:
  initramfs-tools initramfs-tools-core klibc-utils libbrlapi0.7 liblouis20 libpcre2-32-0
  libsynctex2 libwebkit2gtk-4.0-37 logsave lz4
The following packages will be upgraded:
  atril atril-common brltty brltty-x11 e2fsprogs initramfs-tools-bin libatrildocument3
  libatrilview3 libklibc libsoup2.4-1
10 upgraded, 10 newly installed, 0 to remove and 921 not upgraded.
3 not fully installed or removed.
Need to get 0 B/19.1 MB of archives.
After this operation, 71.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 248701 files and directories currently installed.)
Preparing to unpack .../e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking e2fsprogs (1.45.5-2ubuntu1.1) over (1.44.1-1ubuntu1.4) ...
dpkg: error processing archive /var/cache/apt/archives/e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb (--unpack):
 unable to make backup link of './usr/bin/chattr' before installing new version: Operation not permitted
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
dpkg: considering deconfiguration of e2fsprogs, which would be broken by installation of logsave ...
dpkg: no, e2fsprogs is essential, will not deconfigure
 it in order to enable installation of logsave
dpkg: error processing archive /var/cache/apt/archives/logsave_1.45.5-2ubuntu1.1_amd64.deb (--unpack):
 installing logsave would break existing software
Errors were encountered while processing:
 /var/cache/apt/archives/e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb
 /var/cache/apt/archives/logsave_1.45.5-2ubuntu1.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
这一步的报错的主要信息有下面的两个。

2ubuntu1.1_amd64.deb (--unpack):
 unable to make backup link of './usr/bin/chattr' before installing new version: Operation not permitted
这个提示 chattr 的一开始没听过,直接被我忽略了,甚至怀疑和 ssh 有关,后面证明这个报错才是关键。之后的报错其实是后来的结果和提示,我却一直拿下面的内容搜索,但是一直搜索不到有用的内容。大概就是说 e2fsprogs 和 logsave 在安装的时候出问题了。e2fsprogs 都是系统底层的关键库,和文件系统相关,那如果坏了可能就得重装系统了……

dpkg: considering deconfiguration of e2fsprogs, which would be broken by installation of logsave ...
dpkg: no, e2fsprogs is essential, will not deconfigure
 it in order to enable installation of logsave
之后重新回来搜索第一个 chattr 的报错,结果找到了下面的链接,最终引导我解决了问题。上面第一个报错说 无法给 chattr 做备份链接,Operation not permitted。这就很有意思了,我是 root 都不允许。结果证实还是经验少,这个报错是经典的 chattr 用来管理文件安全的一个报错。除了我们习惯的 chmod 对用户的读写执行进行约束,chattr 也可以进一步约束文件不可以删除或者只可以 append 等等,具体大家可以 google 一下 chattr 这个库。

https://forum.howtoforge.com/threads/big-mistake-removed-e2fsprogs.75729/
https://forum.howtoforge.com/threads/big-mistake-removed-e2fsprogs.75729/
事后推测原因是 chattr 这个库坏了,而这个库给很多系统敏感文件都加了禁止删除,包括他自己。更新这个库的时候应该要把这些库文件的禁止删除取消,但是它在这里出问题了。于是按照连接中的方法,去下载了 e2fsprogs 的 pkg 包。

https://ubuntu.pkgs.org/20.04/ubuntu-updates-main-amd64/e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb.html
https://ubuntu.pkgs.org/20.04/ubuntu-updates-main-amd64/e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb.html
下载后的 pkg 包是可以解压的,解压以后,在解压后的 /usr/bin/ 可以找到 chattr and lsattr 这两个可执行文件。于是我们用这里的 chattr 取消系统里 chattr 和 lsattr 的保护,然后手动删除。

./chattr -ia /usr/bin/chattr
./chattr -ia /usr/bin/lsattr
rm /usr/bin/chattr 
rm /usr/bin/lsattr 
之后 apt upgrade ,安装顺利进行,问题解决
————————————————
原文链接:https://blog.csdn.net/Haulyn5/article/details/127495565

猜你喜欢

转载自blog.csdn.net/txl910514/article/details/130142499