ubuntu:kernel:delete_old_kernel_images
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:kernel:delete_old_kernel_images [2019/12/15 22:18] – peter | ubuntu:kernel:delete_old_kernel_images [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 60: | Line 60: | ||
Removing linux-headers-3.12.0-27-virtual ... | Removing linux-headers-3.12.0-27-virtual ... | ||
Removing linux-headers-3.12.0-27 ... | Removing linux-headers-3.12.0-27 ... | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Delete kernel packages in remove/ | ||
+ | |||
+ | <code bash> | ||
+ | sudo dpkg --list | grep linux-image | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | rc linux-image-4.15.0-29-generic | ||
+ | rc linux-image-4.15.0-55-generic | ||
+ | rc linux-image-4.15.0-58-generic | ||
+ | rc linux-image-4.15.0-60-generic | ||
+ | rc linux-image-4.15.0-62-generic | ||
+ | rc linux-image-4.15.0-64-generic | ||
+ | rc linux-image-4.15.0-65-generic | ||
+ | rc linux-image-4.15.0-66-generic | ||
+ | rc linux-image-4.15.0-69-generic | ||
+ | ii linux-image-4.15.0-70-generic | ||
+ | ii linux-image-4.15.0-72-generic | ||
+ | ii linux-image-generic | ||
+ | </ | ||
+ | |||
+ | * **rc**: means package is in remove/ | ||
+ | * **ii**: means package is in install state and it is 100% installed on the system. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Remove all linux-image packages in rc state ==== | ||
+ | |||
+ | <code bash> | ||
+ | sudo x=$(dpkg --list | grep -i linux-image | grep ^rc| awk '{ print $2}') | ||
+ | sudo echo " | ||
+ | sudo apt --purge remove $x | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Recheck kernel package state ==== | ||
+ | |||
+ | <code bash> | ||
+ | sudo dpkg --list | grep linux-image | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | ii linux-image-4.15.0-70-generic | ||
+ | ii linux-image-4.15.0-72-generic | ||
+ | ii linux-image-generic | ||
+ | </ | ||
+ | |||
+ | Note that all **rc** states have gone. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Deleting all old kernels easily ===== | ||
+ | |||
+ | Get a list of kernels. | ||
+ | |||
+ | <code bash> | ||
+ | # Get kernel version. | ||
+ | v=" | ||
+ | |||
+ | # Create ignore list to avoid deleting the running kernel. | ||
+ | i=" | ||
+ | |||
+ | # Display the list. | ||
+ | echo dpkg --list | egrep -i ' | ||
+ | </ | ||
+ | |||
+ | To delete it simply run it as follows: | ||
+ | |||
+ | <code bash> | ||
+ | v=" | ||
+ | i=" | ||
+ | apt --purge remove $(dpkg --list | egrep -i ' | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Easy way to delete all old kernels ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get purge $(dpkg -l linux-{image, | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Simple way to delete all old kernels ===== | ||
+ | |||
+ | <code bash> | ||
+ | sudo purge-old-kernels | ||
</ | </ | ||
ubuntu/kernel/delete_old_kernel_images.1576448332.txt.gz · Last modified: 2020/07/15 09:30 (external edit)