Skip to main content

Part 5 - Mounting the drive(s)

You made it up to here, you finished Part 4 - Setting up Rclone and/or Plexdrive and are still with it, congratulations! The hardest parts are done, it'll be downhill from now on. Promise!

We now need to mount our drive so that Plex can access it as if it is just one giant external drive.

Douglas Adams would have loved it!

Mounting the Google drive (Rclone)

You are probably still logged in with your plexuser account, which is exactly what we want.

Let's create the required folders first:

mkdir -p /home/plexuser/logs
mkdir -p /home/plexuser/uploads

Creating the mount script:

sudo nano /etc/systemd/system/rclone.service

Then paste (right click):

Description=Mount and cache Google drive to /media/Plex
ExecStartPre=/bin/mkdir -p ${MOUNTTO}
ExecStartPre=/bin/mkdir -p ${LOGS}
ExecStartPre=/bin/mkdir -p ${UPLOADS}
ExecStart=/usr/bin/rclone mount \
  --rc \
  --log-file ${LOGS}/rclone.log \
  --log-level INFO \
  --umask 022 \
  --allow-non-empty \
  --allow-other \
  --fuse-flag sync_read \
  --tpslimit 10 \
  --tpslimit-burst 10 \
  --dir-cache-time=160h \
  --buffer-size=64M \
  --attr-timeout=1s \
  --vfs-read-chunk-size=2M \
  --vfs-read-chunk-size-limit=2G \
  --vfs-cache-max-age=5m \
  --vfs-cache-mode=writes \
  --cache-dir ${UPLOADS} \
  --config ${RCLONEHOME}/rclone.conf \
  Gdrive: ${MOUNTTO}
ExecStop=/bin/fusermount -u -z ${MOUNTTO}
ExecStop=/bin/rmdir ${MOUNTTO}

Of course you will need to replace all instances of plexuser with your own username.

When you are done, save the file by typing Ctrl-O, Enter to save, then Ctrl-X to exit.

You will need to enable the service. Type

sudo systemctl enable rclone.service

Reload the service so it'll work:

sudo systemctl daemon-reload

If you don't plan on installing Plexdrive, then you will need to reboot your server now. Type

sudo reboot

You may need to wait a few seconds for the server to be back online again... just enough time to grab another cup of coffee. You deserve a break.

If you only wish to use Rclone and if you rebooted, just click away the PuTTY session (it has become unresponsive anyway). You are done now and you can proceed to Part 6 - Making it all come together.

If however you are planning to add Plexdrive, read on.

Mounting Plexdrive

Only follow these instructions if you are installing Plexdrive - which is now a legacy feature (Rclone is just as good now).

Make sure you are logged into PuTTY with your own username. First, let's create the mount directory:

sudo mkdir /media/Plexdrive

To speed up the installation a bit, create a screen session so that we can proceed while Plexdrive is creating the cache. Type

screen -S plexdrive

This will open a new session which we can place in the background later to continue setting things up. Type

sudo plexdrive mount -c /root/.plexdrive -o allow_other -v 2 /media/Plexdrive

You will be asked to provide your generated client ID. This is the Google client ID you created in part 4. Remember how I asked you to keep the browser open? The codes are probably still sitting on your screen. Paste it using right click, then hit Enter.

Do the same with the generated client secret, again this is the client secret you created in part 4 and that is still on your browser screen. If you had closed your browser after all, head back to, click "Credentials", and click "Edit" behind the API you created. This will show you the OAuth information again.

You will now be asked to paste a link in your browser. Use your mouse to select the entire link (see screenshot below). DO NOT TYPE CTRL-C!!! Just selecting it will copy the link.

Paste this link in your PC browser. You are asked to authorize Google drive and will be given an authorization code. Paste the code in PuTTY (right click!).

If all goes well, Plexdrive will start generating the cache. This will take a long time, but thanks to the separate screen we do not have to wait till it is completely finished. I do suggest waiting a few minutes until it mentions that it finished the initial scanning.

Once the cache creating process slows down to 1 or 2 items at the time, you can safely detach the screen to proceed with the following steps. To detach from the screen press Ctrl-A, then the letter D.

Once you are back on your main screen (placing the cache process in the background), type

sudo nano /etc/systemd/system/plexdrive.service

In the nano text editor paste the following lines:

Description=Mount Plexdrive to /media/Plexdrive
ExecStartPre=-/bin/mkdir -p /media/Plexdrive
ExecStart=/usr/local/bin/plexdrive mount \
  -c /root/.plexdrive \
  -o allow_other \
ExecStop=/bin/fusermount -u -z /media/Plexdrive
ExecStop=/bin/rmdir /media/Plexdrive

Save with Ctrl-O, Enter, then Ctrl-X. You will need to enable the service. Type

sudo systemctl enable plexdrive.service

Reload the service so it'll work:

sudo systemctl daemon-reload

Time to check our caching process! Go back to the screen you placed in the background:

screen -r plexdrive

I did not find it necessary to wait till the entire scanning process was done. Once mine slowed down to one or two items at the time, I found I could reboot safely and let the service take over. First detach your screen (Ctrl-A, D), then reboot.

sudo reboot

Click away the PuTTY session, it has become unresponsive.

We're almost there! All that needs to be done now is Part 6 - Making it all come together.