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

Showing results for 
Search instead for 
Did you mean: 

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

No ratings

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

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 SDCARD.

10/7/2020: Update - SDCARD image names have been updated to images ending with .wic as the default from Yocto Project.  The process is the same for both .sdcard and .wic files.


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 read or write 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

Run the fdisk command to view the contents of the image:

$ 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


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

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

          8192 * 512 = 4194304

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

24576 * 512 = 12582912


Mount Partitions

First create mount points:

$ sudo mkdir /mnt/{mp1,mp2}


 sdcard1 partition

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

NOTE: An alternate method for determining the offset, see below:

$ sudo mount -o loop,offset=$((512 * 8192)) core-image-base-imx6sxsabresd.sdcard /mnt/mp1

sdcard2 partition

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

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


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

$ sudo umount /mnt/{mp1,mp2}
$ sudo rm /mnt/{mp1,mp2}


Version history
Revision #:
5 of 5
Last update:
‎10-07-2020 12:29 PM
Updated by: