source: https://superuser.com/a/1409363
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
If that doesn't work, can try:
sudo kpartx -a image_name.IMG