要移除旧内核,运行以下命令:
$ do-kernel-purge -
Ubuntu Kernel Purge - by Caio Oliveira -
This script will only keep three versions: the first and the last two, others will be purge -
---Current version: Linux Kernel 4.16.7-041607 Generic (linux-image-4.16.7-041607-generic) -
---Versions to remove: 4.13.0-16 4.13.0-17 4.13.0-32 4.13.0-36 4.13.0-37 -
---Do you want to remove the old kernels/headers versions? (Y/n): y Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.13.0-17 linux-headers-4.13.0-17-generic linux-headers-4.13.0-32 linux-headers-4.13.0-32-generic linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic linux-image-4.13.0-17-generic linux-image-4.13.0-32-generic linux-image-4.13.0-36-generic linux-image-4.13.0-37-generic linux-image-extra-4.13.0-17-generic linux-image-extra-4.13.0-32-generic linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-37-generic Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: linux-headers-4.13.0-16* linux-headers-4.13.0-16-generic* linux-image-4.13.0-16-generic* linux-image-extra-4.13.0-16-generic* 0 upgraded, 0 newly installed, 4 to remove and 71 not upgraded. After this operation, 318 MB disk space will be freed. (Reading database ... 465582 files and directories currently installed.) Removing linux-headers-4.13.0-16-generic (4.13.0-16.19) ... Removing linux-headers-4.13.0-16 (4.13.0-16.19) ... Removing linux-image-extra-4.13.0-16-generic (4.13.0-16.19) ... run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic update-initramfs: Generating /boot/initrd.img-4.13.0-16-generic run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.16.7-041607-generic Found initrd image: /boot/initrd.img-4.16.7-041607-generic Found linux image: /boot/vmlinuz-4.13.0-39-generic Found initrd image: /boot/initrd.img-4.13.0-39-generic Found linux image: /boot/vmlinuz-4.13.0-38-generic Found initrd image: /boot/initrd.img-4.13.0-38-generic Found linux image: /boot/vmlinuz-4.13.0-37-generic Found initrd image: /boot/initrd.img-4.13.0-37-generic Found linux image: /boot/vmlinuz-4.13.0-36-generic Found initrd image: /boot/initrd.img-4.13.0-36-generic Found linux image: /boot/vmlinuz-4.13.0-32-generic Found initrd image: /boot/initrd.img-4.13.0-32-generic Found linux image: /boot/vmlinuz-4.13.0-17-generic Found initrd image: /boot/initrd.img-4.13.0-17-generic Found linux image: /boot/vmlinuz-4.13.0-16-generic Found initrd image: /boot/initrd.img-4.13.0-16-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin done Removing linux-image-4.13.0-16-generic (4.13.0-16.19) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic update-initramfs: Deleting /boot/initrd.img-4.13.0-16-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.16.7-041607-generic Found initrd image: /boot/initrd.img-4.16.7-041607-generic Found linux image: /boot/vmlinuz-4.13.0-39-generic Found initrd image: /boot/initrd.img-4.13.0-39-generic Found linux image: /boot/vmlinuz-4.13.0-38-generic Found initrd image: /boot/initrd.img-4.13.0-38-generic Found linux image: /boot/vmlinuz-4.13.0-37-generic Found initrd image: /boot/initrd.img-4.13.0-37-generic Found linux image: /boot/vmlinuz-4.13.0-36-generic Found initrd image: /boot/initrd.img-4.13.0-36-generic Found linux image: /boot/vmlinuz-4.13.0-32-generic Found initrd image: /boot/initrd.img-4.13.0-32-generic Found linux image: /boot/vmlinuz-4.13.0-17-generic Found initrd image: /boot/initrd.img-4.13.0-17-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin done (Reading database ... 430635 files and directories currently installed.) Purging configuration files for linux-image-extra-4.13.0-16-generic (4.13.0-16.19) ... Purging configuration files for linux-image-4.13.0-16-generic (4.13.0-16.19) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-16-generic /boot/vmlinuz-4.13.0-16-generic Reading package lists... Done Building dependency tree Reading state information... Done . . . . Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: linux-headers-4.13.0-37* linux-headers-4.13.0-37-generic* linux-image-4.13.0-37-generic* linux-image-extra-4.13.0-37-generic* 0 upgraded, 0 newly installed, 4 to remove and 71 not upgraded. After this operation, 321 MB disk space will be freed. (Reading database ... 325772 files and directories currently installed.) Removing linux-headers-4.13.0-37-generic (4.13.0-37.42) ... Removing linux-headers-4.13.0-37 (4.13.0-37.42) ... Removing linux-image-extra-4.13.0-37-generic (4.13.0-37.42) ... run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic update-initramfs: Generating /boot/initrd.img-4.13.0-37-generic run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.16.7-041607-generic Found initrd image: /boot/initrd.img-4.16.7-041607-generic Found linux image: /boot/vmlinuz-4.13.0-39-generic Found initrd image: /boot/initrd.img-4.13.0-39-generic Found linux image: /boot/vmlinuz-4.13.0-38-generic Found initrd image: /boot/initrd.img-4.13.0-38-generic Found linux image: /boot/vmlinuz-4.13.0-37-generic Found initrd image: /boot/initrd.img-4.13.0-37-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin done Removing linux-image-4.13.0-37-generic (4.13.0-37.42) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic update-initramfs: Deleting /boot/initrd.img-4.13.0-37-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic Generating grub configuration file ... Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. Found linux image: /boot/vmlinuz-4.16.7-041607-generic Found initrd image: /boot/initrd.img-4.16.7-041607-generic Found linux image: /boot/vmlinuz-4.13.0-39-generic Found initrd image: /boot/initrd.img-4.13.0-39-generic Found linux image: /boot/vmlinuz-4.13.0-38-generic Found initrd image: /boot/initrd.img-4.13.0-38-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin done (Reading database ... 290810 files and directories currently installed.) Purging configuration files for linux-image-extra-4.13.0-37-generic (4.13.0-37.42) ... Purging configuration files for linux-image-4.13.0-37-generic (4.13.0-37.42) ... Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-37-generic /boot/vmlinuz-4.13.0-37-generic -
Thanks for using this script!!!
(编辑:ASP站长网)
|