fkobi wrote:# bootctl list | grep title | wc -l
This could be simplified to:
bootctl list | grep -c title, rather than relying on a separate
wc.
fkobi wrote:# bootctl unlink gentoo-6.13.7-gentoo-dist.conf
Removed "/efi/gentoo/6.13.7-gentoo-dist/linux"
Removed "/efi/gentoo/6.13.7-gentoo-dist/microcode-amd"
Removed "/efi/gentoo/6.13.7-gentoo-dist/microcode-intel"
Removed "/efi/gentoo/6.13.7-gentoo-dist/initrd"
Removed /efi/loader/entries/gentoo-6.13.7-gentoo-dist.conf
This however is a bit tiring to do it for all the entries.
Is there a better way to delete those?
logrusx addressed how you can avoid this situation in the future. Are you also asking for a way to clean up all the old entries without typing them all individually? If yes, consider using a bit of shell text processing. As an untested starting point:
Code: Select all
# Assume that . has the relevant conf files
printf '%s\n' *-gentoo-dist.conf > /tmp/all-installed-kernels
# Use $EDITOR to remove the ones you want to keep.
$EDITOR /tmp/all-installed-kernels
# Review the file to verify it does not contain anything important. Check that
# the uname of the running kernel is NOT printed, as a baseline safety.
# Further review may be warranted.
grep -F "$(uname -r)" /tmp/all-installed-kernels
# Repeatedly invoke `bootctl unlink` to remove them. If bootctl can take more
# than one kernel at a time, remove the `-n1`.
xargs -n1 -tr -a /tmp/all-installed-kernels bootctl unlink
This is completely untested, and is based on what I inferred from your post. Review its plans carefully before executing.