Prerequisites
- Install rclone
- Create your own client ID for Google.
Add Google Drive remotes in rclone
Once you have installed rclone and created your client ID in Google, you can now begin adding the “remote” in rclone. Remotes in rclone are your remote drives that you want to sync to locally. rclone supports syncing many remote drives, but here we will be specifically mounting a Google drive. If there are no specific instructions to an option when configuring, then you can leave that you can regard that step as optional and use the default option. Let’s begin by configuring the new rclone remote:
rclone config
The next step will use the client_id and client_secret that was created when you set up your own cliend_id in Google. Enter those values to proceed.
In Option scope, choose the first option to give access to all files in Google Drive.
When prompted to open a browser or not, open a browser and login with your Google account. This step authenticates rclone with Google using the client_id and secret_id that was created. You can also use a link if you are configuring this in a headless terminal.
Mount rclone remote
Use the following command to list your configured remotes:
rclone listremotes
You should see the remote that you just configured.
Create a folder or folders in your home directory to mount your rclone remotes such as “/home/user/gdrive1”.
You can then mount your rclone remote with the following command:
rclone mount --daemon "remote/" "/home/user/gdrive1"
Your drive should now be mounted in the directory you specified.
Auto-mount rclone remotes
Create the following bash script file. Make changes to this script as needed. You can mount multiple remotes by adding additional mount points and rclone mount commands.
#!/bin/bash`
REMOTE="google-drive-smu" # The name of your rclone remote
PATH_TO_FILES="/" # The path on the remote you want to mount
LOCAL_MOUNT_POINT="/home/vwenberg/gdrive" # Where to mount it locally, this path needs to exist.
REMOTE2="google-drive-my-drive-smu" # The name of your rclone remote
PATH_TO_FILES2="/" # The path on the remote you want to mount
LOCAL_MOUNT_POINT2="/home/vwenberg/gdrive-mydrive" # Where to mount it locally, this path needs to exist.
rclone mount --daemon "${REMOTE}:${PATH_TO_FILES}" "${LOCAL_MOUNT_POINT}"
rclone mount --daemon "${REMOTE2}:${PATH_TO_FILES2}" "${LOCAL_MOUNT_POINT2}"
Save this file and make it executable. You then need to run this script on reboot by adding it to the crontab.
crontab -e
Add the following line:
@reboot /home/vwenberg/gdrive.sh
Save the file. The script will now run and mount all your remotes on boot.