这里写目录标题
- `autoboot.txt`
- `boot_partition`
- `[tryboot]` 过滤器
- `tryboot_a_b`
- A/B引导的示例更新流程
文章来源: http://raspberry.dns8844.cn/documentation
原文网址
autoboot.txt
autoboot.txt
是一个可选的配置文件,可用于指定 boot_partition
编号。
这也可以与 tryboot
功能结合使用,以实现操作系统升级的A/B引导。
autoboot.txt
限制为512字节,并支持 [all]
、 [none]
和 [tryboot]
条件 过滤器。
另请参见 TRYBOOT 引导流程。
boot_partition
指定用于引导的分区号,除非分区号已指定为 reboot
命令的参数(例如 sudo reboot 2
)。
分区号从 1
开始,MBR分区是 1
到 4
。指定分区 0
意味着从 default
分区启动,这是第一个可启动的FAT分区。
可引导分区必须格式化为FAT12、FAT16或FAT32并包含 start.elf
文件(或Raspberry Pi 5上的 config.txt
文件)才能被引导加载程序归类为可引导。
[tryboot]
过滤器
如果系统使用 tryboot
标志设置启动,则此过滤器通过。
$ sudo reboot "0 tryboot"
tryboot_a_b
将此属性设置为 1
以在设置 tryboot
标志时加载正常的 config.txt
和 boot.img
文件,而不是 tryboot.txt
和 tryboot.img
。
这使得 tryboot
切换可以在分区级别而不是文件级别进行,而无需修改A/B分区中的配置文件。
A/B引导的示例更新流程
下面的伪代码展示了假设的操作系统 "更新服务 "如何使用 autoboot.txt
中的 tryboot
来执行故障安全操作系统升级。
初始化 autoboot.txt
:
[all]
tryboot_a_b=1
boot_partition=2
[tryboot]
boot_partition=3
安装更新
- 系统开机并默认引导到分区2
Update service
将下一个版本操作系统下载到分区3- 通过重新启动到
tryboot
模式reboot"0 tryboot"
测试更新,其中0
表示默认分区
提交或取消更新
- 系统从分区3启动,因为
[tryboot]
过滤器在tryboot mode
中的计算结果为true - 如果tryboot处于活动状态(
/proc/device-tree/chosen/bootloader/partition
)
** 如果当前引导分区(/proc/device-tree/chosen/bootloader/partition
)与autoboot.txt
的[tryboot]
部分中的boot_partition
匹配
***Update Service
验证系统以验证更新是否成功
*** 如果更新成功
**** 替换autoboot.txt
交换boot_partition
配置
**** 正常重启-分区3现在是默认启动分区
*** Else
****Update Service
将更新标记为失败,例如它删除更新文件。
**** 正常重启-分区2仍然是默认启动分区,因为tryboot
标志会自动清除
*** End if
** End If - End If
更新 autoboot.txt
[all]
tryboot_a_b=1
boot_partition=3
[tryboot]
boot_partition=2
更新 autoboot.txt
后不一定要重新启动。不过,Update Service
必须小心避免覆盖当前分区,因为 autoboot.txt
已被修改以提交上次更新。有关详细信息,请参阅 设备树参数。