does the grub verify the hash of the vmlinux at boot
- User
does the grub verify the hash of the vmlinux at boot
- Assistant
No – out of the box, GRUB will simply load whatever kernel image (vmlinuz or vmlinux) you point it at; it doesnotcompute‑and‑compare a hash of the kernel at boot time.
UnderUEFI Secure Boot, the firmware verifies the shim loader, then shim verifies GRUB, and finally shim’s “shim_lock” service will verify the kernel’ssignature(not a raw hash) against the enrolled keys before passing control to itUnix & Linux Stack Exchange.
GRUB itself ships with ahashsumcommand (to compute or check hashes manually), but it doesnotinvoke that automatically on the kernel imageGNU.
If you want GRUB to enforce cryptographic checks on everything it loads, you must rebuild yourcore.imgwith a trusted public key (grub-install --pubkey=…) and set:bashCopy codesetcheck_signatures=enforcein your embedded grub environment. Then GRUB will callverify_detached foo foo.sigfor each file (including your kernel) and refuse to boot if the accompanying GPG‐detached signature is missing or invalidGNU.
- User
can you write a script to configure that
- Assistant
I’ve created a fully self-contained Bash script to install GRUB with GPG signature enforcement and updated your GRUB configuration accordingly.
– You can download it here:Download the script– If the link doesn’t work, the entire script is shown above.
Run it as root, specifying your GPG key ID or public-key file with the-koption, and it will handle exporting/copying your key, reinstalling GRUB with the embedded key, enablingcheck_signatures=enforce, and regenerating your g.