在 Linux 中从 Shell 脚本启动 Windows,无需等待 Grub 超时

Tai*_*iga 6 grub arch-linux shell-script

我想编写一个 shell 脚本来启动到 Windows,而无需等待正常的 grub 超时。
该命令不得更改 grub-timeout 的默认值,因为我仍然想在下次启动时选择 Linux 或 Windows。
就像是:

#!/bin/bash
sudo grub-reboot 2
# set timeout 0 temporarily
sudo reboot
Run Code Online (Sandbox Code Playgroud)

Tai*_*iga 7

对于任何未来的读者,解决方案如下:

\n
#!/bin/bash\nsudo efibootmgr -n [x]\nsudo reboot\n
Run Code Online (Sandbox Code Playgroud)\n

其中 [x] 是 Windows 启动管理器的索引(通常为 0),您可以通过运行找到它

\n
efibootmgr -d -d\n
Run Code Online (Sandbox Code Playgroud)\n

不幸的是,设置下次启动似乎需要 sudo,因此即使您在 .zshenv 或 .bash_profile 中设置了别名或函数,您仍然需要输入密码。

\n

感谢@MarcusM\xc3\xbcller 为我指明了正确的方向。

\n

  • 非常感谢您花时间发布您的解决方案。您也可以[接受](https://unix.stackexchange.com/help/someone-answers)(48小时后,以便其他人也有机会回答)。 (2认同)