Skip to content

Instantly share code, notes, and snippets.

@tomoaki0705
Created October 8, 2019 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoaki0705/03648fd25a355fde7f82ddd4f0b52878 to your computer and use it in GitHub Desktop.
Save tomoaki0705/03648fd25a355fde7f82ddd4f0b52878 to your computer and use it in GitHub Desktop.
How to mount a SD card image to a file system

https://oplern.hatenablog.com/entry/2017/06/30/231027

$ sudo mount -t ext4 -o loop MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img /home/nvidia/work/temp/mnt/
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
  • This happens when your img file is valid but there are multiple paritions in the img file.
  • You need to specify the offset for each partition, and for this you need to check yousin 'fdisk'
$ fdisk -l -u MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img
Disk MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img: 2.6 GiB, 2788163584 bytes, 5445632 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: 0xb576fa97

Device                                            Boot  Start     End Sectors  Size Id Type
MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img1 *     20480  544767  524288  256M  c W95 FAT32 (LBA)
MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img2      544768 5445631 4900864  2.3G 83 Linux
  • 278921216 is 544768 (Start) * 512 (Sector size)
  • Mount using -o option and specify the offset
$ sudo mount -t ext4 -o loop,offset=278921216 MaaXBoard-LinuxShipmentImage-Yocto-V1.0.6r07.img /home/nvidia/work/temp/mnt/
$ cd mnt/
$ ls
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  run  sbin  sys  tmp  unit_tests  usr  var
$ cd etc/OpenCL/vendors/
$ ls
Vivante.icd
$ cat Vivante.icd 
libVivanteOpenCL.so
$ cd ../../../usr/
$ find . -name libVivanteOpenCL.so 2> /dev/null
./lib/libVivanteOpenCL.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment