0

I have a headless raspberry pi running Home Assistant and a bunch of other docker containers. It has been running on a 64GB SD for some time and runs fine, but very occasionally runs out of space due to accumulated downloads or similar.

I bought a new 256 GB EVO card, and am trying to clone the old one to the new.

On a linux laptop with SD reader, I did

sudo dd if=/dev/sda bs=1M of=pi-image.img

then switch the SD card in the reader to the new one and did

sudo dd if=pi-image.img bs=1M of=/dev/sda

When I insert the new card into the pi and power it on, I get a mass of messages, the final one of which is:

not syncing : no working init found. Try passing init option to kernel. see Linux documentation for guidance

I checked the cmdline.txt file, and blkid for the root partition and they matched

I then tried e2fsck on the new SD card, and there was a mass of errors on the rootfs that I tried fixing, but after re-inserting in the pi still the same errors.

I then tried:

  • e2fsck on the original SD, no errors
  • formatted the new SD to a single, full size ext4 partition and ran e2fsck - no errors

So given there are no errors in the first part of the process, how can I clone the original 64GB SD to the new 256GB SD without resulting in errors?

hitch
  • 103
  • 1
  • Consider piclone_cmd which is a command line version of piclone that you can run from the command line on your headless device – Drdrm46 Jun 05 '22 at 09:18
  • Possible duplicate of https://raspberrypi.stackexchange.com/questions/4203/copy-current-sd-image-to-larger-sd-card/108628#108628 – PMF Jun 05 '22 at 10:08
  • 1
    See [this answer](https://raspberrypi.stackexchange.com/questions/120124/how-to-copy-sd-card-whithout-copying-the-unallocated-space/120154#120154). – user68186 Jun 05 '22 at 16:44

1 Answers1

2

If you're using dd to write SD cards, you're wasting time, and using the wrong tool for the job. But please don't take my word for it - check other opinions, or do your own research.

I would suggest you approach this as follows:

  1. make an image-backup of your current SD card using image-backup. @user68186 has referenced a link that will walk you through the details.

    At the end of this process (which isn't long), you will have an .img file that contains an exact replica of every file and smidgen of data on your SD card.

  2. With that .img file, get a tool like Etcher to write your .img to your new SD card. Really - these tools make it very easy.

Seamus
  • 18,728
  • 2
  • 27
  • 57
  • 1
    For the second step, [RPi Imager](https://www.raspberrypi.com/software/) should also work. The other thing to note is when you boot from the new 256 GB SD card for the first time, the OS will automagically expand the system partition `/` to use all the empty space. – user68186 Jun 06 '22 at 00:50
  • Thanks for this - I tried using balena etcher, and the first time it wrote and validated, it said it had failed. So I ran it again and it was successful... so fingers crossed! – hitch Jun 07 '22 at 01:09