password protection for grub2

Hi everybody,

i need to password protect the grub2 bootmenu from being altered by editing the menu entry. in grub legacy this was pretty easy to acomplish since all you need to do is issuing grub-md5crypt command and add an entry in grub. is there a way to do this in grub2 too.

I already googled but the only thing i can find documantion for ubuntu.

Changing to the older grub legacy causes my system failing when booting. so this is not an option.

has anybody successfully worked this out?

The procedure setup here seemed to work for me: Grub2/Passwords - Community Help Wiki as grub2 operation should be almost the same with all systems. I found that editing the file called /etc/grub.d/00_header as root and placing this at the bottom of the file worked:

cat << EOF
set superusers="user1"
password user1 1234
EOF

You must then run the following command for the change to take effect:

sudo /usr/sbin/grub2-mkconfig --output=/boot/grub2/grub.cfg

It is possible that an update of Grub 2 might over write this file. If you forget the user name or password, you will need to use an openSUSE LiveCD to go in and fix the problem, so have a working one in reserve before you make such a change. You can perform all of this using my Grub 2 helper bash script grub2cmd you can find here:

GNU Grub2 Command Help/Config Editor - Version: 1.75 - Blogs - openSUSE Forums

Thank You,

thanks a lot james. very helpful script and post.

I am happy to be of assistance l1zard. If you determine anything more complex than I mention for using passwords in Grub 2, consider adding it in a comment for my grub2cmd bash script on that subject. Many other users might find it useful info to know.

Thank You,

I opened a similar thread here (please, have a look to see the problems I encountered): :
http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/478004-grub2-password-fails.html
There are specific instructions for openSUSE in the reference guide, but these didn’t work for me:
openSUSE 12.2: Chapter 8. The Boot Loader GRUB2
(have a look at section 8.2.7. Setting a Boot Password …).
Best regards … :slight_smile: