Yocto Project: reading partitons in the sdcard image from a Linux Host

Document created by Curtis Wald Employee on Apr 15, 2015Last modified by Curtis Wald Employee on Sep 8, 2015
Version 2Show Document
  • View in full screen mode

As of this writing, April 2015, the default sdcard image created from a Yocto Project build has all the software images nicely aligned to create a SD CARD.

There are two partitions within the image:

1. A W95 FAT32 (LBA) partition that contains the Linux zImage, and various device tree binary (dtb) files.

2. A Linux root file system.


Each partition can be mounted from your Linux host computer, then you can view the partition contents.


Here are the steps based on the core-image-base recipe for the imx6sxsabresd machine using Yocto Project release L3.14.28_1.0.0_GA.


The name of the image: core-image-base-imx6sxsabresd.sdcard


1. Determine where the partitions are using the fdisk command:


$ fdisk -l core-image-base-imx6sxsabresd.sdcard

Disk core-image-base-imx6sxsabresd.sdcard: 100 MB, 100663296 bytes
4 heads, 32 sectors/track, 1536 cylinders, total 196608 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
Disk identifier: 0x00074663

                               Device Boot      Start         End      Blocks   Id  System
core-image-base-imx6sxsabresd.sdcard1            8192       24575        8192    c  W95 FAT32 (LBA)
core-image-base-imx6sxsabresd.sdcard2           24576      188415       81920   83  Linux



2. Determine the byte offset into the sdcard image of where each partition starts:


a. core-image-base-imx6sxsabresd.sdcard1 starts at sector 8192. One sector unit is 512 bytes.

8192 * 512 = 4194304

b. core-image-base-imx6sxsabresd.sdcard2 starts at sector 24576.

24576 * 512 = 12582912


3. Mount Partitions

First create mount points:

$ sudo mkdir /mnt/{mp1,mp2}

a. sdcard1 partition

$ sudo mount -o loop,offset=4194304 core-image-base-imx6sxsabresd.sdcard /mnt/mp1

b. sdcard2 partition

$ sudo mount -o loop,offset=12582912 core-image-base-imx6sxsabresd.sdcard /mnt/mp2

4. View the contents of each mounted partition

$ ls /mnt/mp1
imx6sx-sdb.dtb       imx6sx-sdb-lcdif1.dtb  imx6sx-sdb-reva.dtb      imx6sx-sdb-sai.dtb
imx6sx-sdb-emmc.dtb  imx6sx-sdb-m4.dtb      imx6sx-sdb-reva-ldo.dtb  zImage
$ ls /mnt/mp2
bin  boot  dev  etc  home  lib  lost+found  media  mnt  proc  run  sbin  sys  tmp  usr  var


5. When done release the mount points and remove them from /mnt

$ sudo umount /mnt/{mp1,mp2}

$ sudo rm /mnt/{mp1,mp2}