Prepare SD card
- Insert SD card / usb reader
- Identify the device:
MMC card reader
dmesg ... Oct 20 08:48:20 tableta kernel: mmc0: new high speed SDHC card at address aaaa Oct 20 08:48:20 tableta kernel: mmcblk0: mmc0:aaaa SL08G 7.40 GiB Oct 20 08:48:20 tableta kernel: mmcblk0: p1
USB card reader
dmesg ... Oct 20 08:52:38 tableta kernel: scsi 24:0:0:0: Direct-Access Generic- SD/MMC 1.00 PQ: 0 ANSI: 0 CCS Oct 20 08:52:38 tableta kernel: sd 24:0:0:0: Attached scsi generic sg1 type 0 Oct 20 08:52:39 tableta kernel: sd 24:0:0:0: [sdb] 32372736 512-byte logical blocks: (16.5 GB/15.4 GiB) ... Oct 20 08:52:39 tableta kernel: sdb: sdb1
Let's check once more in
/proc/partitions
cat /proc/partitions major minor #blocks name ... 179 0 7761920 mmcblk0 179 1 7757824 mmcblk0p1 8 16 16186368 sdb 8 17 16185344 sdb1
Here
/dev/sdb
represents the whole card in the USB reader and/dev/sdb1
is the first (and only) partition on that card. Similarly/dev/mmcblk0
represents the card in the MMC reader and/dev/mmcblk0p1
it's first partions.Let's use
/dev/mmcblk0
and/dev/mmcblk0pX
in the following examples.Note: depending on how paranoid your distro is you might not be able run
dmesg
and read/proc/partitions
as normal user. - Umount any partitions that got automatically mounted (depends on your distro, desktop environment and settings...)
- Partition the card to contain:
- A small FAT16 partition for boot files (say 128MB, though 32MB or even 16MB should be enough).
- Partition for the root filessytem (ext4 or similar)
Following commands will have to be executed under root:
- Erase the partition table / beginning of the card:
dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.0827764 s, 12.7 MB/s
- Run
fdisk
to re-create the partition table and create the partitions:- Use the help (
m
) command list available fdisk commands -
Create the first partition, set its type to
e
(W95 FAT16), and set it as bootable (a
, needed only for Beagle Bone, but doesn't hurt...) - Create the second partition and set its type to
83
(Linux)
fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.25.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x0c677597. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-15523839, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-15523839, default 15523839): +128M Created a new partition 1 of type 'Linux' and of size 128 MiB. Command (m for help): t Selected partition 1 Hex code (type L to list all codes): e If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information. Changed type of partition 'Linux' to 'W95 FAT16 (LBA)'. Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Partition number (2-4, default 2): First sector (264192-15523839, default 264192): Last sector, +sectors or +size{K,M,G,T,P} (264192-15523839, default 15523839): Created a new partition 2 of type 'Linux' and of size 7.3 GiB. Command (m for help): a Partition number (1,2, default 2): 1 The bootable flag on partition 1 is enabled now. Command (m for help): p Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 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: 0x549005c5 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 2048 264191 262144 128M e W95 FAT16 (LBA) /dev/mmcblk0p2 264192 15523839 15259648 7.3G 83 Linux Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Note: you can use also
cfdisk
for a curses-based interface. - Use the help (
- Format the first partition as FAT16:
mkfs.vfat -F 16 -n boot /dev/mmcblk0p1
- Format the seconds partition as ext4 (or similar):
mkfs.ext4 -L rootfs /dev/mmcblk0p2
- Mount the partitions as/when needed (or just remove and re-insert the card if you have automount enabled).