aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/mount-media37
1 files changed, 28 insertions, 9 deletions
diff --git a/share/hydractl/mount-media b/share/hydractl/mount-media
index d6adf70..6916439 100755
--- a/share/hydractl/mount-media
+++ b/share/hydractl/mount-media
@@ -7,6 +7,7 @@
MEDIA="$1"
VOLUME="$2"
BASENAME="`basename $0`"
+MAPPING="$MEDIA"
MOUNTPOINT="/media/$MEDIA"
# Check media config
@@ -21,8 +22,16 @@ if [ -z "$VOLUME" ]; then
VOLUME="sdb1"
fi
-# Disk config
+# Disk and device config
DISK="`echo ${VOLUME} | sed -e s/[0-9]\$//g`"
+DEVICE="/dev/$DISK"
+
+# Check if LVM
+if $sudo lvdisplay /dev/$MEDIA/root &> /dev/null; then
+ LVM="yes"
+ DEVICE="/dev/$MEDIA/root"
+ MAPPING="$MAPPING-root"
+fi
# Set sudo config
if [ "`whoami`" != 'root' ]; then
@@ -30,22 +39,32 @@ if [ "`whoami`" != 'root' ]; then
fi
if [ "$BASENAME" == "mount-media" ]; then
- echo "Checking drive health status..."
- $sudo smartctl -H /dev/$DISK
+ if [ -e "$DEVICE" ]; then
+ echo "Checking drive health status..."
+ $sudo smartctl -H /dev/$DISK
- echo "Disabling STANDBY on drive..."
- $sudo sdparm --clear STANDBY -6 /dev/$DISK
+ echo "Disabling STANDBY on drive..."
+ $sudo sdparm --clear STANDBY -6 /dev/$DISK
+ fi
+
+ if [ "$LVM" == "yes" ]; then
+ $sudo vgchange -a y $VOLUME
+ fi
echo "Initializing crypto layer..."
- $sudo cryptsetup luksOpen /dev/$VOLUME $MEDIA && \
+ $sudo cryptsetup luksOpen $DEVICE $MAPPING && \
echo "Checking filesystem..."
- $sudo fsck -v -y /dev/mapper/$MEDIA && \
+ $sudo fsck -v -y /dev/mapper/$MAPPING && \
echo "Mounting volume at $MOUNTPOINT..."
$sudo mkdir -p $MOUNTPOINT
- $sudo mount /dev/mapper/$MEDIA $MOUNTPOINT
+ $sudo mount /dev/mapper/$MAPPING $MOUNTPOINT
elif [ "$BASENAME" == "umount-media" ]; then
$sudo umount $MOUNTPOINT && \
- $sudo cryptsetup luksClose $MEDIA
+ $sudo cryptsetup luksClose $MAPPING
+
+ if [ "$LVM" == "yes" ]; then
+ $sudo vgchange -a n $VOLUME
+ fi
fi