[Tutorial] Amazon Cloud (ACD) + Plex Media Server (PMS) + Ubuntu 16.04 Server (VPS)

Why are you writing this tutorial?

This is not a discussion regarding the technicalities and politics of Plex Development.

For those of us who’ve uploaded our media libraries to ACD, it’s come as a bit of a surprise that Plex may not end up supporting ACD as a storage provider for their upcoming Plex Cloud.

My library is mostly uploaded to ACD, and was ready for use with Plex. Unfortunately, I cant afford Google Drive, nor can I afford Microsoft OneDrive in the capacities I’d require.

The other thing I’m not looking forward to, is having to re-upload my data again. I know there are methods to move the data directly, but the information about them is sketchy or require a middle man. Some even require a subscription.

Needless to say, this doesn’t sit well with me.

At the very least, this is a stop gap, or temporary solution to be able to access and play my media.

There are a lot of ‘almost’ tutorials out there, that provide most of the information to connect everything together, the problem is they aren’t really complete, with missing steps and generalities.

Tutorial Goals

  • Automatically run PMS
  • Automatically mount your ACD as a usable FUSE drive
  • Be able to access the PMS Web Interface and view media remotely

Prerequisites

  1. An ACD account, where you have your media
  2. A VPS (Virtual Private Server) or Bare Metal Server that has at least 4x Cores for transcoding (enough for 720p)
  3. Ubuntu 16.04 Server installed and running
  4. Access to your VPS via SSH
  5. Enough bandwidth on your VPS for large amounts of media
  6. Around 150Gb of free disk space to allow for Transcoding and Library data (depending on library/media size)

Assumptions

  • That your media is housed on ACD within the standard Plex Folder Structure
  • That you have a basic understanding of Linux/Ubuntu, and how to secure your own server
  • That you’re using PuTTY as your SSH client, and are familiar with how it (the application) works

Known Issues

  • Writing to the ACD FUSE drive is very unstable - This is an upstream issue
  • Reading directly from ACD relies heavily on your incoming bandwidth to the VPS
  • PMS will not automatically detect changes to ACD/Libraries, manual or scheduled updates will be required
  • Viewing media will require a good local internet connection, and stable connection to your VPS
  • Large video media will take up to two minutes to buffer on the VPS for transcoding
  • Your Android; Windows; iOS; MacOS and 3rd party apps may not like the long buffering times
  • Files you upload to ACD do not automatically appear in the mounted drive - See the added --interval 420 switch in the tutorial

Tutorial

Step 1 - Setup:

Open PuTTY and add a portforward for 127.0.0.1:32400

  1. Connection > SSH > Tunnels
  2. Source Port 32400
  3. Destination Port 127.0.0.1:32400
  4. Add

nb. Save your connection, otherwise these will be wiped next time you open PuTTY

Step 2 - Upgrades & Prerequisites:

Connect to your VPS and update it, and install prerequisites.

  1. Connect to your VPS via SSH
  2. Run sudo apt-get update
  3. Run sudo apt-get -y upgrade
  4. Run sudo apt-get -y install git-core python-pip curl fuse
  5. Run sudo pip3 install --upgrade pip

Step 3 - Installing Plex:

Install PMS on your VPS

Note: Get the URL from here. Choose 32bit or 64bit for your distro (if in doubt, run uname -a)

  1. Run cd ~/
  2. Run wget <URL from the note above>
  3. Run sudo dpkg -i plexmediaserver*.deb

Step 4 - Configuring Plex Media Server:

Configure PMS

  1. Keep PuTTY and your SSH connection open, as it will provide your tunnel to the PMS
  2. Open a Browser on your local machine and go to http://127.0.0.1:32400
  3. Login with your Plex username and Password as normal
  4. Go to Settings
  5. Go to Server
  6. Click on Claim Server
  7. Plex should error, and ask you to provide your account details
  8. Enter your account name and password, and it should claim the server successfully
  9. Go to Remote Settings
  10. Click on Manually specify public port, and enter 32400 in the box
  11. Click Apply
  12. Click Enable Remote Access
  13. Click Network
  14. Click on the Secure connections drop down box, and select Required
  15. Click Save Changes
  16. This window is no longer needed, and can be closed
  17. In PuTTY, type sudo service plexmediaserver restart
  18. Open your browser and go to https://<your VPS IP Address>:32400 (note the https)

You should now be able to configure and control the PMS normally.

Step 5 - Installing acd_cli:

Install acd_cli

Note: I’ll explain this in more detail later if needed

  1. Run pip3 install --upgrade git+https://github.com/yadayada/acd_cli.git
  2. Run acd_cli sync - It should ask to open a browser etc…
  3. Press CTRL+X to exit back to the prompt
  4. Open your local browser and go to tensile-runway-92512.appspot.com
  5. Login with your Amazon Account, and download the oauth_data file
  6. Upload the oauth_data file to your server in the ~/.cache/acd_cli/ directory
  7. Run acd_cli sync again, this time it should throw up errors about the root directory (you can safely ignore this)

Step 6 - Testing your ACD mount:

Test mount ACD

  1. Run sudo mkdir /mnt/acd
  2. Run sudo acd_cli mount -ao /mnt/acd --interval 420
  3. Run cd /mnt/acd
  4. Run ls -l and make sure all of your Media is there

nb. If your data is NOT listed, then please post the details, and I’ll look into it

Step 7 - Setting up fstab to handle automount:

Unmount and configure fstab to mount ACD on boot

  1. Run cd ~/

  2. Run umount /mnt/acd

  3. Run nano /usr/bin/acdmount and add the following two lines:

    #!/bin/bash
    acd_cli mount -ao $1 --interval 420

  4. Press CTRL+X, then press Y to save and close

  5. Run chmod 777 /usr/bin/acdmount

  6. Run nano /etc/fstab and add the following line:

    acdmount /mnt/acd fuse _netdev 0 0

  7. Press CTRL+X, then press Y to save and close

  8. Run mount -a

  9. Run cd /mnt/acd

  10. Run ls -l and make sure all of your Media is there

  11. Reboot your VPS

  12. After rebooting, run cd /mnt/acd

  13. Run ls -l and make sure all of your Media is there

Final Notes:

When adding your Media to your Plex Installation, you should be able to browse to /mnt/acd and find your media there.

You may need to tweak your transcoding and bandwidth settings to suit your setup.

Good luck!

Sources

And others I cant remember…

Nice write up - this is similar to how I have one of my remote servers set up.
One comment i will make is that I had an issue with using the --interval flag for the sync updates.

I found this to be unreliable and if the server was reading whilst trying to do the sync update it would corrupt the mount point, this seems to be a known issue. (note I never write using the mount)

In the end I just created a simple 3 line script to unmonunt / run the sync / and remount and crontab this to run at 3am!
It ionly takes a few seconds!

I also just mount the acd_cli mount as a cron on boot unter the “plex” user - no requirement for messing about with rights to the mount then!

@garypower said:
In the end I just created a simple 3 line script to unmonunt / run the sync / and remount and crontab this to run at 3am!
It ionly takes a few seconds!

Nice! If you feel like sharing, post it, by all means! The --interval can be a pain, I agree. I’ve lost count of how many times I’ve had to delete the db file and resync. Maybe we should mount it as ro?

My main differences is :

1 - I mount the acd_cli mount as the “plex” user from crontab on boot.
This is my crontab line - wait 15 seconds to make sure all is started up then mount a subdirectory in my acd named “Media” to /var/lib/plexmediaserver/Media

@reboot sleep 15; /usr/local/bin/acd_cli -nl mount --modules=“subdir,subdir=/Media” /var/lib/plexmediaserver/Media

2 - at 3am I crontab a remount : (server is 1 hour ahead from my timezone so the 4 is 3am ) :slight_smile:

0 4 * * * /var/lib/plexmediaserver/acdremount.sh

script simply contains :

#!/bin/bash
fusermount -uz /home/gary/Media
/usr/local/bin/acd_cli sync
/usr/local/bin/acd_cli -nl mount --modules=“subdir,subdir=/Media” /home/gary/Media
exit

3 - at 5 past 3 I kick off via cron a scan of a couple of library sections (TV & Movies) I found this faster with a call via https rather then via the command line can tool.

Crontab line :

5 4 * * * /var/lib/plexmediaserver/plexscan.sh > /var/lib/plexmediaserver/plexscan.log 2>&1

Contents of this script :

curl “http://127.0.0.1:32400/library/sections/10/refresh?force=0&X-Plex-Token=PutYourPlexTokenHere
curl “http://127.0.0.1:32400/library/sections/1/refresh?force=0&X-Plex-Token=PutYourPlexTokenHere

N.B to find your library section numbers run :

export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
/usr/lib/plexmediaserver/Plex\ Media\ Scanner --list

Since I have done this I have no issues with database corruptions etc. They all seem to be to do with accessing whilst a scan runs.

Gary

@garypower - That’s great mate. Thanks for that. Having alternatives for others is great. :slight_smile:

I truly appreciate you taking the time to post it for us!

Nice right up. Thank you for your time

you can also create a .service file with user access to do that as well
I use rclone+crypt instead to do the same thing.

I have also done some testing with acd_cli vs rclone mount - and also comparing Amazon and google drive - figures copied from another thread I posted them in.

All tests were to copy a 2GB file from the fuse mount to local drive.

tests with acd_cli and rclone mount (now it supports seek)

ACD_CLI mount to Amazon - time to copy 5 minutes 1 second
Rclone mount to ACD - time to copy 3 minutes 10 seconds
Rclone mount to google drive - time to copy 55 seconds
Rclone mount to rclone encrypted google drive - time to copy 55 seconds


The issue I have with rclone mounts at the moment are that it causes as massive amount of API hits and traffic transfer when doing things like scanning.

I have a large “ish” library and it is great when playing - but the scanning is hitting the cloud drives too hard.
There appears to be movements in the rclone camp to hopefully do some offline caching of directory structure / files in a simiar way to how acd_cli works.

Once this is in place I will try again as the speed increase from rclone is large!

Gary

The cache is the last part needed. I hosted the system cache worked well but I’m on centos

@buba013 said:
you can also create a .service file with user access to do that as well
I use rclone+crypt instead to do the same thing.

So you’re using systemd?

@buba013 said:
The cache is the last part needed. I hosted the system cache worked well but I’m on centos

Ooo! Cache! I like cache. Do you mean like Redis or memcached?

@garypower said:
Once this is in place I will try again as the speed increase from rclone is large!

I didn’t know about rclone mount! Holy crap! Oh, I see. It’s in the experimental stages. Looks good though. It could potentially eliminate the need for acd_cli altogether, which is one less step in the process! YAY!

Ill post my config for this one day just need to clean up my script .

yes i was using mem I allocated 50 GB ram to it and DD to disk if needed

yes systemd i run it all from the " plex home drive" as plex I do not set allow others so only plex has access to the mount .

eg


[Unit]
Description=Mount

[Service]
ExecStart=/var/lib/plexmediaserver/rclone/rclone mount --max-read-ahead 400M secret: /Plex/Media
Type=oneshot
User=plex
Group=plex
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


Note:max read ahead was a test .

I have a SP cloud box over at OVH , it has 60 GB ram and 200 SSD

Rclone mount yes that like 50 releases ago .

He has fine turned the mount so it dost use so much CPU . he did remove the high mem use but that is coming back as cache .

The dev guy has done great work with rclone ,seeking , and plex , last build i tested with him , I was playing 2 4k movies no issues rewind fast Forward.

were I left Rclone was just about just right for my plex use with crypt. as soon as the mem cache is done it will be as fast as ACD_CLI if not faster with multi streams .

The Coder was getting ready to fine tune the setup , he believe he can get it to preform faster when completely tuned .

The really nice thing about rclone is you only need one .conf file just keep it safe and copy it to the desired sever that wants to use it .

its a portable app works on
Mac
Linux
BSD
Windows

I agree the rclone mount, with the current development, is looking promising.
I currently mount encrypted media with acd-cli and use a unionFS to see local and ACD material as the same folder. And I transfer media to ACD with rclone

@ntrevena said:

@garypower said:
Once this is in place I will try again as the speed increase from rclone is large!

I didn’t know about rclone mount! Holy crap! Oh, I see. It’s in the experimental stages. Looks good though. It could potentially eliminate the need for acd_cli altogether, which is one less step in the process! YAY!

Yes why i like it .
Its just setup the config file setup the crypt configuration .
that’s it Sync/copy from source to ACD then mount ACD to VPS .

@hthighway said:
I agree the rclone mount, with the current development, is looking promising.
I currently mount encrypted media with acd-cli and use a unionFS to see local and ACD material as the same folder. And I transfer media to ACD with rclone

Yes, the Dev is a Plex user too :slight_smile:

@hthighway said:
I agree the rclone mount, with the current development, is looking promising.

Right? I’d be all for scrapping acd_cli if rclone mount was ready for production.

@hthighway said:
I currently mount encrypted media with acd-cli and use a unionFS to see local and ACD material as the same folder. And I transfer media to ACD with rclone

Yeah, that seems to be how most people with a little knowledge have done it. I was thinking about appending the encfs step, but realized that the target audience is those who’ve already uploaded their media in the standard Plex format ready for Plex Cloud.

@buba013 said:
The dev guy has done great work with rclone ,seeking , and plex , last build i tested with him , I was playing 2 4k movies no issues rewind fast Forward.

I will be testing that later today XD

@ntrevena said:
Yeah, that seems to be how most people with a little knowledge have done it. I was thinking about appending the encfs step, but realized that the target audience is those who’ve already uploaded their media in the standard Plex format ready for Plex Cloud.

That’s how I initially had my media on ACD, unencrypted, but now I have re-processed it all to have encryption

hello, i have done some steps in building my Private Plex Server in the cloud.
The target is having Gdrive as the backend.
I have already uploaded several TB of my library to gdrive, currently non encrypted.
Now my questions:

  1. Can i encrypt those TB now?
  2. when i have my server ready and Plex installed, i want to mount gdrive, using rclone, what happen with the content that is encrypted then? how plex interpret these contents?
  3. how can i manage future upload and visibility if everything is encrypted?

I’m a bit newbie with encryption. all the suggestions are more than welcome…

Sorry to bring up an old thread, but it was fairly recent so I thought I’d give it a try. I finally got around to setting up a VPS a couple weeks ago and have been using acd_cli and encfs for my media. My understanding is that I need to use the ACD web interface to delete files, but I can’t seem to find a quick / easy way to identify which files/folders I actually want to delete. Any pointers other than trial and error md5 comparisons?

afaik, You only need to use the ACD web interface to actually empty the trash on your amazon drive.

It seems you are correct. Thanks very much for the tip.