Grub2 passwords

GRUB 2 is a bit of a pain to configure, to put it mildly...

Here's how to set a password for a Windows menu option on a dual-boot system (tested on Debian with grub-pc 1.99-11):

  1. Generate a password hash with grub-mkpasswd-pbkdf2.

  2. Create a new file /etc/grub.d/01_auth with the following contents (replace hash in password_pbkdf2 with your own from step 1):

#!/bin/sh
cat <<EOF
set superusers="admin"
password_pbkdf2 admin grub.pbkdf2.sha512.10000.C97A...blah...0B6
EOF
  1. Set the executable permission on this file with chmod +x.

  2. Edit /etc/grub.d/30_os-prober and replace

menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os {

with

menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os --users admin {
  1. Run update-grub and reboot to test. You should now be prompted for credentials when you select the Windows menu item.