RSS Amplifier

fernvenue's Blog · Dec 9, 2023

Mount Cloud Drive using Rclone

0
Sign in to vote or save

fernvenue's Blog

Some people always say that Cloud Drive providers don’t have a native Linux client, but actually, we have a simpler way to use these Cloud Drives: mount them as local disks on Linux using RClone. This way, we can use them just like local folders. In this article, I’ll use Microsoft OneDrive and Google Drive as examples to demonstrate how to mount Cloud Drives on Linux.

Rclone

Rclone’s website has a clear description about itself:

Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors’ web storage interfaces. Over 70 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.

Therefore, we will not provide extensive details about its specific functions and implementation here.

On Debian, we can install RClone using the package manager::

apt install rclone

RClone’s documentation has many configuration steps for various Cloud Drives. Here, we’ll follow the steps for Microsoft OneDrive and Google Drive to set up our accounts. We won’t delve further into this aspect here, please follow the latest documentation.

Mount

Micrsoft OneDrive

Let’s create a folder first:

mkdir ~/OneDrive

Now we can use RClone to mount our OneDrive to it

rclone --vfs-cache-mode writes mount OneDrive: ~/OneDrive

By the way, here the OneDrive in the command should be the remote name. You can find your remote name using rclone config. After successfully mounting, go to ~/OneDrive to check your OneDrive files.

Now, let’s stop it and use a systemd service to automatically mount OneDrive. Create ~/.config/systemd/user/OneDrive.service:

[Unit]
Description=OneDrive
AssertPathIsDirectory=%h/OneDrive
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount --vfs-cache-mode full OneDrive: /home/fernvenue/OneDrive
ExecStop=/usr/bin/fusermount -zu %h/OneDrive
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target

Remember to replace the target folder, then save, enable, and start it:

systemctl --user enable OneDrive --now
systemctl --user status OneDrive

Now go ~/OneDrive folder to check your OneDrive files:

image

Google Drive

Similar to Microsoft OneDrive, after setting up our Google Drive account using rclone config, let’s create a Google Drive folder first:

mkdir ~/GDrive

Then mount it to check if anything is wrong:

rclone --vfs-cache-mode writes mount GDrive: ~/GDrive

As mentioned above, here the GDrive in the command should be the remote name, which you can find using rclone config. After successfully mounted, go ~/GDrive to check your Google Drive files.

Now, let’s stop it and use a systemd service to automatically mount Google Drive. Create ~/.config/systemd/user/GDrive.service:

[Unit]
Description=GDrive
AssertPathIsDirectory=%h/GDrive
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount --vfs-cache-mode full GDrive: /home/fernvenue/GDrive
ExecStop=/usr/bin/fusermount -zu %h/GDrive
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target

Remember to replace the target folder, then save, enable, and start it:

systemctl --user enable GDrive --now
systemctl --user status GDrive

Now go ~/GDrive folder to check your Google Drive files.

Links

Read the original on blog.fernvenue.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.