Não é possível remover ou instalar o kernel

1

Eu acidentalmente excluí minha partição /boot , mas consegui recuperá-la com grub-install

Estou tentando fazer chroot e instalar os kernels novamente através deste guia: Como restaurar um sistema após a remoção acidental de todos os kernels?

No entanto, quando tentei remover ou instalar o pacote, recebi o seguinte erro:

root @ ubuntu: / # apt-get install -f

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  thermald
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  linux-image-extra-4.2.0-25-generic
0 upgraded, 0 newly installed, 1 to remove and 33 not upgraded.
2 not fully installed or removed.
After this operation, 162 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 411666 files and directories currently installed.)
Removing linux-image-extra-4.2.0-25-generic (4.2.0-25.30) ...
depmod: FATAL: could not load /boot/System.map-4.2.0-25-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Running in chroot, ignoring request.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.2.0-25-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.2.0-25-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Atualização: parece estar preso no seguinte comando

root@ubuntu:/# update-initramfs -c -t -k 4.2.0-25-generic -b /boot
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file

root @ ubuntu: / # ls -l / boot

ubuntu @ ubuntu: ~ $ ls -l / boot

total 5430
-rw-r--r-- 1 root root 1268815 Apr 17  2015 abi-3.19.0-15-generic
-rw-r--r-- 1 root root  177656 Apr 17  2015 config-3.19.0-15-generic
drwxr-xr-x 1 root root      60 Jan 20 21:39 grub
-rw-r--r-- 1 root root  164216 Mar  6  2015 memtest86+.bin
-rw-r--r-- 1 root root  165892 Mar  6  2015 memtest86+.elf
-rw-r--r-- 1 root root  166396 Mar  6  2015 memtest86+_multiboot.bin
-rw------- 1 root root 3615358 Apr 17  2015 System.map-3.19.0-15-generic

root @ ubuntu: / # apt-get install --reinstall linux-image-4.2.0-25-generic

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 33 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for linux-image-4.2.0-25-generic:amd64

root @ ubuntu: / # dpkg --configurar linux-image-4.2.0-25-genérico

Setting up linux-image-4.2.0-25-generic (4.2.0-25.30) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
initrd.img(/boot/initrd.img-4.2.0-25-generic
) points to /boot/initrd.img-4.2.0-25-generic
 (/boot/initrd.img-4.2.0-25-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 491.
vmlinuz(/boot/vmlinuz-4.2.0-25-generic
) points to /boot/vmlinuz-4.2.0-25-generic
 (/boot/vmlinuz-4.2.0-25-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Running in chroot, ignoring request.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 1025.
dpkg: error processing package linux-image-4.2.0-25-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 linux-image-4.2.0-25-generic

Como posso corrigir isso?

    
por Tek 20.01.2016 / 22:52

1 resposta

2

Houve uma dica acima de não ser possível processar algo sobre postinst.d , então olhei para quais scripts ele estava sendo executado e os encontrei.

Eu fiz um rm -rf /var/lib/dpkg/info/linux-image-4.2.0-25-generic.* que tinha alguns arquivos .postrm e .list que estavam sendo usados e que eram defeituosos por qualquer motivo. Eu os removi, corri dpkg --configure -a e não mais erros de reinstalação! Yay. Obrigado a todos por me apontar na direção certa. Houve outra dica sobre a reinstalação do grub, que fiz com o Boot Repair e, depois disso, consegui identificar melhor onde as coisas estavam quebradas.

    
por Tek 21.01.2016 / 01:31