Tutorial: How to mount raw images (.img) images on Linux

If you have a few .img files coming as disk images from devices like floppies, CDs, DVDs, SD cards, etc, you will realize that  you cannot mount the in Linux, because they contain a file system that has to be mounted.

In linux you would need to use the mount command as for any physical device, however you need to know the correct syntax that is based on understanding the information related to the partition(s) available in the image.

First step is to read the partition Start point using fdisk:

In the terminal type:

sudo fdisk -l imgfile.img

You will see an output similar to the one below:
Device        boot    Start     End         Blocks      Id  System
imgfile.img1      *             63           266544          722233           C     W95 FAT32 (LBA)
imgfile.img2                   25679      25367890        245667890+      83    Linux

As you can see there are two partitions, one that is FAT32 and the other one that it’s ExtFS. This means that to mount the first partition we have to tell Linux that we need to start at the sector 63. The standard sector size is 512 bytes, however there are other possibilities like 128 or 1024. Assuming that the place from where you are downloading the image doesn’t specify any sector size, we can type in the terminal:

sudo mount -t vfat -o loop,offset=$((63 * 512)) imgfile.img /mnt/disk

To mount the second partition, as you can imagine:

mount -t ext4 -o loop,offset=$((25679 * 512)) imgfile.img /mnt/disk1

It’s important to copy the “Start” sector number correctly, otherwise you’ll get an error message like:

mount : wrong fs type, bad option, band superblock on /dev/loop,
missing codepage or helper proggram, or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

One last thing, the standard sector size for CDs and DVDs is 2352 instead of 512. If you are opening such image, you’ll have to use this value instead of 512.

Incoming search terms:

  • https://stefanoprenna com/blog/2014/09/22/tutorial-how-to-mount-raw-images-img-images-on-linux/
  • linux mount raw img
  • ubuntu mount img file
  • как размонтировать img
  • примонтировать img в linux

Only 1 comment left Go To Comment

  1. spelling bee /

    Having read this I believed it was extremely informative.
    I appreciate you taking the time and energy to put this content together.
    I once again find myself personally spending a lot of time both reading and leaving comments.
    But so what, it was still worthwhile!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.