备份树莓派就是把 SD 卡数据备份,恢复就是还原数据到 SD 卡,类似于以前的 GHOST 备份。
使用 diskutil list
查找 SD 卡设备:
...
/dev/disk5 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *32.0 GB disk5
1: Windows_FAT_32 system-boot 268.4 MB disk5s1
2: Linux 31.7 GB disk5s2
备份系统
sudo dd bs=4m if=/dev/disk5 | gzip > RaspiOS.img.gz
备份完成后,输出结果:
7632+0 records in
7632+0 records out
32010928128 bytes transferred in 3214.956889 secs (9956876 bytes/sec)
还原系统
gunzip --stdout RaspiOS.img.gz | sudo dd bs=4m of=/dev/disk5
恢复成功后,输出结果:
0+488448 records in
0+488448 records out
32010928128 bytes transferred in 3220.841360 secs (9938685 bytes/sec)
如果遇到报错信息:
dd: /dev/disk5: Resource busy
需要先卸载磁盘:
diskutil unmountDisk /dev/disk5
看到卸载成功提示:
Unmount of all volumes on disk5 was successful
再执行恢复命令就可以了。
官方参考资料
https://www.raspberrypi.org/documentation/linux/filesystem/backup.md