Remove unused Kernels in Centos

The command package-cleanup remove older kernel. Use –count=1 to keep just the latest. The program will never remove the kernel currently used (“Not removing kernel 3.10.0-327.el7 because it is the running kernel”), so you may end-up with two kernels in /boot… until you reboot and re-run the command.

So the command is

package-cleanup --oldkernels --count=1

The manpage document three options:

--oldkernels
          Remove old kernel and kernel-devel packages.
--count <COUNT>
          Number of duplicate/kernel packages to keep on the system (default 2)
--keepdevel
          Do not remove kernel-devel packages when removing kernels