![卡在“update-initramfs:正在生成 /boot/initrd.img-5.4.0-92-generic”](https://linux22.com/image/776424/%E5%8D%A1%E5%9C%A8%E2%80%9Cupdate-initramfs%EF%BC%9A%E6%AD%A3%E5%9C%A8%E7%94%9F%E6%88%90%20%2Fboot%2Finitrd.img-5.4.0-92-generic%E2%80%9D.png)
我在卸载服务器(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 PID 并将ps -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