prune-kernel 708 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. # because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
  4. # again, /boot and /lib/modules/ eventually fill up.
  5. # Dumb script to purge that stuff:
  6. for f in "$@"
  7. do
  8. if rpm -qf "/lib/modules/$f" >/dev/null; then
  9. echo "keeping $f (installed from rpm)"
  10. elif [ $(uname -r) = "$f" ]; then
  11. echo "keeping $f (running kernel) "
  12. else
  13. echo "removing $f"
  14. rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
  15. rm -f "/boot/vmlinuz-$f" "/boot/config-$f"
  16. rm -rf "/lib/modules/$f"
  17. new-kernel-pkg --remove $f
  18. fi
  19. done