I have a disk image file I'm trying to mount locally using a loop device. Using parted I can see the image has two partitions, however, I'm not able to mount the first partition and losetup thinks the second partition doesn't exist. Anyone know how I can mount the second partition?

/m/sf_VMShare ❯❯❯ sudo losetup /dev/loop0 ./imm_image-2017-05-28.img
/m/sf_VMShare ❯❯❯ sudo losetup -a
/dev/loop0: [0023]:99 (/media/sf_VMShare/imm_image-2017-05-28.img)
/m/sf_VMShare ❯❯❯ sudo parted /dev/loop0 print
Model: Loopback device (loop)
Disk /dev/loop0: 1206MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size   Type     File system  Flags
 1      10.5MB  360MB   349MB  primary  ext4
 2      361MB   1205MB  844MB  primary  ext4

/m/sf_VMShare ❯❯❯ sudo mount -t ext4 /dev/loop0p2 /tmp/vdisk
mount: special device /dev/loop0p2 does not exist
/m/sf_VMShare ❯❯❯ sudo mount -t ext4 /dev/loop0p1 /tmp/vdisk 
mount: wrong fs type, bad option, bad superblock on /dev/loop0p1,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

/m/sf_VMShare ❯❯❯ mount | grep /tmp/vdisk
/m/sf_VMShare ❯❯❯
/m/sf_VMShare ❯❯❯ ls /dev/loop*
/dev/loop0    /dev/loop1  /dev/loop3  /dev/loop5  /dev/loop7
/dev/loop0p1  /dev/loop2  /dev/loop4  /dev/loop6  /dev/loop-control
/m/sf_VMShare ❯❯❯ lsblk -f
├─sda1                 /
└─sda5                 [SWAP]
└─sdb1                 /home/foo/workspace
  • 1
    What does ls /dev/loop* show? – John Jun 19 '17 at 17:34
  • 1
    What is the output of lsblk -f? – Mio Rin Jun 19 '17 at 18:28

How to mount a partition in a full disk image that contains a msdos partition table.


  • fdisk
  • mount
  • calculator

Get the partition layout of the image.

sudo fdisk -l -u=sectors /work/loop_test/disk_image.img

Example output:

Disk /work/loop_test/disk_image.img: 29 MB, 29629952 bytes
255 heads, 63 sectors/track, 3 cylinders, total 57871 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
Disk identifier: 0x0009d7e5

                     Device Boot      Start         End      Blocks   Id  System
/work/loop_test/disk_image.img1       2048       18431        8192   83  Linux
/work/loop_test/disk_image.img2       18432      57343       19456    7  HPFS/NTFS/exFAT

Calculate the offset from the start of the image to the partition start. In this case the ntfs partition.


Sector size * Start = Offset
512 * 18432 = 9437184

Mount the image, passing the offset for the desired partition.

In this example the ntfs partition.

sudo mount -o loop,offset=9437184 /work/loop_test/disk_image.img /mnt/ntfs_partition
  • 2
    Instead of calculating the offset by yourself, you could even use bash's arithemtic evaluation: sudo mount -o loop,offset=$((512*18432)) ... – Murmel Oct 16 '18 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.