Hot to mount img disk file

Some time you need make a lite change on img file. I show you how to use bash mount img disk file with partitions.

For test we will use raspberry pibian image from

When you try mount img image disk with partitions:

“mount: wrong fs type, bad option, bad superblock on /dev/loop2,
missing codepage or helper program, or other error

In some cases useful info is found in syslog – try
dmesg | tail or so.”


We need check disk :

fdisk -l   2017-01-11-raspbian-jessie-lite.img

Screenshot from 2017-02-10 16-29-44.png

We need information about Units sector size and start byte of partition:

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Sector size is 512 bytes

Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Device  Boot                                                   Start End Sectors Size Id Type
2017-01-11-raspbian-jessie-lite.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
2017-01-11-raspbian-jessie-lite.img2 137216 2715647 2578432 1.2G 83 Linux

We have information 1st partition start at 8192 sector and  second at 137216 size of sector is 512 bytes ad file system is vfat and ext4

if you wan check is real vfat you cen read fist 16 bit of fat partiotion

 hexdump -s $((8192*512)) -n16 -C 2017-01-11-raspbian-jessie-lite.img


So we can mount partitions now mount with option offset start mount partition from 1st bytes nr bytes is equal number sector sector multiply by sector size .

mount -o offset=$((8192*512)) -t vfat 2017-01-11-raspbian-jessie-lite.img test
mount -o offset=$((137216*512)) 2017-01-11-raspbian-jessie-lite.img test2

# 137216×512=70254592

mount -o offset=4194304 -t vfat 2017-01-11-raspbian-jessie-lite.img test
mount -o offset=70254592 2017-01-11-raspbian-jessie-lite.img test2


ps .


kpartx -v -a 2017-01-11-raspbian-jessie-lite.img


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s