Google uses cookies to serve non-personalized adds on this page. You can read more here.

From my PATH:

posted on 2013-03-05

I've used this script on and off for the last few years. The script is called

The script will automatically mount all the partitions inside a device image onto a generated path in /tmp.

You need to run the script as root to allow for the mounting of the loop devices when they have been created.

if [ "x$1" == "x" ]; then
  echo "Usage: rawmount device_dump.raw"
  exit 1

kpartx -a "$image" || exit
#OLD losetup -f "$image" || exit
echo "Image      : $image"
echo "Mount base : $mountPoint"
#loDev=`losetup --associated "$image"| cut -d ":" -f 1|tail -n1`
#echo "Lo device  : $loDev"
#parts=`fdisk -l "$loDev" |awk -- '/^\/dev.*\*/{print $1}'`

parts=`kpartx -l "$image"|cut -d : -f 1|tr -d '\n'`
echo "Partitions : $parts"
for device in $parts; do
   echo "Mounting: ${device}"
   mkdir -p "${mp}"
   mount "/dev/mapper/$device" "${mountPoint}${i}" || rmdir "${mp}"
   let i=i+1
#Hide our failures
rmdir "${mountPoint}" 2>/dev/null >/dev/null

You can download the script here