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.

  1. Identify the device

    $ ls -l /dev/mmc*
    $ dmesg | grep mmc

    The device typically appears as /dev/mmcblk0.

  2. 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')
  3. Format the partition

    $ mkfs.ext4 /dev/mmcblk0p1    # For ext4 filesystem
    $ mkfs.vfat /dev/mmcblk0p1    # For FAT32 filesystem
  4. Mount the partition

    $ mkdir -p /mnt/sdcard
    $ mount /dev/mmcblk0p1 /mnt/sdcard
  5. 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:

  1. 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.
  2. Write the disk image

    $ dd if=disk-image.img of=/dev/mmcblk0 bs=4M oflag=direct status=progress
    $ sync

    Where:

    • if= specifies the input file (your disk image)

    • of= specifies the output device (your SD/eMMC device)

    • bs=4M sets the block size to 4MB for better performance

    • oflag=direct bypasses the kernel buffer cache for direct writes

    • status=progress shows transfer progress

    • sync flushes device write caches (still recommended even with oflag=direct)

  3. Verify the write

    $ sync
    $ blockdev --rereadpt /dev/mmcblk0
    $ fdisk -l /dev/mmcblk0