Setting up RClone mount on Ubuntu. A little steer greatly appreciated

Afternoon folks,

I’ve been using RClone for a while now on a seedbox and it has been working like a champ for me, however I’m now in the process of setting up a more complete VPS solution that will act as seedbox and Plex server.

I had been hoping to do all this in Windows due to my familiarity with the OS, however this seems cost prohibitive, therefore I’ve had to roll up my sleeves and dust of all my scattered notes on Unix commands.

I have the server up an running and have successfully installed both Plex and Rclone (I copied over the Rclone config file from my seedbox) What I don’t have fully working is RClone as a mount and I’d really appreciate a little push in the right direction to help get it set up correctly, avoiding any api bans with Gdrive if possible.

So I’ve taken what I think is the first step, but I’d like to double check it’s a correct one and if so where to go next with it.

I’ve used this initial command in Putty, which I hope is mounting the main 30tb media storage folder of my Gdrive to a folder on my server. I ran it about 30 minutes ago and it doesn’t seem to have finished what it’s doing. Is that normal?

rclone mount “gdrive:/The Skull” /home/craftyclown/Skull

When you say finished, it wouldn’t return a prompt back to you as the command is “running”.

Are you using 18.04 on Ubuntu? Should be a little hard at first, but on Ubuntu, you have systemd to start and stop services.

Those are are in /etc/systemd/system and I usually call mine this:

felix@gemini:/etc/systemd/system$ cat gmedia-rclone.service
[Unit]
Description=RClone Service
PartOf=gmedia.service
RequiresMountsFor=/data

[Service]
Type=notify
Environment=RCLONE_CONFIG=/data/rclone/rclone.conf
ExecStart=/usr/bin/rclone mount gcrypt: /GD \
   --allow-other \
   --bind 192.168.1.30 \
   --buffer-size 256M \
   --dir-cache-time 72h \
   --drive-chunk-size 32M \
   --log-level INFO \
   --log-file /home/felix/logs/rclone.log \
   --umask 002 \
   --vfs-read-chunk-size 128M \
   --vfs-read-chunk-size-limit off \
   --rc
ExecStop=/bin/fusermount -uz /GD
Restart=on-failure
User=felix
Group=felix

[Install]
WantedBy=multi-user.target

If you create something along those lines with a few mods with your user that you are using. You can run:

systemctl daemon-reload
systemctl start gmedia-rclone.service
systemctl status gmedia-rclone.service
systemctl enable gmedia-rclone.service

The first reads the changes from disk.
The second starts it.
The third checks the status of it.
The last one starts it on boot.

When you say finished, it wouldn’t return a prompt back to you as the command is “running”.

Right, of course! So to run further commands I would close Putty and then open a new connection and it should keep running in the background?

It does appear to be correctly mounted as I can open filezilla and see the media contents in the /home/craftyclown/Skull directory

If I try to browse for a media folder in Plex however, it sees the Skull folder but it is grayed out and can’t be selected. Is this most likely a permissions issue?

If you close out the Putty session, it would close out the rclone process.

If the systemd stuff is a little too much to start, you can add --daemon on the end of your command and that will return the prompt and run in the background.

Yes I think baby steps are called for at present :smiley:

So we’d be looking at this then as a basic command

rclone mount “gdrive:/The Skull” /home/craftyclown/Skull --daemon

I’m still stumped about the permissions thing. Is this a users/groups thing that’s stopping me from adding the directory?

Ok so oddly enough closing the terminal windows with my old command didn’t actually disconnect the mount. I can still access it via Filezilla. Did I misunderstand something?

Edit: Granted I am checking via Filzilla on my laptop. Not sure why that would make a difference though.

So my user is felix on my system and that is the man that all my stuff runs as.

felix@gemini:~$ id felix
uid=1000(felix) gid=1001(vpn) groups=1001(vpn),24(cdrom),25(floppy),29(audio),30(dip),33(www-data),44(video),46(plugdev),108(netdev),1000(felix),111(plex)

So for me, I use the UID of 1000 and the main group for me is also 1000 as that’s the group name as well.

I do something a little different as I do not run Plex as a plex user, but as ‘felix’ as well since there is a way to do that.

felix@gemini:/etc/systemd/system/plexmediaserver.service.d$ cat override.conf
#
#
[Service]
#  These values are only needed if you wish to change user & group
User=felix
Group=felix

# This is needed to change the default umask
Umask=0002

Usually if you close out a running terminal, the command should eventually die out to. Not sure how long that would take.

So if I’m understanding you correctly I would use the following?

craftyclown@King_Kong:/etc/systemd/system/plexmediaserver.service.d$ cat override.conf

[Service]

User=craftyclown
Group=craftyclown

Umask=0002

For me, I find that to be the easiest setup as I can use the same user for everything.

You do need to adjust the plex permissions as well if you make that change. Here is my example:

root@gemini:/var/lib ls -al | grep plex
drwxr-xr-x  3 felix    felix    4096 Aug 29 09:51 plexmediaserver
root@gemini:/var/lib chown -R felix:felix plexmediaserver/
1 Like

Sorry excuse my total ignorance, but how exactly do I run the command below in terminal?

craftyclown@King_Kong:/etc/systemd/system/plexmediaserver.service.d$ cat override.conf

[Service]

User=craftyclown
Group=craftyclown

Umask=0002

You would just restart plexmediaserver like this:

root@gemini:/var/lib systemctl restart plexmediaserver

You should see Plex running with the new user

root     19803 10636  0 14:05 pts/1    00:00:00 grep Plex
felix    24766     1  0 09:36 ?        00:00:00 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server"
felix    24768 24766  1 09:36 ?        00:03:10 /usr/lib/plexmediaserver/Plex Media Server
felix    24792 24768  0 09:36 ?        00:00:20 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-cc260c476/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.14.1.5488-cc260c476 /usr/lib/plexmediaserver/Resources/Plug-ins-cc260c476/System.bundle
felix    24847 24768  0 09:36 ?        00:00:02 /usr/lib/plexmediaserver/Plex Tuner Service /usr/lib/plexmediaserver/Resources/Tuner/Private /usr/lib/plexmediaserver/Resources/Tuner/Shared 1.14.1.5488-cc260c476 32600 /waitmutex
felix    24873 24768  0 09:36 ?        00:00:40 Plex Plug-in [com.plexapp.agents.subzero] /usr/lib/plexmediaserver/Resources/Plug-ins-cc260c476/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.14.1.5488-cc260c476 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Sub-Zero.bundle
felix    24875 24768  2 09:36 ?        00:05:26 Plex Plug-in [com.plexapp.plugins.trakttv] /usr/lib/plexmediaserver/Resources/Plug-ins-cc260c476/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.14.1.5488-cc260c476 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Trakttv.bundle
felix    24877 24768  0 09:36 ?        00:01:43 Plex Plug-in [com.plexapp.plugins.WebTools] /usr/lib/plexmediaserver/Resources/Plug-ins-cc260c476/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.14.1.5488-cc260c476 /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/WebTools.bundle

Sorry I must be a couple of steps behind. I’m still struggling to enter the necessary code to change permissions.

I tried entering it into terminal but it threw up errors. Am I supposed to be entering it all at once?

apologies I really am very new to using Linux.

Not a problem at all!

For the changing of permissions, you’d type:

chown -R craftyclown:craftyclown /var/lib/plexmediaserver

Thanks, that bit seems clear. I’m changing the ownership of plex to user craftyclown and group craftyclown, is that right?

It was actually the previous step I was struggling with where you had the override.conf and Umask 02. I’m not quite sure what I’m doing there at all.

Thanks for your patience

Yes, you’ve explained that back correctly.

Umasks are a little more complicated, but not that bad.

root@gemini:/etc ls -al hosts
-rw-r--r-- 1 root root 345 Sep  2 16:00 hosts
drwxr-xr-x   2 root root     4096 Aug 25 16:32 xml

Basically for each file you have 3 settings you have for (user)(group)(other). One those 3 spots you can see I have a read/write/execute or rwx. The first bit is the directory flag so that’s kind of not part of the umask.

For me, I want to make sure that I give user and group permissions so I set it like that.

There is a nice little article on umask that does a much better job than me:

https://linuxaria.com/article/linux-shell-understanding-umask-with-examples

Great, thanks. So the key line I kook from that link was…

“In this way all sessions will use the 0002 umask giving to the group the permission to write to files and directories”

So when using the command Umask=0002 do I need to specify where I am applying it to?

In this case, it applies to all the plex related services that are running.

So if plex creates a file, it’ll have those permissions. It does that for logs and such.

I use that in my setup as I have a ‘vpn’ user and I do all my permissions based on group.

Ok so I think the only bit I’m still not getting is exactly how to apply those commands. I literally don’t know what to type into terminal.

Sorry I know I need serious hand holding :smiley:

On a plus note I am taking loads of notes and hopefully I will start getting my head around this soon.

Urghh, think I’m digging myself deeper and deeper into the unknown :frowning:

I thought I’d managed to successfully change the permissions for Plex but now it doesn’t open at all.

I’m seriously considering wiping the server and starting again from scratch.

So maybe a bit too much to bite off at first.

The command to change the ownership for the plex files is executed as the root user:
First run as root:

systemctl stop plexmediaserver

and change the permissions

chown -R craftyclown:craftyclown /var/lib/plexmediaserver

and make sure the override file is there.

Once the chown is done, you can start plex backup by refreshing the disk for changes and start it by typing in:

systemctl daemon-reload
systemctl start plexmediaserver

If none of that works, you can just wipe out plex completely and reinstall plex from scratch and you wipe it by:

apt purge plexmediaserver