This article shows how to mount a Google Cloud Storage (GCS) bucket as a folder on a Linux machine with rclone, and how to mount it again automatically after a reboot.
Costs. GCS charges for storage, operations and network egress, and a mount can generate many operations. In Ursa Major, Standard storage is recharged to a lab funding source (Tier 2), while archive classes such as Coldline fall under Tier 1 within limits. See KB005: Ursa Major service tiers and KB007: Tier 2 recharge workflow. Archive classes carry retrieval charges, so they are a poor fit for a mount you read often.
Prerequisites
- A Linux machine where you can use FUSE (your workstation, or a VM in your project)
- rclone installed (see rclone.org/install)
- An existing GCS bucket
- An account or service account with access to the bucket
Step 1: Configure an rclone remote
The simplest way is the interactive wizard:
rclone config
- Choose
nfor a new remote and name itgc. - For the storage type, choose Google Cloud Storage (this is not Google Drive) (
gcs). - Set credentials in one of these ways:
- On a Google Cloud VM: answer
truetoenv_authto use the VM's service account. - With a service account key file: enter its path at
service_account_file. Keep the key file private (chmod 600). - As yourself: leave both blank and complete the browser login rclone starts. On a machine without a browser, rclone prints a command to run on a machine that has one.
- On a Google Cloud VM: answer
- Enter your project number if asked (needed only to list or create buckets).
- If your bucket uses uniform bucket-level access, answer
truetobucket_policy_only. - Accept the defaults for the rest, then save.
The result in ~/.config/rclone/rclone.conf looks similar to this (with a service account key):
[gc]
type = gcs
project_number = 123456789012
service_account_file = /home/yourname/.config/gcloud/my-lab-sa-key.json
bucket_policy_only = true
Check that it works:
rclone lsd gc:
rclone ls gc:my-lab-bucket
Step 2: Create a mount point
mkdir -p ~/gc
Step 3: Mount the bucket
rclone mount gc:my-lab-bucket ~/gc --vfs-cache-mode writes --daemon --log-file ~/gc-rclone.log
--vfs-cache-mode writes lets applications save files normally. --daemon runs the mount in the background and returns you to the prompt; messages go to the log file.
To unmount:
fusermount3 -u ~/gc
(On older systems use fusermount -u.)
Step 4: Mount automatically at startup (optional)
Add an @reboot entry to your crontab. Use the full path to rclone, because cron does not load your usual PATH:
(crontab -l 2>/dev/null; echo "@reboot $(command -v rclone) mount gc:my-lab-bucket $HOME/gc --vfs-cache-mode writes --daemon --log-file $HOME/gc-rclone.log") | crontab -
A systemd user service is a more robust option if you manage the machine yourself.
Things to know
- A mounted bucket is slower than a local disk, especially with many small files. For bulk transfers use
rclone copyorrclone syncinstead. - Objects in GCS cannot be edited in place; changing a file uploads the whole file again.
- Google also offers Cloud Storage FUSE (
gcsfuse), which is another way to mount a bucket on Linux.
For rclone's full GCS options, see the rclone Google Cloud Storage documentation. Questions: research-computing@ucr.edu.