Defragging my old Dell's UEFI NVRAM

I’m setting up an old Dell box (2011-era tech). I was migrating to some new boot drives and setting up grub on them again. Got to the point of deleting the old boot entries and adding new ones, and got an error like Could not prepare boot variable: No space left on device. Weird, because there weren’t that many EFI variables, but df -h also reported that efivars was full:

efivarfs              64K   60K   0K  100% /sys/firmware/efi/efivars

funky.

It wasn’t due to a glut of boot entries either; I’m pretty keen on keeping the old ones cleared out, so we only had a few on here.

Well, I thought maybe there was a lot of dead space in the nvram that wasn’t in use but also couldn’t be allocated. So I booted an EFI shell, and did this:

fs0:
dmpstore -s efi-vars
dmpstore -d
dmpstore -l efi-vars

Please be careful with these commands, it worked for me but for all I know it might brick your setup. Check help dmpstore first.

What this does is:

After doing this, I rebooted, and had plenty of space:

efivarfs              64K   14K   46K  24% /sys/firmware/efi/efivars

And all my UEFI configuration seems to be right as I left it before doing this. So I think this confirms my suspicions.