第一步:查看當(dāng)前內(nèi)核
rew $ uname -a
linux rew 4.15.0-42-generic #45~16.04.1-ubuntu smp mon nov 19 13:02:27 utc 2018 x86_64 x86_64 x86_64 gnu/linux當(dāng)前使用版本為: 4.15.0-42-generic
第二步:查看所有內(nèi)核
rew $ dpkg --get-selections | grep linux
console-setup-linux install
libselinux1:amd64 install
libselinux1:i386 install
linux-base install
linux-firmware install
linux-generic-hwe-16.04 install
linux-headers-4.15.0-42 install
linux-headers-4.15.0-39 install
linux-headers-4.15.0-39-generic install
linux-headers-4.15.0-42-generic install
linux-headers-generic-hwe-16.04 install
linux-image-4.15.0-39-generic install
linux-image-4.15.0-42-generic install
linux-image-generic-hwe-16.04 install
linux-libc-dev:amd64 install
linux-libc-dev:i386 install
linux-modules-4.15.0-39-generic install
linux-modules-4.15.0-42-generic install
linux-modules-extra-4.15.0-39-generic install
linux-modules-extra-4.15.0-42-generic install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
syslinux-legacy install
util-linux install
第三步:移除冗余內(nèi)核
所有 39 版本的對我來說都是多余的,進(jìn)行刪除:
rew $ sudo apt-get remove \
linux-headers-4.15.0-39 \
linux-headers-4.15.0-39-generic \
linux-image-4.15.0-39-generic \
linux-modules-4.15.0-39-generic \
linux-modules-extra-4.15.0-39-generic
卸載后重新檢查:
rew $ dpkg --get-selections | grep linux
console-setup-linux install
libselinux1:amd64 install
libselinux1:i386 install
linux-base install
linux-firmware install
linux-generic-hwe-16.04 install
linux-headers-4.15.0-42 install
linux-headers-4.15.0-42-generic install
linux-headers-generic-hwe-16.04 install
linux-image-4.15.0-39-generic deinstall
linux-image-4.15.0-42-generic install
linux-image-generic-hwe-16.04 install
linux-libc-dev:amd64 install
linux-libc-dev:i386 install
linux-modules-4.15.0-39-generic deinstall
linux-modules-4.15.0-42-generic install
linux-modules-extra-4.15.0-39-generic deinstall
linux-modules-extra-4.15.0-42-generic install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
syslinux-legacy install
util-linux install
狀態(tài)為 deinstall 即已經(jīng)卸載,如果覺得看著不舒服的話可以使用 purge 連配置文件里一起徹底刪除,清理內(nèi)核列表
rew $ sudo apt-get purge \
linux-headers-4.15.0-39 \
linux-headers-4.15.0-39-generic \
linux-image-4.15.0-39-generic \
linux-modules-4.15.0-39-generic \
linux-modules-extra-4.15.0-39-generic第四步:更新系統(tǒng)引導(dǎo)
刪除內(nèi)核后需要更新 grub 移除失效的啟動項(xiàng)
rew $ sudo update-grub #根據(jù)情況選擇grub/grub2