Как делает 'склонный', решают сколько старых ядер для хранения?

Я управляю несколькими серверами для базовых сервисов (NTP, DNS, и т.д.), и мне просто пришло в голову, что один из серверов, кажется, сохраняет 3 последних ядра, вместо 2 на других:

nul@quark:~$ sudo apt-get autoremove --purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
nul@quark:~$ dpkg -l |grep linux-image
ii  linux-image-3.13.0-51-generic       3.13.0-51.84                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-52-generic       3.13.0-52.85                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.16.0-37-generic       3.16.0-37.49~14.04.1             amd64        Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-51-generic 3.13.0-51.84                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-52-generic 3.13.0-52.85                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.16.0-37-generic 3.16.0-37.49~14.04.1             amd64        Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii  linux-image-generic                 3.13.0.52.59                     amd64        Generic Linux kernel image
ii  linux-image-generic-lts-utopic      3.16.0.37.29                     amd64        Generic Linux kernel image

...

nul@dwarf:~$ sudo apt-get autoremove --purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
nul@dwarf:~$ dpkg -l |grep linux-image
ii  linux-image-3.13.0-52-generic       3.13.0-52.85                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.16.0-37-generic       3.16.0-37.49~14.04.1             amd64        Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-52-generic 3.13.0-52.85                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.16.0-37-generic 3.16.0-37.49~14.04.1             amd64        Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii  linux-image-generic                 3.13.0.52.59                     amd64        Generic Linux kernel image
ii  linux-image-generic-lts-utopic      3.16.0.37.29                     amd64        Generic Linux kernel image

Все серверы сохраняются тождественно, не знайте то, что я, возможно, сделал, должен быть параметром где-нибудь, но не могу найти его!

Подайте мое любопытство!Спасибо

22
задан 6 May 2015 в 13:05

1 ответ

Существует файл, который автоматически генерируется, который говорит apt-get какие ядра автоудалить и которые сохранить.
Файл, который говорит apt-get который ядра, которые они, /etc/apt/apt.conf.d/01autoremove-kernels который сгенерирован от /etc/kernel/postinst.d/apt-auto-removal.

Обычно то, что происходит, - то, что, когда Вы получаете обновления ядра, когда изменения версии ядра, говорят от 3.13 кому: 3.16, /etc/apt/apt.conf.d/01autoremove-kernels затем обновляется для хранения 3.16* ядра и затем установлены удалить весь из 3.13 ядра, если не указано генерирующимся сценарием, который не будет удален.

От apt-auto-removal сценарий:

# Author: Steve Langasek 
#
# Mark as not-for-autoremoval those kernel packages that are:
#  - the currently booted version
#  - the kernel version we've been called for
#  - the latest kernel version (determined using rules copied from the grub
#    package for deciding which kernel to boot)
#  - the second-latest kernel version, if the booted kernel version is
#    already the latest and this script is called for that same version,
#    to ensure a fallback remains available in the event the newly-installed
#    kernel at this ABI fails to boot
# In the common case, this results in exactly two kernels saved, but it can
# result in three kernels being saved.  It's better to err on the side of
# saving too many kernels than saving too few.
#
# We generate this list and save it to /etc/apt/apt.conf.d instead of marking
# packages in the database because this runs from a postinst script, and apt
# will overwrite the db when it exits.

Однако это иногда не будет отмечать их для автоудаления, так как часть кодирования переключила версии для предотвращения этого.

Если Вы хотите, отмечают предыдущие ядра для autoremove за исключением необходимых ядер на основе скриптов, запущенных следующая команда из окна терминала:

sudo apt-mark auto ^linux-image-

Затем когда Вы работаете apt-get autoremove управляйте только теми, которые стары, и больше не необходимый может быть удален. Я поместил примеры ниже:

Этот первый показывает все ядра в системе минус текущее рабочее ядро.

root@terrance-Linux:/home/share# dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
linux-headers-3.16.0-34
linux-headers-3.16.0-34-generic
linux-headers-3.16.0-36
linux-headers-3.16.0-36-generic
linux-headers-3.16.0-37
linux-headers-3.16.0-37-generic
linux-headers-4.0.0-040000
linux-headers-4.0.0-040000-generic
linux-image-3.16.0-34-generic
linux-image-3.16.0-36-generic
linux-image-3.16.0-37-generic
linux-image-4.0.0-040000-generic
linux-image-extra-3.16.0-34-generic
linux-image-extra-3.16.0-36-generic
linux-image-extra-3.16.0-37-generic

Эти шоу текущее рабочее ядро.

terrance@terrance-Linux:~$ uname -r
4.0.1-040001-generic
terrance@terrance-Linux:~$ sudo apt-get autoremove
[sudo] password for terrance: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
terrance@terrance-Linux:~$ sudo apt-mark auto ^linux-image-
linux-image-extra-3.16.0-33-generic can not be marked as it is not installed.
linux-image-extra-3.13.0-27-generic can not be marked as it is not installed.
linux-image-3.13.0-44-lowlatency can not be marked as it is not installed.
linux-image-3.13.0-27-generic can not be marked as it is not installed.
linux-image-3.16.0-31-lowlatency can not be marked as it is not installed.
linux-image-3.16.0-36-generic set to automatically installed.
linux-image-lowlatency-lts-utopic can not be marked as it is not installed.
linux-image-extra-3.13.0-36-generic can not be marked as it is not installed.
linux-image-3.13.0-36-generic can not be marked as it is not installed.
linux-image-4.0.0-040000-generic set to automatically installed.
linux-image-extra-3.13.0-45-generic can not be marked as it is not installed.
linux-image-3.16.0-25-generic can not be marked as it is not installed.

Примечание: Выше каждый был слишком длинным для списка, таким образом, я усеченный немного.

terrance@terrance-Linux:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-3.16.0-34-generic linux-image-3.16.0-36-generic
  linux-image-4.0.0-040000-generic linux-image-extra-3.16.0-34-generic
  linux-image-extra-3.16.0-36-generic
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
After this operation, 613 MB disk space will be freed.
Do you want to continue? [Y/n] 

Так, после выполнения тех команд Вы видите, что я могу теперь автоудалить все старое, но текущее (4.0.1-040001-универсальное) ядро и следующее новейшее (3.16.0-37-универсальное).

Надо надеяться, это помогает.

31
ответ дан 23 November 2019 в 01:35

Другие вопросы по тегам:

Похожие вопросы: