惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
SecWiki News
SecWiki News
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
腾讯CDC
Scott Helme
Scott Helme
I
InfoQ
Cyberwarzone
Cyberwarzone
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Latest
Security Latest
The Register - Security
The Register - Security
Project Zero
Project Zero
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
C
Cisco Blogs
L
LINUX DO - 热门话题
P
Privacy International News Feed
IT之家
IT之家
U
Unit 42
P
Privacy & Cybersecurity Law Blog
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Palo Alto Networks Blog
F
Full Disclosure
宝玉的分享
宝玉的分享
Simon Willison's Weblog
Simon Willison's Weblog
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hacker News: Front Page
Know Your Adversary
Know Your Adversary
PCI Perspectives
PCI Perspectives
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
S
Schneier on Security
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
Cisco Talos Blog
Cisco Talos Blog

纸鹿摸鱼处

北京实习300天 | 纸鹿摸鱼处 实习后买了一堆东西 | 纸鹿摸鱼处 谈谈不受欢迎的博客技术特征 | 纸鹿摸鱼处 我们的设备被拿来做了什么:软件的背景行为 | 纸鹿摸鱼处 生成式AI正在生成 | 纸鹿摸鱼处 前端字体二三事 | 纸鹿摸鱼处 深色模式开发的最佳实践 | 纸鹿摸鱼处 寻不回手工油糕 | 纸鹿摸鱼处 一些数码外设的评价和“捡垃圾”心得 | 纸鹿摸鱼处 朋友的 Vivado 和 Modelsim 装上了吗 | 纸鹿摸鱼处 迟到三月的年末博客杂谈:动力、文章和内容 | 纸鹿摸鱼处 VitePress 不完全优化指南 | 纸鹿摸鱼处 给电脑新手的笔记本开荒指南导读 | 纸鹿摸鱼处 再谈考试时钟:技术之外的思考 | 纸鹿摸鱼处 今日校园见闻:我已经出离高兴了 | 纸鹿摸鱼处 配置并差点运行不了 Java Applet | 纸鹿摸鱼处 Windows 上的开源软件入门 | 纸鹿摸鱼处 博客进化:从 Hexo 到 Nuxt Content | 纸鹿摸鱼处 祖母的90年代南昌差旅之险 | 纸鹿摸鱼处 Linux 下通过 Samba 共享文件夹 | 纸鹿摸鱼处 从“端口无法访问”到本地环境问题——朋友的博客踩坑记录 | 纸鹿摸鱼处 Windows 空间管理/清理指南 | 纸鹿摸鱼处 遭遇APP乱象:老人的「钱袋子」开线了 | 纸鹿摸鱼处 封面被 Linux QQ 官方用了,但是有一些小缺陷 | 纸鹿摸鱼处 Windows 终端体验优化指南 | 纸鹿摸鱼处 有问题,就要讲出来。 | 纸鹿摸鱼处 从 CSS 排序折腾到 Stylelint 和 pnpm | 纸鹿摸鱼处 使用 DOSBox 的多种方式 | 纸鹿摸鱼处 今日有「假」 | 纸鹿摸鱼处 把博客文章按年份放在子文件夹中了 | 纸鹿摸鱼处 写过的奇妙代码。 | 纸鹿摸鱼处 Arch Linux 启动引导修复 | 纸鹿摸鱼处 在延长今天和期待明天之间 | 纸鹿摸鱼处 今日无事,除了一些技术咨询 | 纸鹿摸鱼处 病毒高占用CPU,三天杀俩 | 纸鹿摸鱼处 运营商又想多收话费了 | 纸鹿摸鱼处 电脑连接手机,手机给电脑传文件…… | 纸鹿摸鱼处 Moonlight 串流指南 | 纸鹿摸鱼处 SSH 免密登录 | 纸鹿摸鱼处 Termux 简单指南 | 纸鹿摸鱼处 Tailscale 不完全使用指南 | 纸鹿摸鱼处 Windows 安装指南 | 纸鹿摸鱼处 Arch Linux 易用性及美化 | 纸鹿摸鱼处 Arch Linux 初步配置 | 纸鹿摸鱼处 使用 ArchInstall 安装 Arch Linux | 纸鹿摸鱼处 VS Code 简单配置项 | 纸鹿摸鱼处 他修电脑又遇到了我 | 纸鹿摸鱼处 修监控 (授权转载) | 纸鹿摸鱼处 被大块落冰砸中的话—— | 纸鹿摸鱼处
系统引导配置分享 | 纸鹿摸鱼处
纸鹿本鹿, hi@zhilu.cyou · 2024-03-01 · via 纸鹿摸鱼处

前置知识

一般来说,系统引导方式有 Legacy 引导和 UEFI 引导。其中 Legacy 引导方式较为古老,不在本篇文章的讨论范围内。

UEFI 引导中,可以有多个启动项,比如 Windows Boot Manager、Linux Boot Manager、Grub、网络启动、USB设备启动等。

而在诸如 Windows Boot Manager、Linux Boot Manager、Grub 这些启动项管理器中,也可以设置多个启动项。如果安装了多个 Windows 系统,Windows Boot Manager 中会显示多个 Windows 启动项;如果安装了 Linux 系统, Grub 中会显示 Linux 系统、Linux 系统(高级启动),以及可能会有 Windows Boot Manager 的启动项。

Windows 下使用脚本重启到其他系统

列出 EFI 启动项

PS(管理员)>

bcdedit /enum ALL

执行此命令,你会看到类似以下内容:

text
固件启动管理器
---------------------
标识符                  {fwbootmgr}
displayorder            {bootmgr}
                        {77a0d197-59c5-11ee-b0be-c8cb9e630a73}
                        {9dda157b-7ef3-11ee-b143-806e6f6e6963}
                        {f0506e71-9c73-11ed-adf2-806e6f6e6963}

Windows 启动管理器
--------------------
标识符                  {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager

固件应用程序(101fffff)
-------------------------------
标识符                  {77a0d197-59c5-11ee-b0be-c8cb9e630a73}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\systemd\systemd-bootx64.efi
description             Linux Boot Manager

固件应用程序(101fffff)
-------------------------------
标识符                  {9dda157b-7ef3-11ee-b143-806e6f6e6963}
device                  partition=\Device\HarddiskVolume6
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager

固件应用程序(101fffff)
-------------------------------
标识符                  {f0506e71-9c73-11ed-adf2-806e6f6e6963}
description             EFI USB Device

Windows 启动加载器
-------------------
标识符                  {current}
device                  partition=C:
path                    \WINDOWS\system32\winload.efi
description             Windows 11

……

记住你需要重启到的、形如 {77a0d197-59c5-11ee-b0be-c8cb9e630a73} 的 UUID,就可以编写脚本了。

重启到指定 EFI 启动项

reboot-to-some-entry.batbat
rem 使用管理员权限运行此脚本
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd","/c %~s0 ::","","runas",1)(window.close) && exit
rem 将 Linux Boot Manager 设置为下次启动项
bcdedit /set "{fwbootmgr}" bootsequence "{77a0d197-59c5-11ee-b0be-c8cb9e630a73}" /addfirst
rem 重启
shutdown -r -t 0

推荐将脚本放在用户文件夹下,因为这是终端启动、SSH连接时的默认目录,输入文件名即可运行。

在 Linux 下重启到其他系统

列出启动项

$

efibootmgr

执行此命令后,会得到如下所示的 EFI 启动项列表:

text
BootCurrent: 0005
BootOrder: 0001,0005,0004,2001
Boot0001* Windows Boot Manager  HD(1,GPT,04f43acd-5a75-4946-b8eb-8c2b4aa000c3,0x800,0x100000)/\EFI\Microsoft\Boot\bootmgfw.efi
Boot0004* Windows Boot Manager  HD(1,GPT,3f296803-1e98-4d7f-b76b-263785c2dcef,0x28,0x100000)/\EFI\Microsoft\Boot\bootmgfw.efi
Boot0005* Linux Boot Manager    HD(1,GPT,04f43acd-5a75-4946-b8eb-8c2b4aa000c3,0x800,0x100000)/\EFI\systemd\systemd-bootx64.efi
Boot2001* EFI USB Device        RC

重启到指定 EFI 启动项

$

sudo efibootmgr -n 四位数序号

修改 Linux Boot Manager 的下一次启动项/默认启动项

仅适用于使用 systemd-boot 启动的系统,如果你在使用 Grub,请参阅其他教程。

$

bootctl list

执行此命令后,可以列出如下所示的启动项列表:

text
         type: Boot Loader Specification Type #1 (.conf)
        title: Arch Linux (default) (selected)
           id: 10-arch.conf
       source: /boot//loader/entries/10-arch.conf
        linux: /boot//vmlinuz-linux
       initrd: /boot//amd-ucode.img
               /boot//initramfs-linux.img
      options: root=PARTUUID=7227604a-aca1-034d-9bd3-e17d53548a62 rw rootfstype=btrfs

         type: Automatic
        title: Windows Boot Manager
           id: auto-windows
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f

         type: Automatic
        title: Reboot Into Firmware Interface
           id: auto-reboot-to-firmware-setup
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f

使用此命令可以修改 Linux Boot Manager 的下一次启动项,若想修改默认启动项,请使用 set-default 选项。

$

sudo bootctl set-oneshot [ID]