Background is that I have a headless server that I run a Plex Media Server within a Docker container. The server is running Ubuntu, but I also run a mirrored setup on another machine but use Fedora as the OS.
I have 5 external drives for media storage, and each drive is LUKS encrypted. Since the servers are headless, I don't have a monitor set up mount the drives after subsequently rebooting the systems.
Here are the steps for mounting LUKS encrypted external drives remotely.
After restarting the server, ssh in.
local_user:$ ssh <remote_user>@<remote_ip_address> -p <remote port>
Once logged in to the remote machine, list all of the partitions using lsblk
remote_user:$ lsblk
The result will look something like
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.7T 0 disk
└─sda1 8:1 0 2.7T 0 part
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part
sdc 8:32 0 3.7T 0 disk
└─sdc1 8:33 0 3.7T 0 part
sdd 8:48 0 3.7T 0 disk
└─sdd1 8:49 0 3.7T 0 part
sde 8:64 0 3.7T 0 disk
└─sde1 8:65 0 3.7T 0 part
Next, I need to unencrypt each partition on the drive, so issue the following commands:
remote_user:$ sudo cryptsetup luksOpen /dev/sda1 Drive1
remote_user:$ sudo cryptsetup luksOpen /dev/sdb1 Drive2
remote_user:$ sudo cryptsetup luksOpen /dev/sdc1 Drive3
remote_user:$ sudo cryptsetup luksOpen /dev/sdd1 Drive4
remote_user:$ sudo cryptsetup luksOpen /dev/sde1 Drive5
For my plex installation and mapping, I sort of need to know the contents of each drive so they are mapped to the correct mount points. Since these 5 drives are located in an external enclosure, I don't know the exact mapping, ie, if sda/sda1 is actually Drive1, or Drive3, or Drive5.
With the partitions unlocked, I need to create the mount directories. Since these drives normally mount under the /media/remote_user/ (Ubuntu) or /run/media/remote_user/ (Fedora) directories, I need to make the directories there, one for each drive to be mounted. This is due to the volume bindings in the Docker create file I have setup for each container.
remote_user:$ sudo mkdir /media/remote_user/Drive1
remote_user:$ sudo mkdir /media/remote_user/Drive2
remote_user:$ sudo mkdir /media/remote_user/Drive3
remote_user:$ sudo mkdir /media/remote_user/Drive4
remote_user:$ sudo mkdir /media/remote_user/Drive5
Checking directory owner and group shows that these are root:root since I had to use sudo to create the directories.
remote_user:$ ls -l /media/remote_user
total 20
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive1
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive2
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive3
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive4
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive5
Now run a chown and chgrp to change the owner and group to remote_user:remote:user.
remote_user:$ sudo chown remote_user /media/remote_user/Drive*
remote_user:$ sudo chgrp remote_user /media/remote_user/Drive*
And long list the directory to make sure the changes are correct.
remote_user:$ ls -l /media/remote_user
total 20
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive1
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive2
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive3
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive4
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive5
Now I can mount the drives. I do this one by one to check that the mapping is correct.
remote_user:$ sudo mount /dev/mapper/Drive1 /media/remote_user/Drive1
remote_user:$ ls -l /media/remote_user/Drive1
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media1
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media100
remote_user:$ sudo mount /dev/mapper/Drive2 /media/remote_user/Drive2
remote_user:$ ls -l /media/remote_user/Drive2
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media2
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media4
remote_user:$ sudo mount /dev/mapper/Drive3 /media/remote_user/Drive3
remote_user:$ ls -l /media/remote_user/Drive3
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media3
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media5
remote_user:$ sudo mount /dev/mapper/Drive4 /media/remote_user/Drive4
remote_user:$ ls -l /media/remote_user/Drive4
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media6
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media8
remote_user:$ sudo mount /dev/mapper/Drive5 /media/remote_user/Drive5
remote_user:$ ls -l /media/remote_user/Drive5
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media7
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media9
All 5 drives are unencrypted and mapped to the correct directories for plex to be able to see the media again. This is good because now I no longer have to drag out a monitor, mouse, and keyboard from the closet whenever I want to restart the system to upgrade a kernel or flush memory.
I have 5 external drives for media storage, and each drive is LUKS encrypted. Since the servers are headless, I don't have a monitor set up mount the drives after subsequently rebooting the systems.
Here are the steps for mounting LUKS encrypted external drives remotely.
After restarting the server, ssh in.
local_user:$ ssh <remote_user>@<remote_ip_address> -p <remote port>
Once logged in to the remote machine, list all of the partitions using lsblk
remote_user:$ lsblk
The result will look something like
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 2.7T 0 disk
└─sda1 8:1 0 2.7T 0 part
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part
sdc 8:32 0 3.7T 0 disk
└─sdc1 8:33 0 3.7T 0 part
sdd 8:48 0 3.7T 0 disk
└─sdd1 8:49 0 3.7T 0 part
sde 8:64 0 3.7T 0 disk
└─sde1 8:65 0 3.7T 0 part
Next, I need to unencrypt each partition on the drive, so issue the following commands:
remote_user:$ sudo cryptsetup luksOpen /dev/sda1 Drive1
remote_user:$ sudo cryptsetup luksOpen /dev/sdb1 Drive2
remote_user:$ sudo cryptsetup luksOpen /dev/sdc1 Drive3
remote_user:$ sudo cryptsetup luksOpen /dev/sdd1 Drive4
remote_user:$ sudo cryptsetup luksOpen /dev/sde1 Drive5
For my plex installation and mapping, I sort of need to know the contents of each drive so they are mapped to the correct mount points. Since these 5 drives are located in an external enclosure, I don't know the exact mapping, ie, if sda/sda1 is actually Drive1, or Drive3, or Drive5.
With the partitions unlocked, I need to create the mount directories. Since these drives normally mount under the /media/remote_user/ (Ubuntu) or /run/media/remote_user/ (Fedora) directories, I need to make the directories there, one for each drive to be mounted. This is due to the volume bindings in the Docker create file I have setup for each container.
remote_user:$ sudo mkdir /media/remote_user/Drive1
remote_user:$ sudo mkdir /media/remote_user/Drive2
remote_user:$ sudo mkdir /media/remote_user/Drive3
remote_user:$ sudo mkdir /media/remote_user/Drive4
remote_user:$ sudo mkdir /media/remote_user/Drive5
Checking directory owner and group shows that these are root:root since I had to use sudo to create the directories.
remote_user:$ ls -l /media/remote_user
total 20
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive1
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive2
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive3
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive4
drwxr-xr-x 2 2 root root 4096 Apr 11 21:42 Drive5
Now run a chown and chgrp to change the owner and group to remote_user:remote:user.
remote_user:$ sudo chown remote_user /media/remote_user/Drive*
remote_user:$ sudo chgrp remote_user /media/remote_user/Drive*
And long list the directory to make sure the changes are correct.
remote_user:$ ls -l /media/remote_user
total 20
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive1
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive2
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive3
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive4
drwxr-xr-x 2 2 remote_user remote_user 4096 Apr 11 21:42 Drive5
Now I can mount the drives. I do this one by one to check that the mapping is correct.
remote_user:$ sudo mount /dev/mapper/Drive1 /media/remote_user/Drive1
remote_user:$ ls -l /media/remote_user/Drive1
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media1
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media100
remote_user:$ sudo mount /dev/mapper/Drive2 /media/remote_user/Drive2
remote_user:$ ls -l /media/remote_user/Drive2
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media2
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media4
remote_user:$ sudo mount /dev/mapper/Drive3 /media/remote_user/Drive3
remote_user:$ ls -l /media/remote_user/Drive3
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media3
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media5
remote_user:$ sudo mount /dev/mapper/Drive4 /media/remote_user/Drive4
remote_user:$ ls -l /media/remote_user/Drive4
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media6
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media8
remote_user:$ sudo mount /dev/mapper/Drive5 /media/remote_user/Drive5
remote_user:$ ls -l /media/remote_user/Drive5
total 8
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media7
drwxrwxrwx. 3 remote_user remote_user 4096 May 19 2019 Media9
All 5 drives are unencrypted and mapped to the correct directories for plex to be able to see the media again. This is good because now I no longer have to drag out a monitor, mouse, and keyboard from the closet whenever I want to restart the system to upgrade a kernel or flush memory.
No comments:
Post a Comment