Clone a microSD card

  • I'm currently running LibreElec/Kodi on a Dell Optiplex and a RPi4. The Dell uses a 256GB SSD and I've cloned that to a backup 256GB SSD with no problem - tested and it runs. Cloning the microSD (128GB to 128GB) is a nightmare. I've tried three different cloning systems (CloneZilla, Macrium and Disk Genius) both in disk to disk mode and in disk to image to disk mode. None of them work. The best gets through to displaying the Kodi (21.0 beta) logo and the worst tells me there is disk corruption (when I checking the micoSD - need both Windows and Linux - out I'm told its fine).

    I'm assuming cloning should be possible since I can do it on the Dell - anyone tell me how.

  • SD cards frequently have different disk "geometry" ensuring the partition data copied from one card is incorrect once written to another card. The solution to that is to prepare the destination card to match the source partition/filesystem arrangement, mount the filesystems, then rsync the contents of the partition(s) instead trying to clone the entire physical (card) disk.

  • chewitt

    Based on the fact that LibreElac/Kodi can be installed on different media I'm guessing that the position/size of the FAT32 partition is the critical one and the EXT4 partition can then extend to whatever's left. Is that right?


    petediscrete

    Have you used that utility on LibreElec rather than Raspberry Pi OS?

  • If the goal is moving the RPi4 install from old to new SD card, take a backup in LE settings, clean install LE on the new card, then restore the backup. The backup only contains contents of /storage/.cache, /storage/.config, /storage/.kodi - If you aren't storing media on the SD card then a 16GB card is more than enough. If you are storing media use a USB>SD adapter to mount the old card once the backup is restored and copy media over to the new card. If no adapter, connect it to something else with a card reader and copy files over the network (it'll be slow, but you only do it once). NB: In nearly all cases copying/moving the content of the card will be faster than cloning tools as you only move e.g. 40GB of files on the card instead of copying 128GB of physical card.

    FAT32 (vfat) partition can be any size but we use 512MB for default. The storage partition can be 100% remaning size. The system boots using the UUIDs of the partitions so labels can be anything you like (see cmdline.txt).

  • I agree with "chewitt". Messing up the system with media files not a smart choise. I always prefere a small but fast SD-card for the LE and something else (NAS, external HDD/SSD, "big" USB-stick) for media files (or anything else). Less headache in the case of system (LE) upgrade, reinstall...

  • Firstly you asked for a cloning solution for your LE install. That’s what I supplied. Obviously the backup/restore solution would make a lot more sense.

    My solution is carried out on an RPIOS install. Simply achieved by swapping out the LE SD card with an RPIOS SD card.

    If you do decide to try this method I advise using this utility to shrink the image first to save time. As you know the first thing LE does on first boot is to expand the file system to the full size of the card so cloning a load of blank space is a waste of time

    GitHub - Drewsif/PiShrink: Make your pi images smaller!
    Make your pi images smaller! Contribute to Drewsif/PiShrink development by creating an account on GitHub.
    github.com
  • petediscrete

    I asked because this

    "This is an application which allows the SD card inserted into the Pi to be copied to one in a connected USB reader."

    is at the top of the readme. I have no idea if piclone runs under LibreElec and if not how to use it, nor why it should be any more effective than those I've tried so far.

    chewitt

    You now seem to be recommending a clean install and restore backup not cloning which is what I want to do. I know I was able to clone a 32GB to a 64GB microsd card and then resize the 64GB card's storage partition but going from 128GB to 128GB seems impossible.

    I haven't tried your idea of "preparing" the card (which I'm assuming means install LibreElec and then overwrite stuff) because my Linux PC doesn't want to recognise one card in its microsd slot and another one on a usb adapter at the same time.

    Why this is proving such a challenge I do not know but would like to.

  • Have a look at this. I use the same method to create small images of large drives. On the other hand, if the decompressed fs is not fitting on your new drive, you may want to shrink the partition with the most free space before creating the image, then when decompressed you can resize it to fit the remainder of the drive space.

  • I doubt any of the options you’ve used so far run under LE. If my option did I’d have mentioned it.

    I’ve given you options to both shrink and clone your SD card. What you do with them is entirely your own affair.

    The image shrinking would probably take all the heartache out of the process cloning. My preferred option would be to do a backup, fresh install and restore in the event of disaster.

    Everything you need to know about those two utilities is contained in the respective GitHubs plus a search should throw up user’s experiences with them.

  • You now seem to be recommending a clean install and restore backup not cloning which is what I want to do

    In my experience users fixate on "cloning" as the solution when there are easier and faster approaches. I'd guess that 75% of users seeking a cloning solution simply want to boot their system from a new card, and backing up the current install and restoring it to a clean install on the same LE version achieves this. The other 25% want to create a second LE instance with the same setup as the first, and the same backup and restore to same-version clean install achieves this too. True cloning is a pain in the rear as SD cards and USB sticks might have the same marketing size (128GB) but can have different sector counts due the nuances of manufacturing memory devices, which is a problem if making a bit-for-bit copy where the target device has a lower sector count (is smaller) than the source device. Cloning from smaller to larger devices doesn't have that problem so usually works fine.

  • vaughng

    At this point I have no idea if it will be useful but its a good description of dd. Good enough so that I might understand and use it - thanks.


    chewitt

    If it was simply to use LibreElec/Kodi I would be happy to use the backup, reinstall and restore approach. However, what I want to do is see if I can make some mods to the system, starting with something simple like skins (I like most of the default skin but some bits I want to change) and move on to a couple of addons. Whilst I couldn't clone an entire IBM 4341 or VAX 11/780 ever since the advent of micros that's what I've done. It means that when, inevitably, I mess up big time I can go back to my original start point. That, as I discovered recently, is not the case with backup, reinstall and restore.

    Whilst I've never had trouble cloning a system before I've only once tried it with microSD cards and RPi before. I might buy a couple of cheap SSDs and try those.

  • :):)

    Eureka - all I have to do is setup on a 16GB (the 8GB one wouldn't work) microSD card initially then I can clone to a 128GB card, plug into my Linux laptop to resize storage (weirdly enough it leaves c300MB at the end) but everything works.

    I just wish I'd thought of that a couple of days ago. ;(

  • Why you’re using a 128gb SD card to install LE on for the RPI4 is beyond me. Besides the reported problems from users here with 128gb sd cards running LE, you’re just going to end up hammering it with all those read/write requests.

    Surely a large capacity bootable SSD attached to the RPI4 would be the solution if you feel you need large storage capacity attached directly to the RPI4.

    Methinks you’re cloning around there a little too much 😂