I have upgraded my OS version a few times. What is the best way to remove the old kernels and free space?
Asked
Active
Viewed 244 times
1 Answers
0
Having extra kernels take space up. You can look for your old kernels manually in the /usr/src folder. However, the following command can remove the linux kernels quickly and easily.
From a Terminal window, type in:
dpkg -l 'linux-*' | \
sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | \
xargs sudo apt-get purge
The above line should only be used if you know that your present kernel is working the way you want it and any other kernels you are not concerned about. This will remove all kernels but the current active one that is running on your system. It will remove even newer kernels if you are booted to an older kernel.
Terrance
- 43,712