V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
pythonwood
V2EX  ›  Linux

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

  •  
  •   pythonwood ·
    pythonwood · 2018-05-09 13:24:31 +08:00 · 7624 次点击
    这是一个创建于 2150 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    12 条回复    2020-10-19 12:18:22 +08:00
    songz
        1
    songz  
       2018-05-09 14:35:29 +08:00
    之前遇到类似问题,dd 一个系统,sd 卡大小 64gb,但是系统只用了 4gb 左右,dd 出来却有 60gb 左右,想知道怎么直接 dd 一个 4gb 左右大小的 img 文件
    ys0290
        2
    ys0290  
       2018-05-09 15:01:35 +08:00 via iPhone
    usbit 这个软件怎么样,整体克隆
    ryd994
        3
    ryd994  
       2018-05-09 15:13:52 +08:00 via Android
    其实 2 是可行的,你姿势不对
    用 lsblk 查看 UUID,然后修改 fstab 和 grub 里的 UUID
    zgzh
        4
    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
        5
    autoxbc  
       2018-05-09 15:36:00 +08:00
    其实 Linux 都是这样的,我一个 08 年安装的 Kubuntu 迁移了 5 次也没问题
    EzBlue
        6
    EzBlue  
       2018-05-09 15:38:18 +08:00
    win32 disk image 不考虑下?
    Osk
        7
    Osk  
       2018-05-09 16:24:49 +08:00 via Android
    /dev/disk/by-partuuid 是内核自动生成和管理的吧,可以看下整个 /dev 都是挂载的一个 devtmpfs,而且对于 archlinux arm 等来说系统直接就是一个 tar,所以 tar 无法备份还原可能打开方式不对。

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

    奇怪建议:你可以在新 sd 卡分区格式化时指定 uuid,这样理论上是不用修改原系统的 fstab 等。对应选项:
    mkfs.ext4 -U xxxx-xxxx-....
    mkfs.vaft -i xxxxxxxx
    pythonwood
        8
    pythonwood  
    OP
       2018-05-09 22:30:51 +08:00
    我也有这个需求,要能做个 gui 的工具傻瓜式操作就好了。
    pythonwood
        9
    pythonwood  
    OP
       2018-05-09 22:36:40 +08:00
    @autoxbc 08 年就用 kubuntu 了,是 8.04 吗? 我最开始用的 10.04 ,也要好好保存。
    autoxbc
        10
    autoxbc  
       2018-05-09 23:13:48 +08:00
    @pythonwood #9
    是 8.04 ,维护好可以持续升级,比重装方便
    doublew
        11
    doublew  
       2018-05-28 13:45:33 +08:00
    几年前,改写过一个脚本,能满足你的需求,你可以参考看看 htxps://github.com/imccie/rpi_backup_script
    dosgo
        12
    dosgo  
       2020-10-19 12:18:22 +08:00
    https://github.com/dosgo/pi-image 可以用这个备份
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3384 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:19 · PVG 19:19 · LAX 04:19 · JFK 07:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.