Host: Ubuntu 15.04

With Disk Image Mounter, I can mount the test.img and three directories popped up.

  1. system-a
  2. system-b
  3. writable

As I've searched around, I can not edit the directories since those are read-only.

The possible solution I found so far is to copy these directories to another new place and generate a new image file.

However, since the image file contains these three directories, how can I do it?

=============post update=============

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

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


Device                Start     End Sectors  Size Type
test_custom2.img1    8192   16383    8192    4M BIOS boot
test_custom2.img2   16384  147455  131072   64M EFI System
test_custom2.img3  147456 2244607 2097152    1G Linux filesystem
test_custom2.img4 2244608 4341759 2097152    1G Linux filesystem
test_custom2.img5 4341760 7614463 3272704  1.6G Linux filesystem
  • What type of filesystem does the image hold? Dec 28, 2015 at 9:16
  • @andreas-hofmann ext4
    – Sam
    Dec 28, 2015 at 9:37
  • Are there any partitions in the image? What does the output of fdisk -l image.img say? Dec 28, 2015 at 10:16
  • @andreas-hofmann post updated.
    – Sam
    Dec 28, 2015 at 10:18

4 Answers 4


The problem is that there are multiple partitions in your image. A plain old mount looks for filesystem information at offset 0, which in your case apparently points to some bios boot information, but not to the desired ext4 fs. You should succeed by creating the loopback-device with an offset to the desired partition.

This link may help you out.


Here's the full process, based on the answer here:

Your .img file is not an image of a partition, but of a whole disk. That means it starts with a bootloader and a partition table. You have to detect the offset of the partition and mount it specifically. Sadly I've never been able to find a Linux tool that automates that. So you have to do math, but it's easy. Here's the process:

fdisk -l raspberry_pi.img

Which gives the output below. Note the sector size in bytes (512 in this case; see line 2 below) and the Start sector of the partition (94208 for the Linux partition; see the last line below).

Disk raspberry_pi.img: 7.3 GiB, 7826571264 bytes, 15286272 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: 0xbeb1a7ff

Device          Boot Start      End  Sectors  Size Id Type
raspberry_pi.img1       8192    93813    85622 41.8M  c W95 FAT32 (LBA)
raspberry_pi.img2      94208 15069183 14974976  7.1G 83 Linux

Now, manually multiply the start sector * sector size to get the offset bytes that the mount command needs. In this case, 94208 * 512 = 48234496

sudo mkdir /media/sdcard
sudo mount -o loop,rw,sync,offset=48234496 printer_v5.img /media/sdcard

Now, the image's Linux partition is mounted at /media/sdcard and the root user can edit its files.

Finally, when you're finished:

sudo umount /media/sdcard
  • worked great... thank you.
    – M.Hefny
    Sep 27, 2021 at 14:02

You need to make sure that your current user directory has read and write access to your operation

sudo mkdir -p /tmp/test && sudo mount -o loop,rw,sync image.img /tmp/test
  • thanks, but I got the error by typing your command
    – Sam
    Dec 28, 2015 at 8:19
  • I've updated the post, please let me know if you have any further idea.
    – Sam
    Dec 28, 2015 at 9:01
  • 1
    mount: /tmp/test: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error. Aug 28, 2021 at 5:56

binwalk might be the tool to try in order to get the job done in this case. Many, many options but in it's simplest form:

#install binwalk
git clone https://github.com/ReFirmLabs/binwalk.git
cd binwalk
sudo python setup.py install
#cd to image folder
cd <path to image file>
#show info
binwalk yourimage.img
#auto extract all
binwalk -e yourimage.img
  • Its archives cant be opened by GNOME Archive Manager; what do I do? Nov 3, 2020 at 16:41
  • This doesn't say how to mount the partitions Feb 7, 2023 at 16:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .