# Mount Cloud Storages in Linux systems using rclone

## About

[rclone](https://rclone.org/) is a command line program to manage files on cloud storage. It supports mounting as local file systems which is the feature we need the most.

## Install `go`

```
sudo snap install go --classic

```

## Building on Ubuntu

```
VERSION=1.76.0
wget https://github.com/rclone/rclone/archive/refs/tags/v$VERSION.tar.gz
tar -xzf v$VERSION.tar.gz
cd rclone-$VERSION
go build -ldflags "-s -w"
./rclone version
sudo cp rclone /usr/bin
cd ..
rm -rf v$VERSION.tar.gz rclone-$VERSION

```

## Configuring a cloud storage provider

```
rclone config

```

- Use the defaults where you're not sure what to set.
- For `client ID` and `client secret` use your own values that you've generated for the specific provider.
- Request full access to the storage.
- Use [this](https://rclone.org/remote_setup/) guide on how to configure `rclone` on a remote machine (you don't need to `Edit advanced config`; also, be sure to add the displayed redirect-URL in the `OAuth client ID` you've created).

## Using it as a user systemd service

Put in `$HOME/.config/systemd/user/rclone.service` (replace `lapis` in `ExecStart` with the name used in `rclone config` and `mountpoint` with the required path):

```
[Unit]
Description=RClone Mount Service
After=network-online.target

[Service]
Type=notify
KillMode=none

ExecStart=/usr/bin/rclone mount --vfs-cache-mode writes --vfs-cache-max-age 0h0m0s lapis: /home/lapis/mountpoint
ExecStop=/bin/fusermount -uz /home/lapis/mountpoint
Restart=on-failure

[Install]
WantedBy=default.target

```

And start and enable with `systemctl --user start rclone` and `systemctl --user enable rclone`.

## Similar tools

https://github.com/astrada/google-drive-ocamlfuse

## Notes

- Do *not* use `rclone` for mounting `Samba` shares. Use `cifs-utils` instead. See [here](https://forum.rclone.org/t/smb-vs-rclone-mount-file-operation-compatibility/34492) why.