目录
确保安装了必要的 GRUB 工具
rambo@test1:~$ sudo apt update
rambo@test1:~$ sudo apt install grub-common
生成 GRUB 密码
rambo@test1:~$ grub-mkpasswd-pbkdf2
输入密码:
重新输入口令:
您的密码的 PBKDF2 哈希为 grub.pbkdf2.sha512.10000.F0DA72FA35DC6EF6086A1A0F4AC9AB1C7961DA4856DFC7188142C78FA69C3FB814A0B09412E9957463B1AA9B13A562680A67412624B1ECBDC523F25EFE7320D0.1056A594E29B02F7E0BD66B6FDF1C549A4E179D2C12FD9AFAA239070128404C136F728A049BFF8F46C509D5E07F76409B85F791531BDB827AD6E42CA37995A55
注1:输入两次密码后,工具会生成一个以 grub.pbkdf2.sha512 开头的哈希字符串。记下这个哈希字符串
注2:每一个用户需要登录时都需要在当前用户下生成grub密码,而后按同样的方式写到40_custo文件中
编辑 GRUB 配置文件
rambo@test1:~$ sudo vim /etc/grub.d/40_custo
set superusers="rambo"
password_pbkdf2 rambo grub.pbkdf2.sha512.10000.F0DA72FA35DC6EF6086A1A0F4AC9AB1C7961DA4856DFC7188142C78FA69C3FB814A0B09412E9957463B1AA9B13A562680A67412624B1ECBDC523F25EFE7320D0.1056A594E29B02F7E0BD66B6FDF1C549A4E179D2C12FD9AFAA239070128404C136F728A049BFF8F46C509D5E07F76409B85F791531BDB827AD6E42CA37995A55
注:rambo是我当前使用的用户
更新 GRUB 配置
rambo@test1:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.0-35-generic
Found initrd image: /boot/initrd.img-6.8.0-35-generic
Found memtest86+x64 image: /memtest86+x64.bin
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
# 重启
rambo@test1:~$ sudo reboot
标签:test1,rambo,GRUB,grub,boot,密码,Ubuntu22
From: https://www.cnblogs.com/smlile-you-me/p/18242528