Ubuntu's method for removing redundant kernels
- 2020-12-19 21:24:00
- OfStack
Step 1: View the current kernel
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
The current version is 4.15.0-42-ES5en
Step 2: Look at all the kernels
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
Step 3: Remove the redundant kernel
All 39 versions are redundant to me, delete:
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
Check again after unloading:
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
deinstall is uninstalled. If you don't feel comfortable with it, you can use purge to completely delete it from the configuration file and clean up the kernel list
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
Step 4: Update the system boot
After removing the kernel, you need to update the grub to remove the failed boot item
rew $ sudo update-grub # Choose according to circumstances grub/grub2