Удалить старые ядра Ubuntu

Содержание
Введение
Список установленных ядер
Количество ядер
Узнать сколько осталось места
Удалить устаревшие ядра
Проверить результат
Похожие статьи

Введение

Со временем старые ядра занимают всё больше места в разделе boot

Апофеозом этого процесса является ошибка

the volume boot has only 0 bytes disk space remaining

Хотя обычно Ubuntu предупреждает о нехватке места заранее

Ubuntu boot low space www.andreyolegovich.ru

Решить эту проблему обычно несложно.

Обычно помогает

sudo apt --purge autoremove

Подробности вы можете изучить далее в этой статье.

Список установленных ядер

Получить список всех ядер можно выполнив

dpkg --list | egrep -i --color 'linux-image|linux-headers'

ii linux-headers-5.10.0-1044-oem 5.10.0-1044.46 amd64 Linux kernel headers for version 5.10.0 on 64 bit x86 SMP ii linux-headers-5.10.0-1045-oem 5.10.0-1045.47 amd64 Linux kernel headers for version 5.10.0 on 64 bit x86 SMP ii linux-headers-5.11.0-25-generic 5.11.0-25.27~20.04.1 amd64 Linux kernel headers for version 5.11.0 on 64 bit x86 SMP ii linux-headers-5.11.0-27-generic 5.11.0-27.29~20.04.1 amd64 Linux kernel headers for version 5.11.0 on 64 bit x86 SMP ii linux-headers-5.11.0-34-generic 5.11.0-34.36~20.04.1 amd64 Linux kernel headers for version 5.11.0 on 64 bit x86 SMP ii linux-headers-5.4.0-81 5.4.0-81.91 all Header files related to Linux kernel version 5.4.0 ii linux-headers-5.4.0-81-generic 5.4.0-81.91 amd64 Linux kernel headers for version 5.4.0 on 64 bit x86 SMP ii linux-headers-5.4.0-84 5.4.0-84.94 all Header files related to Linux kernel version 5.4.0 ii linux-headers-5.4.0-84-generic 5.4.0-84.94 amd64 Linux kernel headers for version 5.4.0 on 64 bit x86 SMP ii linux-headers-5.6.0-1056-oem 5.6.0-1056.60 amd64 Linux kernel headers for version 5.6.0 on 64 bit x86 SMP ii linux-headers-5.8.0-34-generic 5.8.0-34.37~20.04.2 amd64 Linux kernel headers for version 5.8.0 on 64 bit x86 SMP ii linux-headers-5.8.0-53-generic 5.8.0-53.60~20.04.1 amd64 Linux kernel headers for version 5.8.0 on 64 bit x86 SMP ii linux-headers-5.8.0-63-generic 5.8.0-63.71~20.04.1 amd64 Linux kernel headers for version 5.8.0 on 64 bit x86 SMP ii linux-headers-generic 5.4.0.84.88 amd64 Generic Linux kernel headers ii linux-headers-generic-hwe-20.04 5.11.0.34.36~20.04.13 amd64 Generic Linux kernel headers ii linux-headers-oem-20.04b 5.10.0.1045.47 amd64 OEM Linux kernel headers rc linux-image-5.10.0-1029-oem 5.10.0-1029.30 amd64 Signed kernel image oem rc linux-image-5.10.0-1033-oem 5.10.0-1033.34 amd64 Signed kernel image oem rc linux-image-5.10.0-1038-oem 5.10.0-1038.40 amd64 Signed kernel image oem ii linux-image-5.10.0-1044-oem 5.10.0-1044.46 amd64 Signed kernel image oem ii linux-image-5.10.0-1045-oem 5.10.0-1045.47 amd64 Signed kernel image oem ii linux-image-5.11.0-25-generic 5.11.0-25.27~20.04.1 amd64 Signed kernel image generic ii linux-image-5.11.0-27-generic 5.11.0-27.29~20.04.1 amd64 Signed kernel image generic ii linux-image-5.11.0-34-generic 5.11.0-34.36~20.04.1 amd64 Signed kernel image generic rc linux-image-5.4.0-42-generic 5.4.0-42.46 amd64 Signed kernel image generic rc linux-image-5.4.0-54-generic 5.4.0-54.60 amd64 Signed kernel image generic rc linux-image-5.4.0-59-generic 5.4.0-59.65 amd64 Signed kernel image generic rc linux-image-5.6.0-1020-oem 5.6.0-1020.20 amd64 Signed kernel image oem rc linux-image-5.6.0-1036-oem 5.6.0-1036.39 amd64 Signed kernel image oem rc linux-image-5.6.0-1039-oem 5.6.0-1039.43 amd64 Signed kernel image oem rc linux-image-5.6.0-1042-oem 5.6.0-1042.46 amd64 Signed kernel image oem rc linux-image-5.6.0-1047-oem 5.6.0-1047.51 amd64 Signed kernel image oem rc linux-image-5.6.0-1048-oem 5.6.0-1048.52 amd64 Signed kernel image oem rc linux-image-5.6.0-1050-oem 5.6.0-1050.54 amd64 Signed kernel image oem rc linux-image-5.6.0-1052-oem 5.6.0-1052.56 amd64 Signed kernel image oem rc linux-image-5.6.0-1053-oem 5.6.0-1053.57 amd64 Signed kernel image oem rc linux-image-5.6.0-1054-oem 5.6.0-1054.58 amd64 Signed kernel image oem rc linux-image-5.6.0-1055-oem 5.6.0-1055.59 amd64 Signed kernel image oem ii linux-image-5.6.0-1056-oem 5.6.0-1056.60 amd64 Signed kernel image oem rc linux-image-5.8.0-34-generic 5.8.0-34.37~20.04.2 amd64 Signed kernel image generic rc linux-image-5.8.0-36-generic 5.8.0-36.40~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-38-generic 5.8.0-38.43~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-41-generic 5.8.0-41.46~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-43-generic 5.8.0-43.49~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-44-generic 5.8.0-44.50~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-45-generic 5.8.0-45.51~20.04.1+1 amd64 Signed kernel image generic rc linux-image-5.8.0-48-generic 5.8.0-48.54~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-49-generic 5.8.0-49.55~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-50-generic 5.8.0-50.56~20.04.1 amd64 Signed kernel image generic ii linux-image-5.8.0-53-generic 5.8.0-53.60~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-55-generic 5.8.0-55.62~20.04.1 amd64 Signed kernel image generic rc linux-image-5.8.0-59-generic 5.8.0-59.66~20.04.1 amd64 Signed kernel image generic ii linux-image-5.8.0-63-generic 5.8.0-63.71~20.04.1 amd64 Signed kernel image generic ii linux-image-generic-hwe-20.04 5.11.0.34.36~20.04.13 amd64 Generic Linux kernel image ii linux-image-oem-20.04b 5.10.0.1045.47 amd64 OEM Linux kernel image

Если нужны только установленные ядра

dpkg --list | grep -i -E --color 'linux-image|linux-kernel' | grep '^ii'

ii linux-image-5.10.0-1044-oem 5.10.0-1044.46 amd64 Signed kernel image oem ii linux-image-5.10.0-1045-oem 5.10.0-1045.47 amd64 Signed kernel image oem ii linux-image-5.11.0-25-generic 5.11.0-25.27~20.04.1 amd64 Signed kernel image generic ii linux-image-5.11.0-27-generic 5.11.0-27.29~20.04.1 amd64 Signed kernel image generic ii linux-image-5.11.0-34-generic 5.11.0-34.36~20.04.1 amd64 Signed kernel image generic ii linux-image-5.6.0-1056-oem 5.6.0-1056.60 amd64 Signed kernel image oem ii linux-image-5.8.0-53-generic 5.8.0-53.60~20.04.1 amd64 Signed kernel image generic ii linux-image-5.8.0-63-generic 5.8.0-63.71~20.04.1 amd64 Signed kernel image generic ii linux-image-generic-hwe-20.04 5.11.0.34.36~20.04.13 amd64 Generic Linux kernel image ii linux-image-oem-20.04b 5.10.0.1045.47 amd64 OEM Linux kernel image

Количество ядер

dpkg --list | egrep -i --color 'linux-image|linux-headers' | grep '^ii' | wc -l

55

Количество установленных ядер

dpkg --list | egrep -i --color 'linux-image|linux-headers' | grep '^ii' | grep '^ii' | wc -l

26

Изучить свободное место на диске

df -H

Filesystem Size Used Avail Use% Mounted on udev 17G 0 17G 0% /dev tmpfs 3.4G 2.7M 3.4G 1% /run /dev/mapper/nvme0n1p3_crypt 502G 429G 48G 91% / tmpfs 17G 27M 17G 1% /dev/shm tmpfs 5.3M 4.1k 5.3M 1% /run/lock tmpfs 17G 0 17G 0% /sys/fs/cgroup /dev/loop0 105M 105M 0 100% /snap/core/11606 /dev/loop1 59M 59M 0 100% /snap/core18/2074 /dev/loop2 105M 105M 0 100% /snap/core/11420 /dev/loop3 59M 59M 0 100% /snap/core18/2128 /dev/loop6 69M 69M 0 100% /snap/gtk-common-themes/1515 /dev/loop5 230M 230M 0 100% /snap/gnome-3-34-1804/72 /dev/loop4 230M 230M 0 100% /snap/gnome-3-34-1804/66 /dev/loop7 133M 133M 0 100% /snap/slack/44 /dev/loop8 34M 34M 0 100% /snap/snapd/12704 /dev/loop9 34M 34M 0 100% /snap/snapd/12883 /dev/loop11 69M 69M 0 100% /snap/gtk-common-themes/1514 /dev/loop10 54M 54M 0 100% /snap/snap-store/547 /dev/loop12 54M 54M 0 100% /snap/snap-store/542 /dev/loop13 130M 130M 0 100% /snap/slack/43 /dev/nvme0n1p2 992M 896M 45M 96% /boot /dev/nvme0n1p1 536M 8.8M 528M 2% /boot/efi tmpfs 3.4G 21k 3.4G 1% /run/user/125 tmpfs 3.4G 91k 3.4G 1% /run/user/26167

Видно, что раздел boot почти заполнен.

Удалить устаревшие ядра можно командой

sudo apt --purge autoremove

Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: linux-headers-5.10.0-1044-oem* linux-headers-5.11.0-25-generic* linux-headers-5.4.0-81* linux-headers-5.4.0-81-generic* linux-hwe-5.11-headers-5.11.0-25* linux-image-5.10.0-1044-oem* linux-image-5.11.0-25-generic* linux-modules-5.10.0-1044-oem* linux-modules-5.11.0-25-generic* linux-modules-extra-5.11.0-25-generic* linux-oem-5.10-headers-5.10.0-1044* 0 upgraded, 0 newly installed, 11 to remove and 22 not upgraded. After this operation, 890 MB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 551121 files and directories currently installed.) Removing linux-headers-5.10.0-1044-oem (5.10.0-1044.46) ... Removing linux-headers-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... Removing linux-headers-5.4.0-81-generic (5.4.0-81.91) ... dpkg: warning: while removing linux-headers-5.4.0-81-generic, directory '/lib/modules/5.4.0-81-generic' not empty so not removed Removing linux-headers-5.4.0-81 (5.4.0-81.91) ... Removing linux-hwe-5.11-headers-5.11.0-25 (5.11.0-25.27~20.04.1) ... Removing linux-image-5.10.0-1044-oem (5.10.0-1044.46) ... /etc/kernel/prerm.d/dkms: dkms: removing: nvidia 450.119.03 (5.10.0-1044-oem) (x86_64) -------- Uninstall Beginning -------- Module: nvidia Version: 450.119.03 Kernel: 5.10.0-1044-oem (x86_64) ------------------------------------- Status: Before uninstall, this module version was ACTIVE on this kernel. nvidia.ko: - Uninstallation - Deleting from: /lib/modules/5.10.0-1044-oem/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-modeset.ko: - Uninstallation - Deleting from: /lib/modules/5.10.0-1044-oem/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-drm.ko: - Uninstallation - Deleting from: /lib/modules/5.10.0-1044-oem/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. I: /boot/initrd.img.old is now a symlink to initrd.img-5.10.0-1045-oem /etc/kernel/postrm.d/initramfs-tools: update-initramfs: Deleting /boot/initrd.img-5.10.0-1044-oem /etc/kernel/postrm.d/zz-update-grub: Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Sourcing file `/etc/default/grub.d/oem-flavour.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.11.0-34-generic Found initrd image: /boot/initrd.img-5.11.0-34-generic Found linux image: /boot/vmlinuz-5.11.0-27-generic Found initrd image: /boot/initrd.img-5.11.0-27-generic Found linux image: /boot/vmlinuz-5.11.0-25-generic Found initrd image: /boot/initrd.img-5.11.0-25-generic Found linux image: /boot/vmlinuz-5.8.0-63-generic Found initrd image: /boot/initrd.img-5.8.0-63-generic Found linux image: /boot/vmlinuz-5.8.0-53-generic Found initrd image: /boot/initrd.img-5.8.0-53-generic Found linux image: /boot/vmlinuz-5.10.0-1045-oem Found initrd image: /boot/initrd.img-5.10.0-1045-oem Found linux image: /boot/vmlinuz-5.6.0-1056-oem Found initrd image: /boot/initrd.img-5.6.0-1056-oem Adding boot menu entry for UEFI Firmware Settings done Removing linux-modules-extra-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... Removing linux-modules-5.10.0-1044-oem (5.10.0-1044.46) ... Removing linux-oem-5.10-headers-5.10.0-1044 (5.10.0-1044.46) ... Removing linux-image-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... /etc/kernel/prerm.d/dkms: dkms: removing: nvidia 450.119.03 (5.11.0-25-generic) (x86_64) -------- Uninstall Beginning -------- Module: nvidia Version: 450.119.03 Kernel: 5.11.0-25-generic (x86_64) ------------------------------------- Status: Before uninstall, this module version was ACTIVE on this kernel. nvidia.ko: - Uninstallation - Deleting from: /lib/modules/5.11.0-25-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-modeset.ko: - Uninstallation - Deleting from: /lib/modules/5.11.0-25-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-drm.ko: - Uninstallation - Deleting from: /lib/modules/5.11.0-25-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. /etc/kernel/postrm.d/initramfs-tools: update-initramfs: Deleting /boot/initrd.img-5.11.0-25-generic /etc/kernel/postrm.d/zz-update-grub: Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Sourcing file `/etc/default/grub.d/oem-flavour.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.11.0-34-generic Found initrd image: /boot/initrd.img-5.11.0-34-generic Found linux image: /boot/vmlinuz-5.11.0-27-generic Found initrd image: /boot/initrd.img-5.11.0-27-generic Found linux image: /boot/vmlinuz-5.8.0-63-generic Found initrd image: /boot/initrd.img-5.8.0-63-generic Found linux image: /boot/vmlinuz-5.8.0-53-generic Found initrd image: /boot/initrd.img-5.8.0-53-generic Found linux image: /boot/vmlinuz-5.10.0-1045-oem Found initrd image: /boot/initrd.img-5.10.0-1045-oem Found linux image: /boot/vmlinuz-5.6.0-1056-oem Found initrd image: /boot/initrd.img-5.6.0-1056-oem Adding boot menu entry for UEFI Firmware Settings done Removing linux-modules-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... (Reading database ... 445162 files and directories currently installed.) Purging configuration files for linux-modules-extra-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... Purging configuration files for linux-image-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... rmdir: failed to remove '/lib/modules/5.11.0-25-generic': Directory not empty Purging configuration files for linux-modules-5.11.0-25-generic (5.11.0-25.27~20.04.1) ... dpkg: warning: while removing linux-modules-5.11.0-25-generic, directory '/lib/modules/5.11.0-25-generic' not empty so n ot removed Purging configuration files for linux-modules-5.10.0-1044-oem (5.10.0-1044.46) ... dpkg: warning: while removing linux-modules-5.10.0-1044-oem, directory '/lib/modules/5.10.0-1044-oem' not empty so not r emoved Purging configuration files for linux-image-5.10.0-1044-oem (5.10.0-1044.46) ...

Проверка

Проверить результат очистки можно с помощью df и grep

df -H | grep boot

/dev/nvme0n1p2 992M 657M 283M 70% /boot
/dev/nvme0n1p1 536M 8.8M 528M 2% /boot/efi

Было занято 96% теперь 70%

dpkg --list | egrep -i --color 'linux-image|linux-headers' | grep '^ii' | wc -l

59

dpkg --list | egrep -i --color 'linux-image|linux-headers' | grep '^ii' | grep '^ii' | wc -l

20

Шесть ядер были удалены

Похожие статьи
Ubuntu
Установка
Настройка сети
SSH: удалённый доступ
SCP: обмен файлами;
Firewall
Дата и время
X Window System Ubuntu
XRDP: Удалённый рабочий стол
VNC: Удалённый рабочий стол
Изменить machine-id
Изменить ulimit
xclip: работа с буфером обмена
Удалить старые ядра
FAQ
Файлы
Объединить .pdf файлы
diff: сравнение файлов
find: поиск файлов
kill: завершить процесс
make
signal: системные сигналы
env: переменные окружения
localectl: язык
systemctl: Список активных сервисов
cron: задания по расписанию
sudo
Grep
Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящуюю по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: