How to Mount Google Drive using rclone on Linux

Mounting your Google Drive on Linux allows you to access your cloud storage as if it were a local directory. This guide will walk you through the complete process of setting up and mounting Google Drive using rclone, a powerful command-line tool for cloud storage management.

Prerequisites

Before starting, ensure you have:

  • A Linux system with root or sudo access
  • An active Google account with Google Drive
  • Internet connection for authentication and file access
  • Basic familiarity with the command line

Step 1: Install rclone

Ubuntu/Debian

sudo apt update
sudo apt install rclone

CentOS/RHEL/Fedora

# For CentOS/RHEL
sudo yum install rclone

# For Fedora
sudo dnf install rclone

Arch Linux

sudo pacman -S rclone

Install from Official Script

curl https://rclone.org/install.sh | sudo bash

Verify the installation:

rclone version

Step 2: Install FUSE

To mount filesystems, rclone requires FUSE (Filesystem in Userspace):

Ubuntu/Debian

sudo apt install fuse

CentOS/RHEL/Fedora

# For CentOS/RHEL
sudo yum install fuse

# For Fedora
sudo dnf install fuse

Arch Linux

sudo pacman -S fuse2

Step 3: Configure Google Drive Remote

Start the rclone configuration process:

rclone config

Follow these steps in the interactive setup:

  1. Create a new remote: n) New remote
  2. Name your remote: name> gdrive (You can use any name you prefer)
  3. Select Google Drive: Storage> drive
  4. Leave client ID and secret blank (unless you have your own): client_id> [Press Enter] client_secret> [Press Enter]
  5. Choose scope (recommended: option 1 for full access): scope> 1 This gives full access to all files except the Application Data Folder.
  6. Service Account file (leave blank for personal use): service_account_file> [Press Enter]
  7. Enable web browser authentication: y) Yes
  8. Browser authentication:
    • rclone will open your default browser
    • Log in to your Google account
    • Grant permissions to rclone
    • Copy the verification code back to the terminal
  9. Shared Drive configuration: n) No (Unless you want to access a specific Shared Drive)
  10. Confirm configuration: y) Yes this is OK

Read https://rclone.org/drive/#making-your-own-client-id

Step 4: Test the Configuration

Verify that rclone can access your Google Drive:

# List directories in your Google Drive
rclone lsd gdrive:

# List all files
rclone ls gdrive:

# List files with details
rclone lsl gdrive:

Step 5: Create Mount Point

Create a directory where you want to mount Google Drive:

mkdir ~/GoogleDrive

Step 6: Mount Google Drive

Basic Mount Command

rclone mount gdrive: ~/GoogleDrive --daemon

Recommended Mount Command with Options

rclone mount gdrive: ~/GoogleDrive \
  --vfs-cache-mode writes \
  --vfs-cache-max-age 100h \
  --vfs-cache-max-size 10G \
  --vfs-read-chunk-size 32M \
  --vfs-read-chunk-size-limit off \
  --buffer-size 32M \
  --daemon

Mount Options Explained

  • --vfs-cache-mode writes: Cache file writes to improve performance
  • --vfs-cache-max-age 100h: Keep cached files for 100 hours
  • --vfs-cache-max-size 10G: Limit cache size to 10GB
  • --vfs-read-chunk-size 32M: Read files in 32MB chunks
  • --buffer-size 32M: Set buffer size for better performance
  • --daemon: Run in background

Alternative: Mount with GUI Support

If you’re using a desktop environment and want the mount to appear in file managers:

rclone mount gdrive: ~/GoogleDrive \
  --vfs-cache-mode writes \
  --allow-other \
  --daemon

Step 7: Verify the Mount

Check if the mount is successful:

# List mounted filesystems
df -h | grep GoogleDrive

# Check if files are accessible
ls -la ~/GoogleDrive

Step 8: Unmount Google Drive

To unmount the drive:

# Method 1: Using fusermount
fusermount -u ~/GoogleDrive

# Method 2: Using umount
sudo umount ~/GoogleDrive

# Method 3: Kill rclone process
killall rclone

Step 9: Auto-Mount on Boot (Optional)

Using systemd Service

Create a systemd service file:

sudo nano /etc/systemd/system/rclone-gdrive.service

Add the following content (replace username with your actual username):

[Unit]
Description=rclone: Remote FUSE filesystem for Google Drive
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
User=username
Group=username
ExecStart=/usr/bin/rclone mount gdrive: /home/username/GoogleDrive \
  --config=/home/username/.config/rclone/rclone.conf \
  --vfs-cache-mode writes \
  --vfs-cache-max-age 100h \
  --vfs-cache-max-size 10G \
  --vfs-read-chunk-size 32M \
  --buffer-size 32M \
  --allow-other
ExecStop=/bin/fusermount -u /home/username/GoogleDrive
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable rclone-gdrive.service
sudo systemctl start rclone-gdrive.service

Check service status:

sudo systemctl status rclone-gdrive.service

Using /etc/fstab

Add the following line to /etc/fstab:

sudo nano /etc/fstab

Add this line (replace username with your actual username):

gdrive: /home/username/GoogleDrive rclone rw,noauto,nofail,_netdev,user,exec,allow_other 0 0

Performance Tips

Optimize for Your Use Case

For frequent small file access:

rclone mount gdrive: ~/GoogleDrive \
  --vfs-cache-mode full \
  --vfs-cache-max-size 10G \
  --vfs-read-ahead 256M \
  --daemon

For streaming large files:

rclone mount gdrive: ~/GoogleDrive \
  --vfs-cache-mode off \
  --vfs-read-chunk-size 128M \
  --vfs-read-chunk-size-limit 2G \
  --buffer-size 64M \
  --daemon

Troubleshooting

Common Issues and Solutions

Issue: Permission denied

# Add your user to the fuse group
sudo usermod -a -G fuse $USER
# Log out and log back in

Issue: Mount point is busy

# Force unmount
sudo umount -l ~/GoogleDrive

Issue: Slow performance

# Increase cache settings
rclone mount gdrive: ~/GoogleDrive \
  --vfs-cache-mode full \
  --vfs-cache-max-size 20G \
  --daemon

Issue: Files not showing immediately

# Add directory cache timeout
rclone mount gdrive: ~/GoogleDrive \
  --dir-cache-time 1000h \
  --daemon

Check rclone Logs

# View logs
rclone mount gdrive: ~/GoogleDrive --log-level INFO --log-file ~/rclone.log

# Or run in foreground for debugging
rclone mount gdrive: ~/GoogleDrive -v

Security Considerations

  1. Token Security: Your authentication tokens are stored in ~/.config/rclone/rclone.conf. Protect this file with appropriate permissions: chmod 600 ~/.config/rclone/rclone.conf
  2. Network Security: All communication with Google Drive is encrypted via HTTPS.
  3. Local Access: Use --allow-other carefully as it allows other users to access the mount.

Conclusion

You now have Google Drive mounted on your Linux system! The mounted directory behaves like any other local directory, allowing you to:

  • Copy files to and from Google Drive using standard commands
  • Edit files directly in your preferred applications
  • Access Google Drive through your file manager
  • Use command-line tools on your cloud files

Remember that changes to files are synchronized with Google Drive, so always ensure you have a stable internet connection when working with important files.

For advanced usage and additional options, refer to the official rclone documentation.

Post Comment

You May Have Missed