Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system?
Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll be using mega.nz for this guide.
If you are new to Rclone, It is an open-source command-line program to sync files and directories to and from different cloud storage providers, it supports over 35 different cloud storage providers (gdrive, mega, onedrive, dropbox, and lots more).
In this guide, I'll be mounting my mega cloud storage to my Ubuntu system, before you get started, read the guide on Synching File With Rclone, once you've done that, we are ready to go.
Note: I'll be mounting a mega storage, but the steps apply to other storage providers, if you are having an issue, make sure you leave a comment.
Step 1. Create a New Folder on Your System that Will Be Used to Mount Mega Storage
I'll be creating a folder mega in my user home directory:
To get a reliable mounting, we would want to implement the Rclone File Caching, this is so the cloud storage system work more like a normal file system.
We can absolutely mount without using a caching, but this might cause an issue with most applications that try to use that specific mount directly to write data.
On top of that, once the data you try uploading fails, rclone can't auto-retry (this is because it would directly stream the data), but with caching enabled, you are in safe hands, I learned this the hard way.
Step 2. Mount Remote Storage (Mega) as A File System.
To mount your remote storage you'll want to make note of the remote name when you started the rclone setup, run
rclone configif you don't know. if you haven't created one, read Getting Started With Rclone, now run the following command:
rclone --vfs-cache-mode writes mount remote-name: ~/mega
--vfs-cache-mode writes is enabling a write-cache mode, this mode writes the file to a local cache (this is done in the background), as file get written to the local cache, it shows up in you remote storage. The good thing about this mode is that you can still make use of your remote storage while the file is writing.
The above command would take a couple of minutes, you can append an ampersand to background the process, this way you won't have to restart it if it doesn't complete, here is the command if you want to background the process:
rclone --vfs-cache-mode writes mount remote-name: ~/mega &
Once it's done, type
df -h to confirm if it's mounted, this a screenshot of mine:
Step 3. Mount Drive On Boot
By default, your mounted drive won't stick when you reboot your system, which is kinda annoying, there are a couple of ways you could remount on startup, you can either use systemd or create a script that runs at boot, I'll follow the latter as it is easier.
Create a script and open it in your user home directory:
Note: I usually have my scripts in a folder called 'scripts', so, you might have to create that if it doesn' already existed.
nano ~/scripts/mount-mega.sh && mount-mega.sh
Paste in the mount command:
#!/bin/bash /usr/bin/rclone --vfs-cache-mode writes mount remote-name: ~/mega &
Make the script executable:
chmod +x ~/scripts/mount-mega.sh
Go into your user crontab with
crontab -e or
crontab -e -u UserName
Now add this to make the script run at startup:
@reboot sh /username/scripts/mount-mega.sh
Unmount Virtual Storage in Rclone
To unmount on GNU/Linux, you use:
fusermount -u /path/to/local/mount
This is the path you mounted the storage to, if you don't know the path, run
mount | grep rclone in some cases, the mount might be in use, if it is in use, use this to force close and unmount:
fusermount -uz /path to/mount
You'll see something as follows:
remote: on /home/user/mega type fuse.rclone (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
The /home/user/mega is the mount path, of course, yours would be different.