Putting file systems onto SDcards

If the file system is not available as if a SDcard needs to be copied the SDcard contents can be copied into a file: dd if=/dev/sdf of=<name>.img


Check where the SDcard is plugged in. It should be high speed.

If the image is copied to an SDcard some of the following will happen:

  1. SDcard is larger than the image. The image will be put on the SDcard but the unused space is lost

  2. SDcard has the same size as the image. This is the perfect case.

  3. SDcard is smaller than the image. Some of the file system will not be written to the SDcard. The impact is therefore unknown.

Therefore it is wise to check if the file system fits to the SDcard and in case the SDcard is bigger it is worth to enlarge the file system to the optimum size. fdisk -l shows how many bytes can be stored.

To know how much can be written to the SDcard using dd the SDcard can simply be read by dd: dd if=/dev/sdf of=dummy.img

Now re- check the file size of <name>.img and dummy.img to face the situation.

truncate is the command that also can do the opposite as enlarge a file system so truncate --reference dummy.img <name>.img expands the <name>.img file system to fit the SDcard.

Finally writing it to the SDcard dd if=<name>.img of=/dev/sdf

Before removing the SDcard sync will assure that everything will be written down.

Linurs Servernest startpage