This utility allows mounting .img files containing multiple partitions to the FS.
mount.img /path/to/file.img 2 /mnt/mount/point
with 2 being the partition index, as fdisk -l /path/to/file.img reports. First partition is 1.
| #!/bin/bash | |
| if [[ ! "$1" || ! "$2" || ! "$3" ]]; then | |
| echo "Usage: mount_file IMAGE PARTITION_NUMBER MOUNTPOINT" | |
| exit 1 | |
| fi | |
| line=(`fdisk -l "$1" | tr -d '*' | grep "$1$2"`) | |
| echo "${line[*]}" | |
| mount -o loop,offset=$((512 * ${line[1]})),sizelimit=$((512 * ${line[3]})) $1 $3 |