看完脚本,其实恢复过程就是把镜像的root分区dd到硬盘的root分区,以及复制efi分区的内核文件,突然就明白idoz在帖子里说的是什么了。
所以发教程还是要说清楚原理才行。既然只是dd,不妨到linux系统里做,明天再实验,先把最后执行的内容和关键的几行脚本发上来。
# Get start and size of our root partition 计算root分区的起始位置和跨度
rootfs_start="`cgpt show -i 3 -n -b -q $image_file`"
rootfs_size="`cgpt show -i 3 -n -s -q $image_file`"
# Copy the Chrome OS kernel overtop the Chromium kernels. On recovery images
#复制内核
cp $WORKDIR/chrome_efi_mount/syslinux/vmlinuz.B $WORKDIR/chromium_efi_mount/syslinux/vmlinuz.B -f
cp $WORKDIR/chrome_efi_mount/syslinux/vmlinuz.B $WORKDIR/chromium_efi_mount/syslinux/vmlinuz.A -f
#拷贝root分区
dd if=$image_file of=/dev/sda3 bs=512 skip=$rootfs_start count=$rootfs_size
exit 0
为了直观中间删掉了挂载卸载的内容,下图是带入变量实际执行的内容。
