Created
December 8, 2022 05:28
-
-
Save zobayer1/23b6290ce68544cfc89da2b3ea283b60 to your computer and use it in GitHub Desktop.
Cleanup your old Kernels after booting up the latest kernel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ## | |
| ## Cleanup your old Kernels after booting up the latest kernel. | |
| ## Source: https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/#sect-clean-up-old-kernels | |
| ## | |
| old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q)) | |
| if [ "${#old_kernels[@]}" -eq 0 ]; then | |
| echo "No old kernels found" | |
| exit 0 | |
| fi | |
| if ! dnf remove "${old_kernels[@]}"; then | |
| echo "Failed to remove old kernels" | |
| exit 1 | |
| fi | |
| echo "Removed old kernels" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment