How to clone Micro SD Card

I was using PI 4 and running hassio. At certinain point it was not working and getting this error;

I tried to put the SD card in another PI and got same error. If I add to SD card reader and connect to pc, I can read the files.

Is there a way to clone from one SD cart to anther withour staring everything from “0”?

This is the way I have ben doing it -

Get another microSD Card and install rasbpian on it and the vnc viewer on it and my PC. Then I have a headless desktop for the RPI to connect and work on it with my PC. YOu have to be running on a different (third) SD Card so the copy does not fail due to “something changed” message (and then the copying aborted) which is received quite often if you are trying to copy from the currently in use SD card.

For speed I have HA running on an SSD with my RPI4 (plugged into the USB 3.0 port) and run with no sd card even in the slot. For backup I have another SSD of the same size (but a different model*, luckily) with another cable of the same type.

Then I just boot up the RPI on only the rasbpian SD card, and use VNC viewer for a desktop on the RPI, then plug in both SSD’s and use the “SD Card Copier” app to copy one SSD to the other. *The only problem with this is, if both SSD’s of mine were the same model, then they have the same name in the SD Card Copier app so I would have no way of knowing which is which!

You can do the same if you have a couple of adapters to allow you to plug the other SD cards into the USB ports.

My backup works perfectly and it is good to do it this way because there are two different partitions on the sd cards, etc. And it is easy to test by shuttong down the RPI, switch SSD’s and turn it back on to test - that has always worked perfectly.

I am sure there is a better way of doing this but that is how I do a backup from time to time. I have tried over the last cvouple of years to dop pretty funcky things while learning and have wrecked my setup several times, but have always been saved by having a recent backup…

I use Win32DiskImager. I remove the SD card from my RPi4, put it into a USB adapter, plug it into my PC and create an image file of the SD card on my PC. This image file can be written back to a new SD card. Note: the SD cards must be the same size AND you must have enough diskspace on the PC to hold the entire size for the SD card.

I have not tried to make an image of a corrupted SD card; so, I do not know if there will be a read failure when doing this.

I like this. But I have a different way (not better) because I have committed to using only SD cards. See my thought here:

@MaxK you might want to try an SSD just for fun. The whole thing runs like 10x faster. I use a Samsung T7 - it comes with a cable that fits and no additional power source is needed.

I use win32diskimager to back up the card. If you are running Google Drive on your pc, close it or win32diskimager may not start. Also click on read only allocated partitions.

Before I do that I put the card in another pi via an usb adapter so I can run gpartd and shrink the card so I’m not backing up empty stuff. You can expand it back after the back up.

1 Like

I forgot to mention that (I run into the same problem too). Thanks for that and the other suggestions!

1 Like

When I ran a supervised install from my RPi’s SDCard I used this nifty little thing:
GitHub - billw2/rpi-clone: A shell script to clone a booted disk.

Not sure if it’s still working and if/how you’d get it to run in your setup.
I’ve moved to an SSD a few years ago, so I don’t use it any more.

1 Like

@chairstacker Thank you for this

This does not help me. I am able to read only in windows pc not in mac the sd card. I see files there (.dat, .dtb, overlays, etc). In win32diskimager I can not do anything. How to clone the files to another sd card?

You will probably need to recover from a backup.

Another option is to create a new install on a new SD card and copy the config and storage files from the old SD card over to the new install. I have not done this but there are other post on this forum that describe how to do this.

I do not have a backup to restore. Have to somehow recover from old sd card

Can you find the directory on the old SD card where configuration.yaml is located?

no, it is in another partition and that is not visible. Only booting partition is visible.

For Windows, you will need Linux Reader to read the SD card

1 Like

So I was able to restore ( I think). With Linux Reader I was able to open the SD card partition and find a backup. I installed fresh version and restored. Now if I connect to PI I can see that it is started but can not access with local ip, probably because it was configured with duckdns. Also through duckdns not able. Trying to figure out why.

@thuva SD Card Copier works every single time, flawlessly

Just used Win32DiskImager to move from a 8GB to a 128GB sd card, works nicely. My card was not corrupted though.

I had read that when copying to a larger SD card, an extra step may be needed to extend the file system to utilize the full capacity of the target SD card. I would check the 128GB card to see if the full capacity is there.

I was also expecting that I have to take another step to get the full capacity working. But it just woke up like this:
image

1 Like

I tried with Win32DiskImager, but was not able to. It failed reading. So I did a fresh install and then went with a backup using Linux Reader