Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Created December 9, 2011 05:58
Show Gist options
  • Save acdimalev/1450400 to your computer and use it in GitHub Desktop.
Save acdimalev/1450400 to your computer and use it in GitHub Desktop.
a quick and dirty script for mounting partitions of a disk image
#!/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
@acdimalev
Copy link
Author

Loopback devices are, in general, probably a much better solution to this problem.

https://gist.github.com/acdimalev/5413305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment