「update-initramfs: /boot/initrd.img-5.4.0-92-generic を生成しています」で止まっています

「update-initramfs: /boot/initrd.img-5.4.0-92-generic を生成しています」で止まっています

サーバー(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

これらのプロセスを終了した後、再度パッケージ削除コマンドを実行して次の結果を取得します。

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

関連情報