Rclone Google Drive Integration: systemd Service & Binary Wrapper Setup
1. Prerequisites Verification
Verify the system PATH contains ~/.local/bin and check the binary path of Rclone:
which rclone
mkdir -p ~/.config/systemd/user
mkdir -p ~/.local/bin
mkdir -p ~/scripts
2. Service Unit Configuration
Create the user-level systemd service file at ~/.config/systemd/user/rclone-gdrive.service:
[Unit]
Description=Rclone Mount Google Drive
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
ExecStart=/usr/bin/rclone mount gdrive: /home/aaa/GoogleDrive --vfs-cache-mode full
ExecStop=/usr/bin/fusermount -u /home/aaa/GoogleDrive
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
Note: Replace proxy configurations and directory paths according to system specifications.
3. Execution Scripts & Binary Symlinks
Mount Control Script
Create ~/scripts/gmount.sh:
#!/bin/bash
systemctl --user start rclone-gdrive.service "$@"
Unmount Control Script
Create ~/scripts/gumount.sh:
#!/bin/bash
systemctl --user stop rclone-gdrive.service "$@"
Status Inspection Script
Create ~/scripts/gstatus.sh:
#!/bin/bash
systemctl --user status rclone-gdrive.service "$@"
Permission Assignment & Symlink Generation
Assign execution flags and link to the binary directory:
chmod +x ~/scripts/gmount.sh ~/scripts/gumount.sh ~/scripts/gstatus.sh
ln -s ~/scripts/gmount.sh ~/.local/bin/gmount
ln -s ~/scripts/gumount.sh ~/.local/bin/gumount
ln -s ~/scripts/gstatus.sh ~/.local/bin/gstatus
4. Initialization & Usage
Reload systemd manager configuration:
systemctl --user daemon-reload
Command Summary
| Command | Action |
|---|---|
gmount | Triggers background mount via systemd |
gumount | Safely unmounts filesystem and stops process |
gstatus | Displays service state, memory utilization, and logs |
systemctl --user enable rclone-gdrive.service | (Optional) Enables automated startup on login |
systemctl --user disable rclone-gdrive.service | Disables automated startup on login |