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

2018-05-09 13:24:31 +08:00
 pythonwood

树莓派 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

7666 次点击
所在节点    Linux
12 条回复
songz
2018-05-09 14:35:29 +08:00
之前遇到类似问题,dd 一个系统,sd 卡大小 64gb,但是系统只用了 4gb 左右,dd 出来却有 60gb 左右,想知道怎么直接 dd 一个 4gb 左右大小的 img 文件
ys0290
2018-05-09 15:01:35 +08:00
usbit 这个软件怎么样,整体克隆
ryd994
2018-05-09 15:13:52 +08:00
其实 2 是可行的,你姿势不对
用 lsblk 查看 UUID,然后修改 fstab 和 grub 里的 UUID
zgzh
2018-05-09 15:31:58 +08:00
傻瓜式。系统附件里面使用

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.
autoxbc
2018-05-09 15:36:00 +08:00
其实 Linux 都是这样的,我一个 08 年安装的 Kubuntu 迁移了 5 次也没问题
EzBlue
2018-05-09 15:38:18 +08:00
win32 disk image 不考虑下?
Osk
2018-05-09 16:24:49 +08:00
/dev/disk/by-partuuid 是内核自动生成和管理的吧,可以看下整个 /dev 都是挂载的一个 devtmpfs,而且对于 archlinux arm 等来说系统直接就是一个 tar,所以 tar 无法备份还原可能打开方式不对。

主要是 dd 的效率太低了,尤其是空间使用率不高时。

奇怪建议:你可以在新 sd 卡分区格式化时指定 uuid,这样理论上是不用修改原系统的 fstab 等。对应选项:
mkfs.ext4 -U xxxx-xxxx-....
mkfs.vaft -i xxxxxxxx
pythonwood
2018-05-09 22:30:51 +08:00
我也有这个需求,要能做个 gui 的工具傻瓜式操作就好了。
pythonwood
2018-05-09 22:36:40 +08:00
@autoxbc 08 年就用 kubuntu 了,是 8.04 吗? 我最开始用的 10.04 ,也要好好保存。
autoxbc
2018-05-09 23:13:48 +08:00
@pythonwood #9
是 8.04 ,维护好可以持续升级,比重装方便
doublew
2018-05-28 13:45:33 +08:00
几年前,改写过一个脚本,能满足你的需求,你可以参考看看 htxps://github.com/imccie/rpi_backup_script
dosgo
2020-10-19 12:18:22 +08:00
https://github.com/dosgo/pi-image 可以用这个备份

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/453417

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX