说明:我们很多人喜欢用VPS
做离线下载,不过由于有的服务器硬盘太小了,装不了太多电影资源啥的,我们就需要想办法了,之前说过可以通过挂载FTP
来增大空间,参考:Linux VPS通过安装CurlFtpFS来挂载FTP,这里再说个挂载Google Drive
网盘的方法,毕竟Google Drive
有15G
免费的空间,有的也有无限空间,都可以利用上去。
说明
本教程只适用Debian
/Ubuntu
系统,如果你是CentOS
或者其它Linux
系统,请使用以下命令安装rclone
:
curl https://rclone.org/install.sh | sudo bash
初始化配置和挂载方法和下面一样,开机自启可参考该教程→传送门。
安装
1、安装rclone
wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh
2、初始化配置
rclone config
会出现以下信息:
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> Rats #配置名称,随便填
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Google Photos
\ "google photos"
14 / Hubic
\ "hubic"
15 / JottaCloud
\ "jottacloud"
16 / Koofr
\ "koofr"
17 / Local Disk
\ "local"
18 / Mega
\ "mega"
19 / Microsoft Azure Blob Storage
\ "azureblob"
20 / Microsoft OneDrive
\ "onedrive"
21 / OpenDrive
\ "opendrive"
22 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
23 / Pcloud
\ "pcloud"
24 / Put.io
\ "putio"
25 / QingCloud Object Storage
\ "qingstor"
26 / SSH/SFTP Connection
\ "sftp"
27 / Union merges the contents of several remotes
\ "union"
28 / Webdav
\ "webdav"
29 / Yandex Disk
\ "yandex"
30 / http Connection
\ "http"
31 / premiumize.me
\ "premiumizeme"
Storage> 12 #选择12,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> #留空
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> 1
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id>
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #输入n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
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/ #打开该地址获取code
Log in and authorize rclone for access
Enter verification code>hjdd #输入你获取到的code
Configure this as a team drive?
y) Yes
n) No
y/n> n #输入n
--------------------
[Rats]
type = drive
client_id = 85042871
client_secret = D72gPc
scope = drive
token = {"access_token":"y902Z"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #输入y
Current remotes:
Name Type
==== ====
Rats 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保存退出
3、挂载为磁盘
#新建本地文件夹,路径自己定,即下面的LocalFolder
mkdir /root/GoogleDrive
#挂载为磁盘,下面的DriveName、Folder、LocalFolder参数根据说明自行替换
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
DriveName
为初始化配置填的name
,Folder
为Google Drive
里的文件夹,LocalFolder
为VPS
上的本地文件夹。
挂载成功后,输入df -h
命令查看即可!
4、卸载磁盘
fusermount -qzu LocalFolder
开机自启
先新建systemd
配置文件,适用CentOS 7
、Debian 8+
、Ubuntu 16+
。
再使用命令:
#将后面修改成你上面手动运行命令中,除了rclone的全部参数
command="mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000"
#以下是一整条命令,一起复制到SSH客户端运行
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target
[Service]
Type=simple
ExecStart=$(command -v rclone) ${command}
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF
开始启动:
systemctl start rclone
设置开机自启:
systemctl enable rclone
其他命令:
重启:systemctl restart rclone
停止:systemctl stop rclone
状态:systemctl status rclone
如果你想挂载多个网盘,那么将systemd
配置文件的rclone.service
改成rclone1.service
即可,重启动什么的同样换成rclone1
。
相关链接
#解决Rclone挂载Google Drive时上传失败和内存占用高等问题
https://www.moerats.com/archives/877/
博主,你好。我的vps上rclone挂载的团队盘状态显示active。但一两天了,文件夹下仍无法列出挂载的团队盘的目录,空间占用一直显示0。请问是什么原因,怎么解决?谢谢啦!
你换个文件夹挂载看看。
rclone mount GoogleDrive: /home/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
2020/02/16 16:22:50 mount helper error: fusermount: failed to access mountpoint /home/GoogleDrive: Transport endpoint is not connected
2020/02/16 16:22:50 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
以前能挂上的,现在不知道为什么挂不了了,一直报这个错,重新用rclone config 建了一个还是不行
fusermount -qzu LocalFolder
卸载后重新挂载解决了
终于挂上了。但是我想问一下博主,aria2自动上传脚本onedrive的和googledrive可以同时存在吗。在aria2.conf最后面同时加两条命令on-download-complete=/root/od.sh和on-download-complete=/root/gd.sh。我试了一下,同时存在两条的时候 所有的都不上传,但是又不会写顺序命令。
把2个写到一个上传脚本里就行了。
那个,大佬这个写到一起的格式是咋样的,,
大佬,我安装rclone前面都正常,安装到系统服务的时候就会报错,Failed to start rclone.service: Unit is masked. 然后在/etc/systemd/system目录下的rclone.service是空文件,0b大小。请问是什么原因呢,没有找到报错日志在哪里,系统是centos7
没有新建成功,你再试一下
重新安装了,还是一样的。
ok了,我自己弄好了。在rclone config里吧drive设置成team disk就可以了,感谢大佬
请问挂载一个无限Google Drive需要多长时间呢?我按教程来的,半个多小时了还没有返回的信息。服务器1核4G,洛杉矶。
这个没返回信息,其实已经挂好了,你额外开个窗口使用df -h查看
一直用的没问题,直到今天,第一步都报错。。。
--2019-12-08 19:27:45-- https://downloads.rclone.org/rclone-current-linux-amd64.zip
Resolving downloads.rclone.org (downloads.rclone.org)... 5.153.250.7, 2a02:24e0:8:61f9::1
Connecting to downloads.rclone.org (downloads.rclone.org)|5.153.250.7|:443... failed: Connection refused.
Connecting to downloads.rclone.org (downloads.rclone.org)|2a02:24e0:8:61f9::1|:443... failed: Network is unreachable.
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Xeon(R) CPU E31245 @ 3.30GHz (206A7),ASM,AES-NI)
Scanning the drive for archives:
1 file, 0 bytes
Extracting archive: /tmp/rclone.zip
ERROR: /tmp/rclone.zip
Can not open the file as archive
Can't open as archive: 1
Files: 0
Size: 0
Compressed: 0
rclone_debian.sh: line 12: cd: rclone-*: No such file or directory
cp: cannot stat 'rclone': No such file or directory
chown: cannot access '/usr/bin/rclone': No such file or directory
chmod: cannot access '/usr/bin/rclone': No such file or directory
cp: cannot stat 'rclone.1': No such file or directory
Purging old database entries in /usr/share/man...
Processing manual pages under /usr/share/man...
Purging old database entries in /usr/share/man/zh_CN...
Processing manual pages under /usr/share/man/zh_CN...
Purging old database entries in /usr/share/man/ko...
Processing manual pages under /usr/share/man/ko...
Purging old database entries in /usr/share/man/hu...
Processing manual pages under /usr/share/man/hu...
Purging old database entries in /usr/share/man/de...
Processing manual pages under /usr/share/man/de...
Purging old database entries in /usr/share/man/sl...
Processing manual pages under /usr/share/man/sl...
Purging old database entries in /usr/share/man/it...
Processing manual pages under /usr/share/man/it...
Purging old database entries in /usr/share/man/nl...
Processing manual pages under /usr/share/man/nl...
Purging old database entries in /usr/share/man/cs...
Processing manual pages under /usr/share/man/cs...
Purging old database entries in /usr/share/man/fr...
貌似解析到rclone的ipv6,导致下载失败,禁用下ipv6应该就好了。
那我去尝试下,看到这个报错我都懵了。。
你好,博主。
根据本文指导,按照操作成功挂载了ARIA2的下载文件夹和google drive
(1)root@localhost:~# df -h
boluo2:plan1 1.0P 105M 1.0P 1% /usr/local/caddy/www/aria2/Download
(2)root@localhost:~# systemctl status rclone
● rclone.service - Rclone
Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-11-30 02:33:24 EST; 5min ago
但是在aria2一开新任务,任务就失败。
在google drive是可以看到新任务产生的文件的,但是因为是失败的文件,所以完全打不开
想请教一下这是哪里出了错呢。
别把挂载盘当下载目录,可以下载到其它目录后,移动进挂载盘
理解。
可是我用xftp尝试将一张100k的图片从另一个文件夹复制到挂载文件夹,然后在50%就失败了
是因为虚拟机的配置太低吗,因为是试验性质,用的gcp cpu 1core 1.7g 10G硬盘
我看到博主有另外一篇博文,说到API也会影响,不知道是不是也有关系呢
盼解答,先多谢博主了
这个应该不会吧,才100k,得看日志才行
我刚才使用了rclone挂载Google Drive,一直都还算顺利的。
我在后面开始启动/设置开机自启的步骤里,发现不能成功。
状态:systemctl status rclone查看状态爆:
● rclone.service - Rclone Loaded: error (Reason: Bad message) Active: inactive (dead) Nov 25 19:59:21 10-8-31-36 systemd[1]: [/etc/systemd/system/rclone.service:8] Missing '='. Nov 25 20:02:46 10-8-31-36 systemd[1]: [/etc/systemd/system/rclone.service:8] Missing '='.但是我通过我的网站上传一张图片的时候是成功的,谷歌盘里也显示有
这个应该是你直接挂上了,所以上传没问题,systemctl状态的话,应该是配置文件不对,看提示好像是=的缘故
能否再介绍一下rclone 的webUI安装使用,感谢
这个很久前就玩过,感觉有点不太行,我过几天再看看有没有改进啥的
大佬,有没有群之类的什么,可以交流比较方便的?下面的人有问题也可以去群里面问啊。。。。
么得群,一般有问题的话,是先建议百度/谷歌