david/scripts-archive
david
/
scripts-archive
Archived
1
0
Fork 0
This repository has been archived on 2022-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-archive/lomount.sh

28 lines
623 B
Bash
Executable File

#!/bin/sh
# Mount partitions within a disk image file
# Author: P@adraigBrady.com
# V1.0 29 Jun 2005 Initial release
# V1.1 01 Dec 2005 Handle bootable (DOS) parititons
if [ "$#" -ne "3" ]; then
echo "Usage: `basename $0` <image_filename> <partition # (1,2,...)> <mount point>" >&2
exit 1
fi
if ! fdisk -v > /dev/null 2>&1; then
echo "Can't find the fdisk util. Are you root?" >&2
exit 1
fi
FILE=$1
PART=$2
DEST=$3
UNITS=$(fdisk -lu $FILE 2>/dev/null | grep "$FILE$PART " |
tr -d '*' | awk '{print $2}')
OFFSET=`expr 512 '*' $UNITS`
mount -o loop,offset=$OFFSET $FILE $DEST