Foreword
Can be modified by the grub boot root password, so we have to create a convenient, if the password is forgotten, we can change the password through grub guide, but it also provides a convenient outsiders, by outsiders grub boot can enter the system and modify root password, this is a very serious danger. So we need to set a password to restrict grub menu.
1. Backup
cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
cp /etc/grub.d/00_header /etc/grub.d/00_header.bak
2. Generate keys
grub2-mkpasswd-pbkdf2
3. Modify the configuration file
vim /etc/grub.d/00_header
4. generate a new profile grub.cfg
-o-Grub2 mkconfig /boot/grub2/grub.cfg
5. Verify
Restart