billw2 / rpi-clone

A shell script to clone a booted disk.
BSD 3-Clause "New" or "Revised" License
2.48k stars 327 forks source link

clone mmcblk0 to sdb while booted with sda #131

Open Barabba11 opened 2 years ago

Barabba11 commented 2 years ago

Hi, I've a SD wiht a license I want to clone for a spare copy, I can't boot pi with mmcblk because I can't install rpi-clone. So I booted with an usb slick with original raspbian, as sda. Then I've inserted mmcblk and sdb (USB) , now if I launch rpi-clone I can just clone sda to mmcblk, as sda is the sytem and I don't want to risk that because I need to preserve mmcblk. I can't risk to overwrite mmcblk. Shortly I want to clone mmcblk to sdb, while sda keeps as the root folder. How to do that? Thank you

bwims commented 2 years ago

Can I bump this please? I'd like to use my a400 to clone two separate devices too.

Barabba11 commented 1 year ago

this question still not solved, any help? How can I clone mmcblk to sdb (and viceversa) while having sda as raspbian boot drive with rpi-clone? Looks so easy but I'm getting frustrated

bwims commented 1 year ago

I solved my own problem later, when I realised that rpi-clone is simply based on the linux "dd" command.

I found a useful article here which explained how it works.

The good thing about rpi-clone is that it backs up the running system without much thought, which is normally what I want to do, when running off an SDD.

If, however, I want to back up a 2nd device to a 3rd device, then this is what I do:

sudo dd if=/dev/sdX of=/dev/sdY bs=4096 conv=notrunc,noerror

where if=input (X is the 2nd controller letter), of=output (Y is the 3rd controller letter), notrunc = do not truncate the output file and noerror = continue after read errors

For my purposes, copying one sd card to another, this works fine.

Barabba11 commented 1 year ago

Thank you for your kind solution, I'll give a chance. Probably rpi-clone is doing more, like resizing partitions and so on, it looks more safe for cloning a drive that should work as boot after. Rpi-clone sadly misses the chance to specify the source drive, if it's possible to implement it we can have chances to clone different drives, not only the boot one as source. Thanks

PS: there is another option except DD, it's Win32DiskImageWriter under windows but it has 2 disadvantages: 1) you need a equal-bigger destination drive (sometimes equal capacity SD may differ for one byte less only,, and that's enough to stop the program to proceed), 2) you need to dump all space to a 3rd drive, and write all space back to the new SD, long and painful.

bwims commented 1 year ago

Yes, I used to use win32diskimage as you say, and abandoned it the moment I discovered rpi-clone, and through it, dd .

dd has never caused me problems, and it's easy to use.