技术解析

树莓派 SD 卡 Linux 系统盘复制, 10 分钟克隆新机, raspbain 备份恢复
0
2021-06-22 07:24:46
idczone

树莓派 SD 卡 Linux 系统盘复制,10 分钟克隆新机,raspbain 备份恢复

原文: https://blog.pythonwood.com/2017/11/%E6%A0%91%E8%8E%93%E6%B4%BESD%E5%8D%A1Linux%E7%B3%BB%E7%BB%9F%E7%9B%98%E5%A4%8D%E5%88%B6%EF%BC%8C10%E5%88%86%E9%92%9F%E5%85%8B%E9%9A%86%E6%96%B0%E6%9C%BA/

发现 raspbian 系统可在不同树莓派之间通用,挺好。

不用重复“ 系统安装 -> 软件安装 -> 配置软件 "的老装机模式。 有旧和新树莓派二个,用如下过程,可以快速复制克隆,给新树莓派克隆系统,从此硬件升级一步到位,批量升级 linux 系统时收益更大。

  1. dd 读取为 raw 镜像盘、
  2. resize2fs 缩容分区、
  3. qemu-img 缩容 disk、
  4. dd 写入成功启动树莓派

原文出自 Pythonwood 的https://blog.pythonwood.com


之前遇到类似问题,dd 一个系统,sd 卡大小 64gb,但是系统只用了 4gb 左右,dd 出来却有 60gb 左右,想知道怎么直接 dd 一个 4gb 左右大小的 img 文件

usbit 这个软件怎么样,整体克隆

其实 2 是可行的,你姿势不对
用 lsblk 查看 UUID,然后修改 fstab 和 grub 里的 UUID

傻瓜式。系统附件里面使用
SD Card Copier v1.0
This is an application to copy and back up SD cards. To use it, you will need a USB SD card writer.
To back up your Raspberry Pi's internal SD card, insert a blank SD card into a USB card writer and connect it to your Pi. Then start the application, choose your card writer from the “ Copy To Device ” drop-down box and press “ Start ”. The copy process will take 10-15 minutes depending on the size of your card.
The resulting card should be a bootable copy of your existing card; to restore, simply place the backup card into the onboard SD card slot, put the card to restore onto into the USB writer and repeat the copy process above.
You can also back up to a standard USB stick, and then restore from the USB stick to an SD card by setting the “ Copy From Device ” drop-down to the USB stick and the “ Copy To Device ” to a USB card writer containing the card to restore onto.
Note that you cannot copy onto the SD card from which your Pi is currently booted, which is why it does not appear in the “ Copy To Device ” dropdown.
Note also that the destination card doesn ’ t need to be the same size as the source card, but it must have enough space to hold all the data that is on it. The application will warn you if there is insufficient space on the destination.
Under Raspbian Stretch and later versions, you cannot mount two partitions with the same UUID, so you will not be able to mount a cloned SD card when booted from the disk from which it was cloned. If you need to do this, check the "New Partition UUIDs" box before copying.

其实 Linux 都是这样的,我一个 08 年安装的 Kubuntu 迁移了 5 次也没问题

win32 disk image 不考虑下?

/dev/disk/by-partuuid 是内核自动生成和管理的吧,可以看下整个 /dev 都是挂载的一个 devtmpfs,而且对于 archlinux arm 等来说系统直接就是一个 tar,所以 tar 无法备份还原可能打开方式不对。
主要是 dd 的效率太低了,尤其是空间使用率不高时。
奇怪建议:你可以在新 sd 卡分区格式化时指定 uuid,这样理论上是不用修改原系统的 fstab 等。对应选项:
mkfs.ext4 -U xxxx-xxxx-....
mkfs.vaft -i xxxxxxxx

我也有这个需求,要能做个 gui 的工具傻瓜式操作就好了。

08 年就用 kubuntu 了,是 8.04 吗? 我最开始用的 10.04 ,也要好好保存。

/>是 8.04 ,维护好可以持续升级,比重装方便

几年前,改写过一个脚本,能满足你的需求,你可以参考看看 htxps://github.com/imccie/rpi_backup_script

https://github.com/dosgo/pi-image 可以用这个备份

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服