Skip to content

Setup SD Card Partition

Edwin edited this page Dec 27, 2018 · 2 revisions

Setup SD Card Partition

To build a boot-able SD card for i.MX8 board,
we have to build 2 partition in SD card. First partition is FAT32 for kernel, and another is ext4 for root file system.

Image Layout

Start Address Size(sectors) Format Usage
0x400 (2) 0x9ffc00(20478) RAW mkimage
0xa00000(20480) 50MB(1024000) FAT Kernel Image
0x25800000(1228800) To the End Ext3/Ext4 root-fs

Create Partition

In this case my drive is at /dev/sdb.

  • First make sure the drive is NOT mounted.
sudo umount /dev/sdb1

sudo fdisk /dev/sdb

Command (m for help): p
Disk /dev/sdb: 3.7 GiB, 3980394496 bytes, 7774208 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        8192 7774207 7766016  3.7G  b W95 FAT32
  • If you have partition already, delete it first
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
  • Create 1st partition
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

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): 
First sector (2048-7774207, default 2048): 20480
Last sector, +sectors or +size{K,M,G,T,P} (20480-7774207, default 7774207): +50M

Created a new partition 1 of type 'Linux' and of size 50 MiB.
  • Create 2nd Partiion
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-7774207, default 2048): 1228800
Last sector, +sectors or +size{K,M,G,T,P} (1228800-7774207, default 7774207): 

Created a new partition 2 of type 'Linux' and of size 3.1 GiB.
  • Final result will be like following.
Command (m for help): p
Disk /dev/sdb: 3.7 GiB, 3980394496 bytes, 7774208 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         20480  122879  102400   50M 83 Linux
/dev/sdb2       1228800 7774207 6545408  3.1G 83 Linux
  • Don't forget to write table to disk!
Command (m for help): w
The partition table has been altered.

Format Partition

Now we have to format each partition to correct format.

  • vFAT for Kernel
sudo mkfs.vfat /dev/sdb1

mkfs.fat 3.0.28 (2015-05-16)
  • Ext4 for Root-fs
sudo mkfs.ext4 /dev/sdb2

mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 818176 4k blocks and 204800 inodes
Filesystem UUID: 07b7109a-0e74-4af0-aac9-90349721e2e8
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

What's Next?!

Now you can dd the flash.bin, copy kernel and dump root file system to your SD card!

Enjoy!