Issue mounting drives

Hello everyone,

I’m currently running the latest version of Manjaro Budgie with the latest linux-zen kernel (though I don’t believe my issue is related to the kernel). I have an encrypted SSD for my OS and 5 HDDs which are all encrypted also. Yes, I know that I’m a crazy person. Lastly, I have a jump drive that remains plugged into the same USB port at all times. I have a startup script that I run to decrypt all of my drives and to mount the jump drive, which includes the following lines:

echo "Decrypting encrypted4"
sudo cryptsetup luksOpen /dev/sdd sdd
sudo mount /dev/mapper/sdd /mnt/encrypted4

echo " "
echo "Decrypting encrypted8-1"
sudo cryptsetup luksOpen /dev/sda sda
sudo mount /dev/mapper/sda /mnt/encrypted8-1

echo " "
echo "Decrypting encrypted8-2"
sudo cryptsetup luksOpen /dev/sdb sdb
sudo mount /dev/mapper/sdb /mnt/encrypted8-2
echo " "
echo "Decrypting encrypted4-mirror"
sudo cryptsetup luksOpen /dev/sde sde
sudo mount /dev/mapper/sde /mnt/encrypted4-mirror

echo " "
echo "Decrypting encrypted4-other"
sudo cryptsetup luksOpen /dev/sdg sdg
sudo mount /dev/mapper/sdg /mnt/encrypted4-other

sudo mount /dev/sdf /mnt/backup/

The problem I’m having is that occasionally my HDD at sdg and my jump drive at sdf switch, so it’ll try decrypting my hard drive and error out because suddenly the jump drive is sdg and the hard drive is sdf.

Is there any way to ensure that these drives remain at the same spot and I’m not constantly having to change my script? Thanks in advance!

yeah, use UUIDs instead of /dev/sdXY. those values are not guaranteed to be constant. probably easiest by setting up crypttab and fstab to handle the mounting.

the crypttab will set up all those /dev/mapper locations based on what names you give it, and then fstab can mount those /dev/mapper locations to existing folder mount points.

possibly you could also set up a udev rule of some sort to maintain the drive designations, but I think properly mounting these things is probably easier.

from the arch wiki: dm-crypt/System configuration - ArchWiki


Wow, thank you so much! That was very easy to set up, even for someone noob-ish like me. Much appreciated!

1 Like