Created
December 9, 2011 05:58
-
-
Save acdimalev/1450400 to your computer and use it in GitHub Desktop.
a quick and dirty script for mounting partitions of a disk image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# part-mount | |
# | |
# a quick and dirty script for mounting | |
# partitions of a disk image | |
# | |
if test $# -ne 3; then | |
echo Usage: $0 DISK-IMAGE PARTITION DIR; exit | |
fi | |
image=$1 | |
part=$2 | |
target=$3 | |
if ! test -f $image; then | |
echo $0: $image: no such disk image; exit | |
fi | |
offset=$(parted $image unit B print | awk "{if (\$1 == $part) print \$2}") | |
if test "x$offset" = "x"; then | |
echo $0: $part: no such partition; exit | |
fi | |
mount -o loop,offset=$offset $image $target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Loopback devices are, in general, probably a much better solution to this problem.
https://gist.github.com/acdimalev/5413305