| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #!/bin/sh
- #
- # crucial mx500 2TB
- # disk s/n: CT2000MX500SSD1
- #
- LV_NAME1=xxx
- LUKS_MNT1=luks-${LV_NAME1}
- #
- #
- #
- UNLOCK_MNT1=/media/yazoo/${LUKS_MNT1}
- #
- # Check if mount point exists, create if not
- if [ ! -d "$UNLOCK_MNT1" ]; then
- echo "Mount point $UNLOCK_MNT1 does not exist. Creating it..."
- sudo mkdir -p "$UNLOCK_MNT1"
- if [ $? -eq 0 ]; then
- echo "Mount point $UNLOCK_MNT1 created successfully."
- else
- echo "Failed to create mount point $UNLOCK_MNT1. Exiting."
- exit 1
- fi
- fi
- # Unmount and close LUKS device if already mounted/opened
- sudo umount "$UNLOCK_MNT1" 2>/dev/null
- sudo cryptsetup luksClose "$LUKS_MNT1" 2>/dev/null
- # Open LUKS device
- echo "Unlocking QNAP disk TOSHIBA 4x2T ..."
- sudo cryptsetup luksOpen UUID=$LV_NAME1 "$LUKS_MNT1"
- if [ $? -eq 0 ]; then
- echo "LUKS device unlocked successfully."
- else
- echo "Failed to unlock LUKS device. Exiting."
- exit 1
- fi
- # Mount the unlocked device
- echo "Mounting ..."
- sudo mount /dev/mapper/"$LUKS_MNT1" "$UNLOCK_MNT1"
- if [ $? -eq 0 ]; then
- echo "Device mounted successfully at $UNLOCK_MNT1."
- else
- echo "Failed to mount device. Closing LUKS device."
- sudo cryptsetup luksClose "$LUKS_MNT1"
- exit 1
- fi
- # Optional: Remount with specific options (if needed)
- # sudo mount -o rw,remount /dev/mapper/"$LUKS_MNT1" "$UNLOCK_MNT1"
|