From 49c7880e6abdf3b81074ebe9b7735da19206258c Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Wed, 28 Feb 2018 12:39:27 -0700 Subject: [PATCH] Added mount-raw-image script * Allows for easier mounting of dd images and the partitions within * Fixes issue #18 --- .bin/Scripts/mount-raw-image | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 .bin/Scripts/mount-raw-image diff --git a/.bin/Scripts/mount-raw-image b/.bin/Scripts/mount-raw-image new file mode 100755 index 00000000..e738c445 --- /dev/null +++ b/.bin/Scripts/mount-raw-image @@ -0,0 +1,32 @@ +#!/bin/bash +# +## Wizard Kit: RAW image mounting tool + +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail + +LOOPDEV="$(losetup -f)" + +function usage { + echo "Usage: $(basename "$0") [image]" + echo " e.g. $(basename "$0") HDD.dd" +} + +if [[ -f "${1:-}" ]]; then + sudo losetup -P "${LOOPDEV}" "${1:-}" + sleep 1 + if [[ -b "${LOOPDEV}p1" ]]; then + # losetup detected partitions + for dev in "${LOOPDEV}p"*; do + udevil mount -o ro "${dev}" || true + done + else + # losetup did not detect partitions, attempt whole image + udevil mount -o to "${LOOPDEV}" || true + fi +else + usage + exit 1 +fi