我在伺服器 (20.04 LTS) 上卸載軟體包時遇到問題。
當我運行時apt remove metricbeat
收到此訊息:
root@elk:/home/elk# apt remove metricbeat
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
metricbeat
0 upgraded, 0 newly installed, 1 to remove and 183 not upgraded.
1 not fully installed or removed.
After this operation, 182 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 151385 files and directories currently installed.)
Removing metricbeat (7.16.2) ...
Setting up linux-image-5.4.0-92-generic (5.4.0-92.103) ...
Processing triggers for linux-image-5.4.0-92-generic (5.4.0-92.103) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-92-generic
Progress: [ 80%] [############################################.......]
它在這一步驟凍結,ctrl+c ctrl+z 不起作用。我打開另一個 ssh 連線並再次運行apt remove metricbeat
並收到以下訊息:
^Citing for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1890890 (apt)... 1s
我找到了apt PIDps -aux | grep apt
並殺死了它。然後再次運行刪除命令:
root@elk:/home/elk# apt remove metricbeat
^Citing for cache lock: Could not get lock /var/lib/dpkg/lock. It is held by process 1891272 (dpkg)... 1s
dpkg運行進程:
root 1891272 0.0 0.0 11136 5328 ? Ss 14:47 0:00 /usr/bin/dpkg --status-fd 42 --configure --pending
root 1891282 0.0 0.0 2608 608 ? S 14:47 0:00 /bin/sh /var/lib/dpkg/info/linux-image-5.4.0-92-generic.postinst triggered linux-update-5.4.0-92-generic
殺死這些進程後,再次執行 package remove 命令並取得:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
所以我跑了sudo dpkg --configure -a
,它卡在了這一步:
root@elk:/home/elk# dpkg --configure -a
Setting up linux-image-5.4.0-92-generic (5.4.0-92.103) ...
Processing triggers for linux-image-5.4.0-92-generic (5.4.0-92.103) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-92-generic
通過 ctrl+c :
error processing package linux-image-5.4.0-92-generic (--configure):
installed linux-image-5.4.0-92-generic package post-installation script subprocess was interrupted
Errors were encountered while processing:
linux-image-5.4.0-92-generic
我檢查了 /boot :
root@elk:/boot# ls -lh
total 218M
-rw-r--r-- 1 root root 233K Apr 20 2020 config-5.4.0-26-generic
-rw-r--r-- 1 root root 233K Nov 5 16:02 config-5.4.0-91-generic
-rw-r--r-- 1 root root 233K Nov 26 14:42 config-5.4.0-92-generic
drwxr-xr-x 4 root root 4.0K Apr 9 08:14 grub
lrwxrwxrwx 1 root root 27 Apr 9 08:14 initrd.img -> initrd.img-5.4.0-92-generic
-rw-r--r-- 1 root root 78M Feb 15 2021 initrd.img-5.4.0-26-generic
-rw-r--r-- 1 root root 81M Dec 9 06:37 initrd.img-5.4.0-91-generic
-rw-r--r-- 1 root root 0 Apr 9 14:58 initrd.img-5.4.0-92-generic.new
lrwxrwxrwx 1 root root 27 Jan 5 06:48 initrd.img.old -> initrd.img-5.4.0-91-generic
-rw------- 1 root root 4.6M Apr 20 2020 System.map-5.4.0-26-generic
-rw------- 1 root root 4.6M Nov 5 16:02 System.map-5.4.0-91-generic
-rw------- 1 root root 4.6M Nov 26 14:42 System.map-5.4.0-92-generic
lrwxrwxrwx 1 root root 24 Jan 5 06:48 vmlinuz -> vmlinuz-5.4.0-92-generic
-rw------- 1 root root 12M Apr 20 2020 vmlinuz-5.4.0-26-generic
-rw------- 1 root root 12M Nov 5 16:04 vmlinuz-5.4.0-91-generic
-rw------- 1 root root 14M Nov 26 14:45 vmlinuz-5.4.0-92-generic
lrwxrwxrwx 1 root root 24 Jan 5 06:48 vmlinuz.old -> vmlinuz-5.4.0-91-generic
root@elk:/boot#
我認為它有一些問題initrd.img-5.4.0-92-generic
,我不知道如何解決。這樣的循環一次又一次地發生。
答案1
你要等多久?我知道在它執行的過程中我必須等待幾分鐘update-initramfs: Generating /boot/initrd.img
。當它到達時,試著喝杯咖啡,看看電視。
答案2
嘗試update-initramfs
在詳細模式下運行,看看它卡在哪個模組上:
update-initramfs -v -u
或者ps
可能會顯示目前正在運行哪個鉤子:
ps f | grep initram
24830 pts/1 S+ 0:00 \_ /bin/sh -e /etc/kernel/postinst.d/initramfs-tools 4.19.0-21-amd64 /boot/vmlinuz-4.19.0-21-amd64
24832 pts/1 S+ 0:00 \_ /bin/sh /usr/sbin/update-initramfs -c -k 4.19.0-21-amd64 -b /boot
24834 pts/1 S+ 0:00 \_ /bin/sh /usr/sbin/mkinitramfs -o /boot/initrd.img-4.19.0-21-amd64.new 4.19.0-21-amd64
28372 pts/1 S+ 0:00 \_ /bin/sh /usr/share/initramfs-tools/hooks/mdadm