diff options
Diffstat (limited to '.local/bin/mount-luks-partition-dump.sh')
-rwxr-xr-x | .local/bin/mount-luks-partition-dump.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.local/bin/mount-luks-partition-dump.sh b/.local/bin/mount-luks-partition-dump.sh new file mode 100755 index 0000000..2382d15 --- /dev/null +++ b/.local/bin/mount-luks-partition-dump.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +error() { + echo "error: $@" + exit 1 +} + +set -e + +DUMP="$1" +MOUNTPOINT=/media/luks-dump + +[ -d "$MOUNTPOINT" ] && error "$MOUNTPOINT already exists, you must delete it first" +[ $EUID -ne 0 ] && error "must be run as root" +[ -f "$DUMP" ] || error "'$DUMP' is not a file or is not readable" + +DEVICE=$(losetup -f) +losetup $DEVICE "$DUMP" + +cryptsetup luksOpen $DEVICE luks-dump +mkdir $MOUNTPOINT +mount /dev/mapper/luks-dump $MOUNTPOINT + +echo "press enter when done..." +read + +umount $MOUNTPOINT +rmdir $MOUNTPOINT +cryptsetup luksClose luks-dump +losetup -d $DEVICE |