Well its’ been a while (I got busy for a minute) but I didn’t forget. I needed to doctor up what I had so it was a little more universal. I’d love to share this with the community but I wonder if anyone would help me vett this? Or should I start a different thread for it? Here is what I have. Is there any chance someone could see if it works for them and if it seems sensible and correct what I have? Thanks.
Here it is…
Set Up Local Mounts for the MEGA Remote File System
Ubuntu Version: ubuntu 24.04.2
Kernel: 6.8.0-54-generic
Rclone Version: 1.69.1
Mega Version (web): 5.49.3
Mounts We Will Be Setting UP
We will be setting up a mount for the entire remote file system as well as mounting several directories in the remote file system with Mega (online storage). IF this fits your use case or you just want to try it this should work well for a proof of concept. The code examples given will insert the value for your home directory for you but if you experience any issues you can also replace $HOME
with your actual username as you proceed. You can find it by using the whoami
command - it will show the username you are currently logged in under.
- Mega Root Filesystem: Mounts to $HOME/Mega
- Mega Collections Directory: Mounts to $HOME/Collections
- Mega Obsidian Directory: Mounts to $HOME/Obsidian
- Mega Projects Directory: Mounts to $HOME/Projects
Official Ubuntu documentation (as of the time of this post) can be found here
Create Directories
First we need to make sure that the directories (folders) that we need are there for us when we move on the the steps that come after. Copy each of the lines below and execute them one-by-one on your command line to create the mount directories on your local machine as well as directories on the mega remote filesystem. This will enable each of the service files we have just created in the previous step.
Create mount directories on your local machine
mkdir $HOME/Mega
mkdir $HOME/Collections
mkdir $HOME/Obsidian
mkdir $HOME/Projects
Create directories on Mega
After you have successfully logged into the web interface perform the following steps in order to create each directory on the remote file system.
- Click the Cloud drive tab located in the left sidebar (expand the sidebar if it is collapsed).
- Right mouse click and select Create folder (or click the Create folder button in the top right hand corner area).
- Enter one of
- Collections
- Obsidian
- Projects
Repeat steps 1, 2, and 3 for each of the directories we need to create.
Official Mega documentation (as of the time of this post) can be found here but it does not appear to have an article on this procedure that I can find at this time.
Remote Configuration With Rclone
First lets set up our rclone configuration and make sure it works.
Set up the rclone config for Mega
Assuming we are using rclone version 1.69.1
-
Run the following command to start and create the rclone configuration:
rclone config
-
You will be prompted with the following options:
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
Type n
and press Enter
to create a new remote.
-
You will be asked to name the remote. Enter a name of your choice (e.g., Mega
):
name> Mega
-
Next, you will see a list of storage types. Select Mega
by typing 33
and pressing Enter
:
> Type of storage to configure.
Choose a number from below, or type in your own value.
...
33 / Mega
\ (Mega)
...
Storage> 33
-
You will be prompted to enter your Mega username (email) and password:
user> your_email@example.com
pass> your_password
-
If you want to use advanced settings, you can configure them now. Otherwise, press Enter
to accept the defaults.
-
Finally, confirm the configuration by typing y
and pressing Enter
:
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
-
Our Mega remote is now set up and ready to use. You can quit this configuration by typing q
and pressing Enter
.
Official Rclone documentation (as of the time of this post) can be found here
Testing the Connection to the Remote
- Test that the remote can be mounted (this verifies the rclone config and that the connection to mega is working).
rclone mount Mega:/ $HOME/Mega --allow-other --vfs-cache-mode writes
Creating and Enabling System Services with Systemd
Now its time to make things persistent. By doing these steps we will be able to retain the work we’ve done - even if the computer is shut off or rebooted. Lets create and Enable service files - one for each mount. We’re mounting remote directories; and, in one case, the whole thing).
Create the service file to mount the storage root (the entire mega remote file system)
nano ~/.config/systemd/user/mega-storage-root-mount.service
Service File Contents
Filename: mega-storage-root-mount.service
[Unit]
Description=Rclone Mount for Mega Root Filesystem
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=rclone mount Mega:/ $HOME/Mega \
--allow-other \
--vfs-cache-mode writes
ExecStop=/bin/fusermount -u $HOME/Mega
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Check the contents of the service file
less ~/.config/systemd/user/mega-storage-root-mount.service
Create the service file to mount the Collections directory
nano ~/.config/systemd/user/mega-storage-collections-mount.service
Service File Contents
Filename: mega-storage-collections-mount.service
[Unit]
Description=Rclone Mount for Mega Collections Directory
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=rclone mount Mega:/Collections $HOME/Collections \
--allow-other \
--vfs-cache-mode writes
ExecStop=/bin/fusermount -u $HOME/Collections
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Check the contents of the service file
less ~/.config/systemd/user/mega-storage-collections-mount.service
Create the service file to mount the Obsidian Directory
nano ~/.config/systemd/user/mega-storage-obsidian-mount.service
Service File Contents
Filename: mega-storage-obsidian-mount.service
[Unit]
Description=Rclone Mount for Mega Collections Directory
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=rclone mount Mega:/Obsidian $HOME/Obsidian \
--allow-other \
--vfs-cache-mode writes
ExecStop=/bin/fusermount -u $HOME/Obsidian
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Check the contents of the service file
less ~/.config/systemd/user/mega-storage-obsidian-mount.service
Create the service file to mount the Projects Directory
nano ~/.config/systemd/user/mega-storage-projects-mount.service
Service File Contents
Filename: mega-storage-projects-mount.service
[Unit]
Description=Rclone Mount for Mega Projects Directory
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=rclone mount Mega:/Projects $HOME/Projects \
--allow-other \
--vfs-cache-mode writes
ExecStop=/bin/fusermount -u $HOME/Projects
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Check the contents of the service file
less ~/.config/systemd/user/mega-storage-projects-mount.service
Add The Services To Systemd And Get Them Going
Reload the daemon
`systemctl --user daemon-reload`
Enable each service file
Copy each of the lines below and execute them one-by-one on your command line. This will enable each of the service files we have just created in the previous step.
systemctl --user enable mega-storage-root-mount
systemctl --user enable mega-storage-collections-mount
systemctl --user enable mega-storage-obsidian-mount
systemctl --user enable mega-storage
Start and check the status of each service file
systemctl --user start mega-storage-root-mount
systemctl --user status mega-storage-root-mount
systemctl --user start mega-storage-collections-mount
systemctl --user status mega-storage-collections-mount
systemctl --user start mega-storage-obsidian-mount
systemctl --user status mega-storage-obsidian-mount
systemctl --user start mega-storage-projects-mount
systemctl --user status mega-storage-projects-mount
Reboot your computer
Lets see by practical example whether it does what it’s supposed to?
Check in the file manager for the mount
Check it out - see if you can see and use it in your file manager?
Check the statuses of the service files again for a final confirmation
systemctl --user status mega-storage-root-mount
systemctl --user status mega-storage-obsidian-mount
systemctl --user status mega-storage-projects-mount
If everything has gone well you should have a working system of mounts that mount the mega remote file system (and a few directories in it) to your local machine.
Links
Official Ubuntu Documentation
Official Mega Documentation
Official Rclone Documentation