Tenho um problema ao desinstalar pacotes no meu servidor (20.04 LTS).
Quando executo apt remove metricbeat
recebo esta mensagem:
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%] [############################################.......]
Ele congela nesta etapa, ctrl+c ctrl+z não funcionou. Abro outra conexão ssh, executo novamente apt remove metricbeat
e recebo esta mensagem:
^Citing for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1890890 (apt)... 1s
Eu encontrei o apt PID ps -aux | grep apt
e matei-o. Em seguida, execute novamente o comando remove agora:
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
Processos em execução do 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
depois de encerrar esses processos, execute novamente o comando package remove e obtenha:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
então corri sudo dpkg --configure -a
e travei nesta etapa:
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
Por 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
Eu verifiquei o /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#
Acho que tem alguns problemas initrd.img-5.4.0-92-generic
e não sei como posso resolver. esse ciclo aconteceu repetidas vezes.
Responder1
Quanto tempo você está esperando? Eu sei que tive que esperar vários minutos enquanto isso acontecia update-initramfs: Generating /boot/initrd.img
. Experimente pegar um café e assistir TV quando chegar.
Responder2
Tente executar update-initramfs
no modo detalhado para ver em qual módulo ele trava:
update-initramfs -v -u
Ou ps
pode mostrar qual gancho está em execução no momento:
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