0

I need to transfer the contents of my SD card (raspbian setup, so fat32 + ext4) to a new SD card because it's approaching end of life. Indeed this filesystem was created with badblocks' aid to mkfs which skips bad locations.

Now, it's has been discussed the proper way to copy the fs; but I can't do that right away because I don't have a way to physically mount two SDHC at the same time. So I thought one way (there could be others) could be "buffering" that old fs to a certain directory on my other machine (e.g. /tmp/fs) and only then transfer to the new card.

My questions is: is it safe to do so? I do know care must be taken when copying filesystems around. Are there any other ways?

7
  • Is "my machine" the Pi, or a different (second) machine? Dec 4, 2019 at 17:44
  • @roaima: Yes it's a different one. It'd be a notebook so even an entirely different architecture.
    – edmz
    Dec 4, 2019 at 17:46
  • You can transfer the entire filesystem into a file on a local directory assuming you have the space. Then transfer that into the filesystem of a new memory card. Finally you can calculate the checksum of the original filesystem, then the checksum of the new filesystem and make sure they are identical. The partitions need to be of exactly the same size for this to work. Later you can increase the size of the new partition if wanted. If this sounds like what you want to do I can write detailed instructions as an answer. Dec 4, 2019 at 17:47
  • Does your notebook have a SDHC card reader? Dec 4, 2019 at 17:49
  • @roaima: Yes it does. That's the way I installed raspbian back then actually.
    – edmz
    Dec 4, 2019 at 17:52

1 Answer 1

1

Cloning

If your new card is at least as big as the old card (not one single byte smaller), cloning from the old card to an image file, and cloning from the image file to the new card should work.

Crude cloning tools

You can do it with cat or cp or pv or dd in a crude and risky way. It should work, but you had better double-check to avoid spelling errors or other mistakes, that can make the cloning process overwrite valuable data. These tools will do what you tell them to do without any question, even if you them to overwrite the family pictures.

Clonezilla

You can do it with Clonezilla, easiest by making a USB live drive from a Clonezilla iso file. This tool is both faster and safer.

It is smart enough to only copy used blocks in the file systems plus bootloaders and partition table data and file system metadata. So free drive space will be skipped. There is also compression. The process will be faster and the image (in this case a directory with a set of files) will be much smaller than a crude cloned image.

Clonezilla is also safer because it helps you via a user interface to 'see' what you are doing and there is a final checkpoint, where you can make sure that you will do what you want to do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .