apt autoremove não pode remover pacotes linux-image

3

Eu pareço ter corrompido meu banco de dados apt e não tenho idéia de como repará-lo. Ele falha em todos os comandos que envolvem linux-image-4.4.0-22-generic and linux-image-extra-4.4.0-22-generic . Aqui está a saída do console depois de executar sudo apt autoremove .

jonathan@Aristotle:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-4.4.0-22 linux-headers-4.4.0-22-generic linux-image-4.4.0-22-generic linux-image-extra-4.4.0-22-generic
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 295 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 268155 files and directories currently installed.)
Removing linux-headers-4.4.0-22-generic (4.4.0-22.40) ...
Removing linux-headers-4.4.0-22 (4.4.0-22.40) ...
Removing linux-image-extra-4.4.0-22-generic (4.4.0-22.40) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-4.4.0-22-generic (4.4.0-22.40) ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
dkms: removing: bbswitch 0.8 (4.4.0-22-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  bbswitch
Version: 0.8
Kernel:  4.4.0-22-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

bbswitch.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.
dkms: removing: nvidia-340 340.96 (4.4.0-22-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  nvidia-340
Version: 340.96
Kernel:  4.4.0-22-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

nvidia_340.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


nvidia_340_uvm.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.
dkms: removing: virtualbox 5.0.18 (4.4.0-22-generic) (x86_64)

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 5.0.18
Kernel:  4.4.0-22-generic (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxdrv.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetadp.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxnetflt.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vboxpci.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.4.0-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-4.4.0-22-generic.postrm line 328.
dpkg: error processing package linux-image-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-22-generic
 linux-image-4.4.0-22-generic

E: Subprocesso / usr / bin / dpkg retornou um código de erro (1)

Eu adicionei uma corrida com o dpkg usando a depuração completa, na qual eu tentei remover o linux-image-4.4.0-22-generic e o linux-image-extra-4.4.0-22-generic.

jonathan@Aristotle:~$ sudo dpkg -D73773 -r linux-image-extra-4.4.0-22-generic linux-image-4.4.0-22-generic
D000001: ensure_diversions: new, (re)loading
D000001: process queue pkg linux-image-extra-4.4.0-22-generic:amd64 queue.len 1 progress 1, try 1
D000001: deferred_remove package linux-image-extra-4.4.0-22-generic:amd64
D000001: checking dependencies for remove 'linux-image-extra-4.4.0-22-generic:amd64'
(Reading database ... 235952 files and directories currently installed.)
Removing linux-image-extra-4.4.0-22-generic (4.4.0-22.40) ...
D020000: trigproc_activate_packageprocessing pkg=linux-image-extra-4.4.0-22-generic:amd64
D000001: removal_bulk package linux-image-extra-4.4.0-22-generic:amd64
D000002: fork/exec /var/lib/dpkg/info/linux-image-extra-4.4.0-22-generic.postrm ( remove )
depmod: FATAL: could not load /boot/System.map-4.4.0-22-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-22-generic
WARNING: missing /lib/modules/4.4.0-22-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/4.4.0-22-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_dJ1Z6g/lib/modules/4.4.0-22-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_dJ1Z6g/lib/modules/4.4.0-22-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
D020000: post_script_tasks - ensure_diversions
D000001: ensure_diversions: same, skipping
D020000: post_script_tasks - trig_incorporate
D000001: process queue pkg linux-image-4.4.0-22-generic:amd64 queue.len 0 progress 1, try 1
D000001: deferred_remove package linux-image-4.4.0-22-generic:amd64
D000001: checking dependencies for remove 'linux-image-4.4.0-22-generic:amd64'
D000040: checking depending package 'linux-image-extra-4.4.0-22-generic:amd64'
D000040: checking virtual package 'fuse-module'
D000040: checking virtual package 'ivtv-modules'
D000040: checking virtual package 'kvm-api-4'
D000040: checking virtual package 'linux-image'
D000040: checking virtual package 'redhat-cluster-modules'
D000040: checking virtual package 'spl-dkms'
D000040: checking virtual package 'virtualbox-guest-modules'
D000040: checking virtual package 'zfs-dkms'
Removing linux-image-4.4.0-22-generic (4.4.0-22.40) ...
D020000: trigproc_activate_packageprocessing pkg=linux-image-4.4.0-22-generic:amd64
D000001: removal_bulk package linux-image-4.4.0-22-generic:amd64
D000002: fork/exec /var/lib/dpkg/info/linux-image-4.4.0-22-generic.postrm ( remove )
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-4.4.0-22-generic.postrm line 328.
dpkg: error processing package linux-image-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
D020000: post_script_tasks - ensure_diversions
D000001: ensure_diversions: same, skipping
D020000: post_script_tasks - trig_incorporate
D010000: trigproc_run_deferred
Errors were encountered while processing:
 linux-image-extra-4.4.0-22-generic
 linux-image-4.4.0-22-generic

Esta corrida sugere que eu vou ter que cavar os scripts de baixo nível para determinar o que está acontecendo. Existem realmente três problemas aqui:

  • Como o banco de dados foi corrompido em primeiro lugar?
  • Por que o dpkg não pode se recuperar do erro ao tentar remover os pacotes?
  • Qual procedimento de reparo está disponível.

Eu fiz uma nova execução usando a opção dpkg --force remove-reinstreq com o seguinte resultado.

jonathan@Aristotle:~$ sudo dpkg -D73773 --force remove-reinstreq -r linux-image-extra-4.4.0-22-generic linux-image-4.4.0-22-generic
[sudo] password for jonathan: 
D000001: ensure_diversions: new, (re)loading
D000001: process queue pkg linux-image-extra-4.4.0-22-generic:amd64 queue.len 1 progress 1, try 1
D000001: deferred_remove package linux-image-extra-4.4.0-22-generic:amd64
D000001: checking dependencies for remove 'linux-image-extra-4.4.0-22-generic:amd64'
(Reading database ... 235952 files and directories currently installed.)
Removing linux-image-extra-4.4.0-22-generic (4.4.0-22.40) ...
D020000: trigproc_activate_packageprocessing pkg=linux-image-extra-4.4.0-22-generic:amd64
D000001: removal_bulk package linux-image-extra-4.4.0-22-generic:amd64
D000002: fork/exec /var/lib/dpkg/info/linux-image-extra-4.4.0-22-generic.postrm ( remove )
depmod: FATAL: could not load /boot/System.map-4.4.0-22-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.4.0-22-generic cannot be found.
Please install the linux-headers-4.4.0-22-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-22-generic
WARNING: missing /lib/modules/4.4.0-22-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/4.4.0-22-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_g7jrQG/lib/modules/4.4.0-22-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_g7jrQG/lib/modules/4.4.0-22-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
D020000: post_script_tasks - ensure_diversions
D000001: ensure_diversions: same, skipping
D020000: post_script_tasks - trig_incorporate
D000001: process queue pkg linux-image-4.4.0-22-generic:amd64 queue.len 0 progress 1, try 1
D000001: deferred_remove package linux-image-4.4.0-22-generic:amd64
D000001: checking dependencies for remove 'linux-image-4.4.0-22-generic:amd64'
D000040: checking depending package 'linux-image-extra-4.4.0-22-generic:amd64'
D000040: checking virtual package 'fuse-module'
D000040: checking virtual package 'ivtv-modules'
D000040: checking virtual package 'kvm-api-4'
D000040: checking virtual package 'linux-image'
D000040: checking virtual package 'redhat-cluster-modules'
D000040: checking virtual package 'spl-dkms'
D000040: checking virtual package 'virtualbox-guest-modules'
D000040: checking virtual package 'zfs-dkms'
Removing linux-image-4.4.0-22-generic (4.4.0-22.40) ...
D020000: trigproc_activate_packageprocessing pkg=linux-image-4.4.0-22-generic:amd64
D000001: removal_bulk package linux-image-4.4.0-22-generic:amd64
D000002: fork/exec /var/lib/dpkg/info/linux-image-4.4.0-22-generic.postrm ( remove )
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-22-generic /boot/vmlinuz-4.4.0-22-generic
Generating grub configuration file ...
grub-probe: error: not a directory.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-4.4.0-22-generic.postrm line 328.
dpkg: error processing package linux-image-4.4.0-22-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
D020000: post_script_tasks - ensure_diversions
D000001: ensure_diversions: same, skipping
D020000: post_script_tasks - trig_incorporate
D010000: trigproc_run_deferred
Errors were encountered while processing:
 linux-image-extra-4.4.0-22-generic
 linux-image-4.4.0-22-generic

O problema imediato parece ser que depmod encontra erros fatais porque não pode acessar os arquivos /boot/System.map-4.4.0-22-generic and /lib/modules/4.4.0-22-generic que parecem ter sido excluídos em uma execução anterior que encontrou um erro fatal depois de excluí-los.

Isso sugere que não será possível determinar a causa original da situação e nos deixa com dois problemas:

  • Por que o dpkg com a opção --force remove-reinstreq não pode concluir o processo de remoção desses dois arquivos?
  • Qual procedimento de reparo está disponível para recuperação da situação atual.

Parece-me que o primeiro ponto pode ser tratado como um bug no sistema dpkg, mas eu ainda não tive a chance de ver se este é o caso. Em qualquer caso, será um problema potencialmente difícil de resolver, porque o banco de dados está agora em um estado completamente inconsistente, como resultado da remoção física desses arquivos, sem concluir o processo de remoção.

O segundo ponto é a minha prioridade atual e eu preciso saber se há alguma maneira de reinstalar o Ubuntu para reparar o banco de dados.

Alguém tem sugestões sobre como resolver esses problemas?

    
por Jonathan 30.06.2016 / 16:55

3 respostas

0

Eu bati completamente o ubuntu 14.04 em um terminal apenas, removendo a meta-cidade.
Tudo foi reinstalado com

sudo apt-get install --reinstalar o ubuntu-desktop

espero que isso ajude!

    
por Dan 01.07.2016 / 19:04
0

Parece que o grub não está configurado corretamente. Dê uma olhada neste link tente consertar o grub e ele deve passar.

    
por stingray 01.07.2016 / 19:09
-1

Este parece ser um bug onde o script de remoção para a imagem linux não percebe que é para removê-lo e tenta recriar os arquivos vmlinux. Espero que o bug seja corrigido em breve.

    
por Edmund Broadley 17.07.2016 / 10:33