SD Card Reading and Writing with Linux dd
Preamble
Just a quick post as a personal note for a reminder on how to use the dd command to read and write SD card images. This can be useful when working locally with Raspberry Pi and NVidia Jetson style embedded computers.
Determine the Device Location
We need to determine the path for the SD card we intend to use, whether the operation is reading or writing.
sudo fdisk -l
Returns a list of all of the available partitions and drives. We are interested in this 64GB SD card.
Disk /dev/mmcblk0: 59.64 GiB, 64021856256 bytes, 125042688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x87c6153d
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 2048 526335 524288 256M c W95 FAT32 (LBA)
/dev/mmcblk0p2 526336 125042654 124516319 59.4G 83 Linux
Now we need to unmout the media before we can safely read or write from it with dd.
sudo umount /dev/mmcblk0
Reading
The command below will create a sd_card_image.img image file from the SD card image in your users home directory.
sudo dd if=/dev/mmcblk0 of=~/sd_card_image.img bs=4M status=progress
Writing
This command will take a sd_card_image.img image file from your local home directory and write it to your SD card.
sudo dd of=/dev/mmcblk0 if=~/sd_card_image.img bs=4M status=progress
Resources and Further Reading
Hey you!
Found this useful or interesting?
Consider donating to support.
Any question, comments, corrections or suggestions?
Reach out on the social links below through the buttons.