xref: /linux/scripts/prune-kernel (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b64e86cdSJ. Bruce Fields#!/bin/bash
2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
3b64e86cdSJ. Bruce Fields
4b64e86cdSJ. Bruce Fields# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
5b64e86cdSJ. Bruce Fields# again, /boot and /lib/modules/ eventually fill up.
6b64e86cdSJ. Bruce Fields# Dumb script to purge that stuff:
7b64e86cdSJ. Bruce Fields
8b64e86cdSJ. Bruce Fieldsfor f in "$@"
9b64e86cdSJ. Bruce Fieldsdo
10b64e86cdSJ. Bruce Fields        if rpm -qf "/lib/modules/$f" >/dev/null; then
11b64e86cdSJ. Bruce Fields                echo "keeping $f (installed from rpm)"
12b64e86cdSJ. Bruce Fields        elif [ $(uname -r) = "$f" ]; then
13b64e86cdSJ. Bruce Fields                echo "keeping $f (running kernel) "
14b64e86cdSJ. Bruce Fields        else
15b64e86cdSJ. Bruce Fields                echo "removing $f"
16b64e86cdSJ. Bruce Fields                rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
17b64e86cdSJ. Bruce Fields                rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
18b64e86cdSJ. Bruce Fields                rm -rf "/lib/modules/$f"
19*5d53508dSReza Arbab                if [ -x "$(command -v new-kernel-pkg)" ]; then
20b64e86cdSJ. Bruce Fields                        new-kernel-pkg --remove $f
21*5d53508dSReza Arbab                elif [ -x "$(command -v kernel-install)" ]; then
22*5d53508dSReza Arbab                        kernel-install remove $f
23*5d53508dSReza Arbab                fi
24b64e86cdSJ. Bruce Fields        fi
25b64e86cdSJ. Bruce Fieldsdone
26