Difference between revisions of "How to mount img file"

From HyperSecurity Wiki
Jump to: navigation, search
 
Line 2: Line 2:
  
 
Open Terminal, locate the disk image, and enter this command:
 
Open Terminal, locate the disk image, and enter this command:
  kpartx -av disk_image.raw  
+
  kpartx -av disk_image.raw
 +
 
 
add map loop0p1 (252:2): 0 3082240 linear /dev/loop0 2048
 
add map loop0p1 (252:2): 0 3082240 linear /dev/loop0 2048
  
Line 10: Line 11:
  
 
  mount /dev/mapper/loop0p2 /mnt
 
  mount /dev/mapper/loop0p2 /mnt
 
Alternatively, the block device is detected by Nautilus and you can mount it from the side bar:
 
  
 
When you are done, unmount what you mounted and remove the device mapping:
 
When you are done, unmount what you mounted and remove the device mapping:

Revision as of 19:19, 11 April 2018

An easy solution is using kpartx: it will figure out the partition layout and map each to a block devices. After that all you have to do is mount the one you want.

Open Terminal, locate the disk image, and enter this command:

kpartx -av disk_image.raw

add map loop0p1 (252:2): 0 3082240 linear /dev/loop0 2048

add map loop0p2 (252:3): 0 17887232 linear /dev/loop0 3084288

This created loop0p1 and loop0p2 under /dev/mapper. From the output you can see the sizes of the partitions which helps you identify them. You can mount the one you want with:

mount /dev/mapper/loop0p2 /mnt

When you are done, unmount what you mounted and remove the device mapping:

sudo umount /mnt
sudo kpartx -d disk_image.raw