summaryrefslogtreecommitdiff
path: root/share/hydractl/mount-media
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-10-14 02:27:27 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-10-14 02:27:27 -0300
commit5077ee7d9a9f80ac400ce509124352300e7f8e43 (patch)
tree9b3cb27c6884e73645aa9b1225146df34f86f90a /share/hydractl/mount-media
parentfb748d619cb32a75fed2040a31258074f87f4934 (diff)
downloadhydra-5077ee7d9a9f80ac400ce509124352300e7f8e43.tar.gz
hydra-5077ee7d9a9f80ac400ce509124352300e7f8e43.tar.bz2
Adds LVM support into mount-media
Diffstat (limited to 'share/hydractl/mount-media')
-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