From 6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 Mon Sep 17 00:00:00 2001 From: Evgeny Sorokin Date: Sat, 6 Jan 2024 03:41:49 +0000 Subject: add something --- .local/bin/mount-luks-partition-dump.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 .local/bin/mount-luks-partition-dump.sh (limited to '.local/bin/mount-luks-partition-dump.sh') 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 -- cgit v1.2.3