Keep 4 old versions of kernels

This commit is contained in:
gardouille 2023-07-20 14:59:31 +02:00
parent 8d89b5cd8d
commit 65537f8fe6
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

View File

@ -32,7 +32,12 @@ while IFS= read -r OLD_EFI_ENTRY; do
done < "${temp_efi_list_file}"
# }}}
# Clean old kernels {{{
## Remove all unified kernels
## Rename last version of generic kernel for backup
mv -- "${EFI_MOUNT_PATH}/EFI/debian/linux.debian.efi" "${EFI_MOUNT_PATH}/EFI/debian/backup.debian.efi.$(date +%Y%m%d-%H%M)"
## Keep only the 4 more recent backup kernels
find "${EFI_MOUNT_PATH}/EFI/debian" -type f -iname "backup.debian.efi.*" | sort --reverse --numeric-sort -- | tail --lines=+5 -- | xargs --replace={} rm -- {}
## Remove all previous unified kernels with version in filename
find "${EFI_MOUNT_PATH}/EFI/debian" -type f -iname "linux.debian.*.efi" -delete
# }}}