pre-install kernel hook: only keep 3 old kernels instead of waiting until we run out of disk space

master
BodgeMaster 2023-07-14 23:11:02 +02:00
parent 1967fe3c85
commit 234432cf74
2 changed files with 6 additions and 15 deletions

View File

@ -1,24 +1,17 @@
#!/usr/bin/env bash
#
# Kernel pre-install hook for Void-USB
# This script removes old kernels when disk space is low.
# This script removes old kernels to save disk space.
#
# Arguments: $1 package name, $2 kernel version
PKGNAME="$1"
VERSION="$2"
MB_LOW=250
MB_FREE="$(df --block-size=1M --output=avail /boot | tail -n1)"
KEEP_OLD_KERNELS=3
if [ "$MB_FREE" -lt "$MB_LOW" ]; then
echo
while [ "$(vkpurge list | wc -l)" -gt "$KEEP_OLD_KERNELS" ]; do
OLDEST_KERNEL="$(vkpurge list | sort | head -n1)"
if [ -z "$OLDEST_KERNEL" ]; then
echo -e "\033[31m================================================\n\033[33mWARNING:\033[0m Failed to find an old kernel to remove.\nThe /boot partition is running out of space.\nThis will become an issue if left unaddressed.\n\033[31m================================================\033[0m"
else
echo "Removing old kernel $OLDEST_KERNEL using vkpurge..."
vkpurge rm "$OLDEST_KERNEL"
fi
else
echo "Not doing anything, /boot has plenty of space."
fi
done

View File

@ -11,8 +11,6 @@ make our own or extract (if feasible) kb selection and time zone selection to hi
- potentially interesting packages
- ckbcomp
- kbd-data
vkpurge old stuff - only keep 2 vkpurgeable kernels
- change kernel pre-install hook
overview of the installation process at the start
overall progress indication (step x out of y)
exclude optical drives