AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / ubuntu / Perguntas / 1496999
Accepted
raphael75
raphael75
Asked: 2023-12-15 00:47:30 +0800 CST2023-12-15 00:47:30 +0800 CST 2023-12-15 00:47:30 +0800 CST

Não é possível limpar kernels antigos

  • 772

Eu tenho o Ubuntu 20.04. Tenho tido problemas com a pasta /boot ficando sem espaço.

$ sudo apt list --installed | grep linux-image

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

linux-image-5.11.0-38-generic/focal-updates,focal-security,now 5.11.0-38.42~20.04.1 amd64 [installed]
linux-image-5.11.0-40-generic/focal-updates,focal-security,now 5.11.0-40.44~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-41-generic/focal-updates,focal-security,now 5.11.0-41.45~20.04.1 amd64 [installed,automatic]
linux-image-5.11.0-43-generic/focal-updates,focal-security,now 5.11.0-43.47~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-44-generic/focal-updates,focal-security,now 5.11.0-44.48~20.04.2 amd64 [installed,automatic]
linux-image-5.11.0-46-generic/focal-updates,focal-security,now 5.11.0-46.51~20.04.1 amd64 [installed]
linux-image-5.13.0-25-generic/focal-updates,focal-security,now 5.13.0-25.26~20.04.1 amd64 [installed]
linux-image-5.13.0-27-generic/focal-updates,focal-security,now 5.13.0-27.29~20.04.1 amd64 [installed]
linux-image-5.13.0-28-generic/focal-updates,focal-security,now 5.13.0-28.31~20.04.1 amd64 [installed]
linux-image-5.13.0-30-generic/focal-updates,focal-security,now 5.13.0-30.33~20.04.1 amd64 [installed]
linux-image-5.13.0-35-generic/focal-updates,focal-security,now 5.13.0-35.40~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-37-generic/focal-updates,focal-security,now 5.13.0-37.42~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-48-generic/focal-updates,focal-security,now 5.13.0-48.54~20.04.1 amd64 [installed,automatic]
linux-image-5.13.0-51-generic/focal-updates,focal-security,now 5.13.0-51.58~20.04.1 amd64 [installed]
linux-image-5.13.0-52-generic/focal-updates,focal-security,now 5.13.0-52.59~20.04.1 amd64 [installed]
linux-image-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 [installed]
linux-image-5.15.0-43-generic/focal-updates,focal-security,now 5.15.0-43.46~20.04.1 amd64 [installed]
linux-image-5.15.0-46-generic/focal-updates,focal-security,now 5.15.0-46.49~20.04.1 amd64 [installed]
linux-image-5.15.0-48-generic/focal-updates,focal-security,now 5.15.0-48.54~20.04.1 amd64 [installed]
linux-image-5.15.0-50-generic/focal-updates,focal-security,now 5.15.0-50.56~20.04.1 amd64 [installed]
linux-image-5.15.0-52-generic/focal-updates,focal-security,now 5.15.0-52.58~20.04.1 amd64 [installed]
linux-image-5.15.0-53-generic/focal-updates,focal-security,now 5.15.0-53.59~20.04.1 amd64 [installed]
linux-image-5.15.0-56-generic/focal-updates,focal-security,now 5.15.0-56.62~20.04.1 amd64 [installed]
linux-image-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-image-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed]
linux-image-5.15.0-67-generic/focal-updates,focal-security,now 5.15.0-67.74~20.04.1 amd64 [installed]
linux-image-5.15.0-69-generic/focal-updates,focal-security,now 5.15.0-69.76~20.04.1 amd64 [installed]
linux-image-5.15.0-71-generic/focal-updates,focal-security,now 5.15.0-71.78~20.04.1 amd64 [installed]
linux-image-5.15.0-79-generic/focal-updates,focal-security,now 5.15.0-79.86~20.04.2 amd64 [installed]
linux-image-5.15.0-82-generic/focal-updates,focal-security,now 5.15.0-82.91~20.04.1 amd64 [installed]
linux-image-5.15.0-84-generic/focal-updates,focal-security,now 5.15.0-84.93~20.04.1 amd64 [installed]
linux-image-5.15.0-87-generic/focal-updates,focal-security,now 5.15.0-87.97~20.04.1 amd64 [installed]
linux-image-5.15.0-88-generic/focal-updates,focal-security,now 5.15.0-88.98~20.04.1 amd64 [installed]
linux-image-5.15.0-91-generic/focal-updates,focal-security,now 5.15.0-91.101~20.04.1 amd64 [installed]
linux-image-5.8.0-59-generic/focal-updates,focal-security,now 5.8.0-59.66~20.04.1 amd64 [installed]
linux-image-5.8.0-63-generic/focal-updates,focal-security,now 5.8.0-63.71~20.04.1 amd64 [installed]
linux-image-generic-hwe-20.04/focal-updates,focal-security,now 5.15.0.91.101~20.04.48 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-27-generic/focal-updates,focal-security,now 5.11.0-27.29~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-34-generic/focal-updates,focal-security,now 5.11.0-34.36~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-36-generic/focal-updates,focal-security,now 5.11.0-36.40~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.11.0-37-generic/focal-updates,focal-security,now 5.11.0-37.41~20.04.2 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-39-generic/focal-updates,focal-security,now 5.13.0-39.44~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-40-generic/focal-updates,focal-security,now 5.13.0-40.45~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-41-generic/focal-updates,focal-security,now 5.13.0-41.46~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.13.0-44-generic/focal-updates,focal-security,now 5.13.0-44.49~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-70-generic/focal-updates,focal-security,now 5.15.0-70.77~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-72-generic/focal-updates,focal-security,now 5.15.0-72.79~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-73-generic/focal-updates,focal-security,now 5.15.0-73.80~20.04.1 amd64 [installed,automatic]
linux-image-unsigned-5.15.0-86-generic/focal-updates,focal-security,now 5.15.0-86.96~20.04.1 amd64 [installed,automatic]

/boot conteúdo da pasta:

$ ls -l /boot
total 342408
-rw-r--r-- 1 root root    262258 Aug 18 10:34 config-5.15.0-82-generic
-rw-r--r-- 1 root root    262265 Nov 16 08:58 config-5.15.0-91-generic
drwx------ 3 root root      4096 Dec 31  1969 efi
drwxr-xr-x 4 root root      4096 Dec 14 11:32 grub
-rw-r--r-- 1 root root 129102715 Sep 19 07:56 initrd.img-5.15.0-82-generic
-rw-r--r-- 1 root root  55717600 Dec 14 11:30 initrd.img-5.15.0-86-generic
-rw-r--r-- 1 root root 129129902 Dec 14 10:45 initrd.img-5.15.0-91-generic
lrwxrwxrwx 1 root root        28 Dec 14 11:30 initrd.img.old -> initrd.img-5.15.0-91-generic
drwx------ 2 root root     16384 Jun  9  2021 lost+found
-rw-r--r-- 1 root root    182704 Aug 18  2020 memtest86+.bin
-rw-r--r-- 1 root root    184380 Aug 18  2020 memtest86+.elf
-rw-r--r-- 1 root root    184884 Aug 18  2020 memtest86+_multiboot.bin
-rw------- 1 root root   6240491 Aug 18 10:34 System.map-5.15.0-82-generic
-rw------- 1 root root   6242483 Nov 16 08:58 System.map-5.15.0-91-generic
lrwxrwxrwx 1 root root        25 Dec 14 11:30 vmlinuz -> vmlinuz-5.11.0-25-generic
-rw------- 1 root root  11522568 Aug 18 12:03 vmlinuz-5.15.0-82-generic
-rw------- 1 root root  11517416 Nov 16 09:01 vmlinuz-5.15.0-91-generic
lrwxrwxrwx 1 root root        25 Dec 14 11:30 vmlinuz.old -> vmlinuz-5.15.0-91-generic

Se eu correr:

sudo apt remove --purge linux-image-unsigned-5.11.0-25-generic

Eu recebo:

$ sudo apt remove --purge linux-image-unsigned-5.11.0-25-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-modules-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
                                            linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
 linux-modules-extra-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
                                                  linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
 linux-signatures-nvidia-5.11.0-25-generic : Depends: linux-image-5.11.0-25-generic but it is not going to be installed or
                                                      linux-image-unsigned-5.11.0-25-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Se eu executar o comando, ele sugere:

$ sudo apt --fix-broken install

Mostra (mudando para pastebin para liberar caracteres):

https://pastebin.com/FmpseWKi

/tamanho da partição de inicialização

$ df -h | grep boot
/dev/nvme0n1p2             704M  343M  310M  53% /boot
/dev/nvme0n1p1             511M   87M  425M  17% /boot/efi

Não sei como limpar esses kernels antigos e como evitar que a pasta /boot fique cheia.

ATUALIZAÇÃO Tentei usar o Synaptic conforme sugerido pelo usuário68186 (e também foi sugerido nos links postados). Quando tentei desinstalar apenas linux-image-5.13.0-25-generic , ele também quis instalar linux-image-unsigned-5.13.0-25-generic . Eu li aqui A remoção do kernel linux-image faz com que o pacote linux-image-unsigned seja instalado porque preciso remover também o pacote de módulos correspondente . Selecionei linux-modules-extra-5.13.0-25-generic e linux-image-5.13.0-25-generic e foi isso que obtive:

(Reading database ... 2036888 files and directories currently installed.)
Removing linux-signatures-nvidia-5.13.0-25-generic (5.13.0-25.26~20.04.1+1) ...
Removing linux-modules-extra-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Removing linux-modules-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Removing linux-image-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.15.0-82-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.15.0-82-generic
I: /boot/vmlinuz is now a symlink to vmlinuz-5.15.0-91-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.15.0-91-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.13.0-25-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Setting up linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
Setting up linux-image-5.13.0-48-generic (5.13.0-48.54~20.04.1) ...
Setting up linux-image-unsigned-5.15.0-73-generic (5.15.0-73.80~20.04.1) ...
Setting up linux-image-unsigned-5.13.0-39-generic (5.13.0-39.44~20.04.1) ...
(Reading database ... 2029733 files and directories currently installed.)
Purging configuration files for linux-modules-5.13.0-25-generic (5.13.0-25.26~20.04.1) ...
Processing triggers for linux-image-5.13.0-48-generic (5.13.0-48.54~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.13.0-48-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.0-48-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.15.0-73-generic (5.15.0-73.80~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.15.0-73-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.15.0-73-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.13.0-39-generic (5.13.0-39.44~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.13.0-39-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.13.0-39-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-91-generic
Found initrd image: /boot/initrd.img-5.15.0-91-generic
Found linux image: /boot/vmlinuz-5.15.0-82-generic
Found initrd image: /boot/initrd.img-5.15.0-82-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.11.0-36-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-36-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
Error 24 : Write error : cannot write compressed block 
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.11.0-36-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-unsigned-5.11.0-36-generic (--configure):
 installed linux-image-unsigned-5.11.0-36-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-unsigned-5.11.0-36-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Setting up linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
Processing triggers for linux-image-unsigned-5.11.0-36-generic (5.11.0-36.40~20.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.11.0-36-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.11.0-36-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
Error 24 : Write error : cannot write compressed block 
cpio: write error: Broken pipe
sort: write failed: 'standard output': Broken pipe
sort: write error
E: mkinitramfs failure cpio 2 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.11.0-36-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-unsigned-5.11.0-36-generic (--configure):
 installed linux-image-unsigned-5.11.0-36-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-unsigned-5.11.0-36-generic

Você tem alguma sugestão sobre o que fazer aqui?

Atualização 2

eu corri

sudo apt autopurge 

e consegui isso (infelizmente não me permite adicionar mais texto a esta pergunta, então tive que colocá-lo no pastebin):

https://pastebin.com/wb00JM5y

Atualização 3

Finalmente consegui usar o Synaptic para remover os kernels antigos. Por algum motivo, houve um problema com 5.11.0-36 e 5.11.0-25. Era como se eu tivesse que remover 36 primeiro e depois me deixar remover 25. Mas depois de removê-los, consegui remover todos os outros sem erros.

package-management
  • 3 3 respostas
  • 124 Views

3 respostas

  • Voted
  1. noisefloor
    2023-12-15T00:51:48+08:002023-12-15T00:51:48+08:00

    Pacotes não utilizados e necessários para o sistema podem ser removidos com sudo apt autoremoveou sudo apt autopurge. Este último também excluirá os arquivos de configuração (se os pacotes a serem removidos tiverem algum).

    Isso também removerá todos os kernels antigos, os dois mais novos serão mantidos automaticamente.

    • 0
  2. Artur Meinild
    2023-12-15T02:01:27+08:002023-12-15T02:01:27+08:00

    Existe uma ferramenta no Launchpad chamada linux-purgeque limpa facilmente kernels antigos.

    Estas são as instruções de instalação:

    Execute a seguinte cadeia de comando no terminal para instalar o linux-purge em seu sistema:

    sh -c 'cd /tmp && wget -N https://git.launchpad.net/linux-purge/plain/install-linux-purge.sh && chmod +x ./install-linux-purge.sh && sudo ./install-linux-purge.sh && rm ./install-linux-purge.sh' && [ "$BASH" ] && echo Replaced current shell in order to make the Bash completion work. && exec bash
    

    Pode ser solicitada uma senha devido ao uso do sudo com o script.

    Depois disso, basta executá-lo com sudo linux-purgee, por padrão, removerá tudo, exceto os dois kernels mais recentes.

    • 0
  3. Best Answer
    raphael75
    2023-12-18T22:52:59+08:002023-12-18T22:52:59+08:00

    Consegui usar a GUI do Synaptic Package Manager para remover os kernels antigos. Inicialmente tive um problema ao remover os 5.11.0-36 e 5.11.0-25. Recebi erros, a menos que tenha removido o 36 primeiro.

    Descobri que se eu selecionasse os "linux- modules -<version>-generic" ele selecionaria automaticamente os outros pacotes relacionados e isso reduziria o número de pacotes que eu teria que selecionar.

    • 0

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Existe um comando para listar todos os usuários? Também para adicionar, excluir, modificar usuários, no terminal?

    • 9 respostas
  • Marko Smith

    Como excluir um diretório não vazio no Terminal?

    • 4 respostas
  • Marko Smith

    Como descompactar um arquivo zip do Terminal?

    • 9 respostas
  • Marko Smith

    Como instalo um arquivo .deb por meio da linha de comando?

    • 11 respostas
  • Marko Smith

    Como instalo um arquivo .tar.gz (ou .tar.bz2)?

    • 14 respostas
  • Marko Smith

    Como listar todos os pacotes instalados

    • 24 respostas
  • Martin Hope
    Flimm Como posso usar o docker sem sudo? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    led-Zepp Como faço para salvar a saída do terminal em um arquivo? 2014-02-15 11:49:07 +0800 CST
  • Martin Hope
    ubuntu-nerd Como descompactar um arquivo zip do Terminal? 2011-12-11 20:37:54 +0800 CST
  • Martin Hope
    TheXed Como instalo um arquivo .deb por meio da linha de comando? 2011-05-07 09:40:28 +0800 CST
  • Martin Hope
    Ivan Como listar todos os pacotes instalados 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    David Barry Como determino o tamanho total de um diretório (pasta) na linha de comando? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "Os seguintes pacotes foram retidos:" Por que e como resolvo isso? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford Como os PPAs podem ser removidos? 2010-07-30 01:09:42 +0800 CST

Hot tag

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve