@ Technical Tip: Clean up /boot in CentOS, RHEL or Rocky Linux 8 and up

1) Check the current kernel being used:


sudo uname -sr


2) List all kernels installed on the system:


sudo rpm -q kernel


3) Delete old kernels and only leave <X> number of kernels:


sudo dnf remove --oldinstallonly --setopt installonly_limit=<X> kernel 


Note: <X> can be set to 1, 2, 3 or other numeric values. Carefully check the running kernel in step 2 and any other kernels used before running this command. Alternatively, use the following command to delete kernels one by one:


rpm -e <kernel_name>

Kernel names can be obtained through step 2.

