WizardKit/scripts/mount-raw-image
2Shirt b368b27faa
New project organization
* Script work is brought into better focus
* New layout will be used to better package the python scripts
* No hidden folders (they will be hidden at build time)
* All building should be done under setup/
  * Avoids ambiguous .bin/.cbin folders at root of project
2019-06-28 18:06:43 -06:00

32 lines
660 B
Bash
Executable file

#!/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 ro "${LOOPDEV}" || true
fi
else
usage
exit 1
fi