1、[root@localhost ~]# grub2-mkpasswd-pbkdf2 //输入密码生成密码串
输入口令:
Reenter password:
grub.pbkdf2.sha512.10000.CAFD1E841CB4C7E790C0AC0ED
87D7FA64BE75F89C53870A829C35CF35FBE379BA1F10773E2377D6FCBB7EB844FF2C422732A123F
2D11DB93D3C210EE94FCB0E1.74D4890C925DEA983782126299404F9977517136B67554B9AC3776E9C0F7
2413ECF7842B35766B9C2424A5E1D43A314AD89EA1BE78DE32C6C1426727AE366153
2、[root@localhost ~]# cp /boot/grub2/grub.cfg{,.bak} //备份
3、[root@localhost ~]# cp /etc/grub.d/00_header /etc/grub.d/00_header.bak //备份
4、[root@localhost ~]# vim /etc/grub.d/00_header //对文件进行编辑
cat << EOF
set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.CAFD1E841CB4C7E790C0AC0ED
87D7FA64BE75F89C53870A829C35CF35FBE379BA1F10773E2377D6FCBB7EB844FF2C422732A123F
2D11DB93D3C210EE94FCB0E1.74D4890C925DEA983782126299404F9977517136B67554B9AC3776E9C0F7
2413ECF7842B35766B9C2424A5E1D43A314AD89EA1BE78DE32C6C1426727AE366153
EOF
5、[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg //使⽤grub2-mkconfig命令重新⽣成grub.cfg⽂件