#!/bin/bash # Some time ago, I wrote a little script to automate that process, maybe # it will help you also. (And yes, I know that the code isn't that pretty) # Direct copy & paste: INFILE="$1" PARTITION="$2" MOUNTPOINT="$3" OPT="$4" if [ "$INFILE" = "" ] ; then echo "Usage: $0 infile partition mountpoint " ; exit ; fi if [ "$PARTITION" = "" ] ; then echo "Usage: $0 infile partition mountpoint " ; exit ; fi if [ "$MOUNTPOINT" = "" ] ; then echo "Usage: $0 infile partition mountpoint " ; exit ; fi if [ "$OPT" != "" ] ; then OPT2=",${OPT}" ; fi PSTARTB=`sfdisk -d "$INFILE" | grep "start=" | head -n"$PARTITION" | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` PSTART=$[ $PSTARTB * 512 ] #PSIZEB=`sfdisk -d "$INFILE" | grep "size=" | head -n4 | tail -n1 | sed 's/.*size=[ ]*//' | sed 's/,.*//'` #PSIZE=`echo "$PSIZEB * 512" | bc` mount "$INFILE" "$MOUNTPOINT" -o loop,offset="$PSTART""$OPT2" #,sizelimit="$PSIZE""$OPT2"