How to dump the SDCard content to an image file

1 minute read

This post shows a way to dump the content of a booting SDCard to an image file with purpose of duplicating the SDCard or sharing its image.

Determine the origin SDCard blocksize and the number of sectors to be copied

$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 7.3 GiB, 7780433920 bytes, 15196160 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: 0x00000000

Device     Boot Start    End Sectors Size Id Type
/dev/sdb1        2048  34815   32768  16M 53 OnTrack DM6 Aux3
/dev/sdb2  *    34816  67583   32768  16M  c W95 FAT32 (LBA)
/dev/sdb3       67584 190463  122880  60M 83 Linux

The line Units: sectors of 1 * 512 = 512 bytes describes the size of a sector on this SDCard. In this example, it’s 512 bytes.

The line /dev/sdb3 67584 190463 122880 60M 83 Linux lists the latest partition on that device, including the number of sectors used until its end, which is also used to calculate the dump command line. In this example, it’s 122880 sectors.

Dump it in an image file

sudo dd if=/dev/sdb of=dump.sdcard bs=512 count=122880

Duplicate the image in another SDCard

sudo dd if=dump.sdcard of=/dev/sdX

Leave a Comment