SD/eMMC Setup Guide
This is a general guide for preparing SD/eMMC devices for use with Linux, including formatting, partitioning, mounting, and writing full disk images.
Manual Partitioning and Formatting
General guide for manually creating partitions and filesystems on SD/eMMC devices.
-
Identify the device
$ ls -l /dev/mmc* $ dmesg | grep mmcThe device typically appears as
/dev/mmcblk0. -
Partition the device (using fdisk or parted)
$ fdisk /dev/mmcblk0 # Create a new partition table (type 'o' for DOS/MBR or 'g' for GPT) # Create a new partition (type 'n') # Set partition type if needed (type 't') # Write changes (type 'w') -
Format the partition
$ mkfs.ext4 /dev/mmcblk0p1 # For ext4 filesystem $ mkfs.vfat /dev/mmcblk0p1 # For FAT32 filesystem -
Mount the partition
$ mkdir -p /mnt/sdcard $ mount /dev/mmcblk0p1 /mnt/sdcard -
Verify mount
$ df -h | grep mmcblk $ mount | grep mmcblk
Writing a Full Disk Image
General guide for writing a complete disk image to SD/eMMC devices.
If you have a complete disk image (with GPT partition table and all partitions), you can write it directly to the SD/eMMC device using dd:
-
Identify the target device
$ ls -l /dev/mmc*Make sure you have identified the correct device. Writing to the wrong device will destroy its data. -
Write the disk image
$ dd if=disk-image.img of=/dev/mmcblk0 bs=4M oflag=direct status=progress $ syncWhere:
-
if=specifies the input file (your disk image) -
of=specifies the output device (your SD/eMMC device) -
bs=4Msets the block size to 4MB for better performance -
oflag=directbypasses the kernel buffer cache for direct writes -
status=progressshows transfer progress -
syncflushes device write caches (still recommended even withoflag=direct)
-
-
Verify the write
$ sync $ blockdev --rereadpt /dev/mmcblk0 $ fdisk -l /dev/mmcblk0