04月30, 2025

Debian 12升级systemd时报错

报错如下:

root@GGG: /opt # apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libnss-systemd : Depends: systemd (= 252.36-1~deb12u1) but 252.26-1~deb12u2 is installed
 libpam-systemd : Depends: systemd (= 252.36-1~deb12u1) but 252.26-1~deb12u2 is installed
 systemd : Depends: libsystemd-shared (= 252.26-1~deb12u2) but 252.36-1~deb12u1 is installed
           Depends: libsystemd0 (= 252.26-1~deb12u2)
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

接着执行apt --fix-broken install仍然报错如下:

root@GGG: /lib # apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
  systemd-container systemd-homed systemd-userdbd systemd-boot systemd-resolved libtss2-esys-3.0.2-0 libtss2-mu0 libtss2-rc0
The following packages will be upgraded:
  systemd
1 upgraded, 0 newly installed, 0 to remove and 150 not upgraded.
13 not fully installed or removed.
Need to get 0 B/3,037 kB of archives.
After this operation, 5,120 B of additional disk space will be used.
Reading changelogs... Done
(Reading database ... 73375 files and directories currently installed.)
Preparing to unpack .../systemd_252.36-1~deb12u1_amd64.deb ...
Unpacking systemd (252.36-1~deb12u1) over (252.26-1~deb12u2) ...
dpkg: error processing archive /var/cache/apt/archives/systemd_252.36-1~deb12u1_amd64.deb (--unpack):
 unable to make backup link of './lib/systemd/systemd-shutdown' before installing new version: Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/systemd_252.36-1~deb12u1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

看起来是权限问题,/lib/systemd/systemd-shutdown文件无法修改。

尝试了很多办法,包括lsof查看文件占用、lsattr查看文件属性等等,都不起作用。

最后尝试了reboot也仍然不行。突然想到先关机再开机,而不是重启,结果就好了。只是仍然不知道为什么。

本文链接:https://debug.fanzheng.org/post/Debian 12-sheng-ji-systemd-shi-bao-cuo.html

-- EOF --

Comments