Mount partition from RAW entire disk image - alexisfrjp/wiki GitHub Wiki

Mount a partition which is inside a RAW/entire disk image created with dd

Parted doc

What we need:

  • ntfsresize ntfs-3g fdisk gdisk kpartx

1. Get the partition

  • fdisk -l entireimage.iso
  • dd if=entireimage.iso bs=512/4096 skip=OFFSET_nb_of_bs count=number_of_sectors | pv | dd of=partitionFile.iso or
  • fdisk -lu entire.iso
  • losetup -f --show -o $[offsetsectors*512] --sizelimit $[512*sizesectors] entireimage.iso

2. Shrink it

With the entire system file

  • gparted /dev/loopX or parted /dev/loopX and resize it

  • ntfsresize --force -s XX_in_Bytes /dev/loopX

OR

  • losetup -f --show entire_disk.iso Make the device image as if it is a real device.
  • kpartx -a /dev/loopX Read the partition table in order to make accessible every partitions.
  • ls -lh /dev/mapper See where every partitions are accessible.
  • ntfsresize --info llopXpX Read information of the NTFS partition.

References

http://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device

http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/

https://www.gnu.org/software/parted/manual/html_chapter/parted_2.html

http://www.root9.net/2012/07/creating-loopback-file-system-image.html

http://www.computerhope.com/unix/losetup.htm

http://pingunux.blogspot.jp/2012/07/creer-formater-et-monter-une-image.html?view=flipcard

mmcblk0, number of partitions in MMC card problem: http://unix.stackexchange.com/questions/217640/dev-mmcblk0-partitions-limit