Prerequisites
Before mounting Google Drive, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
- A Google account with Drive access
Method 1: Using google-drive-ocamlfuse (Recommended)
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
Install dependencies:
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:alessandro-strada/ppa -y
sudo apt update
sudo apt install google-drive-ocamlfuse -y
Create mount point:
mkdir -p ~/googledrive
Authenticate (requires GUI or headless setup):
For headless server, run:
google-drive-ocamlfuse -headless -label=default
Follow the URL to get verification code, then paste it back.
Mount Google Drive:
google-drive-ocamlfuse ~/googledrive
Method 2: Using rclone (More Lightweight)
Install rclone:
curl https://rclone.org/install.sh | sudo bash
Configure Google Drive:
rclone config
Follow prompts:
- Select n for new remote
- Name: gdrive
- Select drive (number for Google Drive)
- Follow authentication steps (headless mode)
Mount with rclone:
mkdir -p ~/googledrive
rclone mount gdrive: ~/googledrive --daemon
Auto-mount at boot (add to crontab):
@reboot /usr/bin/rclone mount gdrive: /home/user/googledrive --daemon
Method 3: Using gcsfuse (Google Cloud Storage)
For Google Cloud Storage buckets (not Drive):
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt update
sudo apt install gcsfuse -y
mkdir -p /mnt/bucket
gcsfuse my-bucket /mnt/bucket
Test Google Drive Mount
ls -la ~/googledrive
echo "Hello from VPS" > ~/googledrive/test.txt
Check file in Google Drive web interface.
Unmount Google Drive
fusermount -u ~/googledrive
Or if using rclone:
sudo umount ~/googledrive
Set Up as System Service (rclone)
Create systemd service:
sudo nano /etc/systemd/system/rclone-gdrive.service
[Unit]
Description=Rclone Google Drive Mount
After=network-online.target
[Service]
Type=forking
User=root
ExecStart=/usr/bin/rclone mount gdrive: /root/googledrive --daemon
ExecStop=/bin/fusermount -u /root/googledrive
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable rclone-gdrive
sudo systemctl start rclone-gdrive
✅ Google Drive mounted. You can now access your Drive files from the VPS.