diff options
author | Evgeny Sorokin <me@ch1p.io> | 2024-01-06 03:41:49 +0000 |
---|---|---|
committer | Evgeny Sorokin <me@ch1p.io> | 2024-01-06 03:41:49 +0000 |
commit | 6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 (patch) | |
tree | d9f9200cf572385cf25f41442231675d5eeabcb8 /.local/bin/mount-luks-partition-dump.sh |
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 |