一、Centos
(1)rclone挂载
#安装EPEL源
yum -y install epel-release
yum -y install wget unzip screen fuse fuse-devel
wget https://downloads.rclone.org/v1.40/rclone-v1.40-linux-amd64.zip
unzip rclone-v1.40-linux-amd64.zip
cd rclone-v1.40-linux-amd64
./rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> liuming #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
\ "amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
\ "s3"
3 / Backblaze B2
\ "b2"
4 / Box
\ "box"
5 / Cache a remote
\ "cache"
6 / Dropbox
\ "dropbox"
7 / Encrypt/Decrypt a remote
\ "crypt"
8 / FTP Connection
\ "ftp"
9 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
10 / Google Drive
\ "drive"
11 / Hubic
\ "hubic"
12 / Local Disk
\ "local"
13 / Microsoft Azure Blob Storage
\ "azureblob"
14 / Microsoft OneDrive
\ "onedrive"
15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
16 / Pcloud
\ "pcloud"
17 / QingCloud Object Storage
\ "qingstor"
18 / SSH/SFTP Connection
\ "sftp"
19 / Webdav
\ "webdav"
20 / Yandex Disk
\ "yandex"
21 / http Connection
\ "http"
Storage> 10 #选择10,Google Drive
要挂载的网盘是Google Drive,那么看见10号为Google Drive。
Google Application Client Id - leave blank normally.
client_id> #留空
Google Application Client Secret - leave blank normally.
client_secret> #留空
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n #选择n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth.... #复制到浏览器打开需要小飞机,获取验证码
Log in and authorize rclone for access
Enter verification code> #填入上面获取到的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> n #不用team drive 选择n
(2)挂载目录
#创建挂载点
mkdir -p /liuming/gdrive
#挂载Drive到/liuming/gdrive
./rclone mount liuming: /liuming/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
./rclone mount DriveName:Folder
DriveName为Rclone的配置名称,比如你配置rclone的时候,Name填的liuming
Folder为网盘里的文件夹路径,如果你要挂载整个网盘,直接填 / 挂载整个根目录
(3)重启——df –h查看挂载
[[email protected] ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 486M 0 486M 0% /dev
tmpfs 496M 4.0K 496M 1% /dev/shm
tmpfs 496M 13M 483M 3% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/vda1 34G 3.5G 29G 11% /
liuming: 1.0P 0 1.0P 0% /liuming/gdrive
tmpfs 100M 0 100M 0% /run/user/0
(4)挂载完成,但是重启VPS系统,不会自动启动挂载,每次进系统都要执行一遍
screen -S rclone
./rclone-v1.40-linux-amd64/rclone mount liuming: /liuming/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
这样有点麻烦,因此还需要弄个自动启动,把自带的rclone服务写到开机启动项里面
先把rclone的可执行文件复制到/usr/bin:
cp /root/rclone-v*/rclone /usr/bin/rclone
新建一个rclone.service文件:
vi /usr/lib/systemd/system/rclone.service
写入:
[Unit]
Description=rclone
[Service]
User=root
ExecStart=/usr/bin/rclone mount liuming: /liuming/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
Restart=on-abort
[Install]
WantedBy=multi-user.target
重载daemon,让新的服务文件生效:
systemctl daemon-reload
现在就可以用systemctl来启动rclone了:
systemctl start rclone
设置开机启动:
systemctl enable rclone
停止、查看状态可以用:
systemctl stop rclone
systemctl status rclone
重启你的VPS,然后查看一下rclone的服务起来没,接着查看一下盘子挂上去没:
reboot
systemctl status rclone
df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 486M 0 486M 0% /dev
tmpfs 496M 4.0K 496M 1% /dev/shm
tmpfs 496M 13M 483M 3% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/vda1 34G 3.5G 29G 11% /
liuming: 1.0P 0 1.0P 0% /liuming/gdrive
tmpfs 100M 0 100M 0% /run/user/0
二、Debian/Ubuntu
#安装rclone
wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh
#初始化配置
rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> liuming #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
\ "amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
\ "s3"
3 / Backblaze B2
\ "b2"
4 / Box
\ "box"
5 / Cache a remote
\ "cache"
6 / Dropbox
\ "dropbox"
7 / Encrypt/Decrypt a remote
\ "crypt"
8 / FTP Connection
\ "ftp"
9 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
10 / Google Drive
\ "drive"
11 / Hubic
\ "hubic"
12 / Local Disk
\ "local"
13 / Microsoft Azure Blob Storage
\ "azureblob"
14 / Microsoft OneDrive
\ "onedrive"
15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
16 / Pcloud
\ "pcloud"
17 / QingCloud Object Storage
\ "qingstor"
18 / SSH/SFTP Connection
\ "sftp"
19 / Webdav
\ "webdav"
20 / Yandex Disk
\ "yandex"
21 / http Connection
\ "http"
Storage> 10 #选择10,Google Drive
Google Application Client Id - leave blank normally.
client_id> #留空
Google Application Client Secret - leave blank normally.
client_secret> #留空
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n #选择n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth.... #复制到浏览器打开,获取验证码
Log in and authorize rclone for access
Enter verification code> #填入上面获取到的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> y #选择y
Fetching team drive list...
No team drives found in your account--------------------
[liuming]
client_id =
client_secret =
service_account_file =
token = {"access_token":"ya29.GltFBd7UJN2qrxdG8FnG_rMuB18ogb8QlujdL7glvXtfV"}
team_drive =
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #选择y
Current remotes:
Name Type
==== ====
liuming drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q #选择q退出
挂载为磁盘
#新建本地文件夹,路径自己定,即下面的LocalFolder
mkdir /root/GoogleDrive
#挂载为磁盘
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
如需卸载磁盘
fusermount -qzu LocalFolder
三、自启动
(1)下载并编辑脚本
wget https://www.moerats.com/usr/shell/rcloned && nano rcloned
NAME="" #rclone name名,及配置时输入的Name
REMOTE=’’ #远程文件夹,Google Drive网盘里的挂载的一个文件夹
LOCAL=’’ #挂载地址,VPS本地挂载目录
Debian系统
apt-get install sudo -y
设置自启
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
update-rc.d -f rcloned defaults
bash /etc/init.d/rcloned start
版权属于:刘明
本文链接:http://liuming.cc/10.html
转载时须注明出处及本声明