说明:我们很多人喜欢用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/
2019/03/26 21:36:40 mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
2019/03/26 21:36:40 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
服务商说开了fuse
开了的话,有没有安装fuse
安装了
Apt-ge5 install fuse
安装的时候有安装信息输出吗?还有重启下服务器看看
root@canon:~# apt-get install fuse Reading package lists... Done
Building dependency tree
Reading state information... Done
fuse is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 151 not upgraded.
root@canon:~# rclone mount 1: /root/Download --allow-other --allow-non-empty --vfs-cache-mode writes
2019/03/28 19:47:44 mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
2019/03/28 19:47:44 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
root@canon:~#
你这个挂载参数看起来怎么是个错的
root@canon:~# rclone mount 1: /root/Download --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
2019/03/30 02:22:24 mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
2019/03/30 02:22:24 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
root@canon:~#
这个你发工单问下,说你安装fuse,却加载不了
我name是 GD,谷歌网盘里的文件夹是VPS,小鸡上的文件夹是/root/GoogleDrive
那我用的代码是
rclone mount GD:/VPS /root/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
这个有没有问题?
现在用这个代码不行,Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
怎么回事?
如果你是ovz需要发工单开启fuse,kvm需要使用命令。
Debian/Ubuntu系统apt-get install fuse -y
CentOS系统yum install fuse -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-headers-4.12.9-041209-generic : Depends: libssl1.0.0 (>= 1.0.0) but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
KVM的,好像无法开启
可以的,你谷歌下,只要把fuse装上就行了
我想把一个GD挂两个位置,一下是读写权限给PT用,一个是只读权限给EMBY用,挂载没问题
我想问那个自启文件什么怎么编辑.
挂载后,别直接当成下载盘,会出问题,只能移动进去,开机自启可以参考这个文章https://www.moerats.com/archives/870/,单独建2个文件,rclone1和rclone2就可以了管理了。
你https://www.moerats.com/archives/870/说的是在/etc/systemd/system下建两个文件没问题.
我这边已经按上面 教程操作了/etc/init.d/ 下的自启,那rclone文件直接删掉就行了是吗?
对,这个不需要了。
你好,按照你的教程成功挂载了google drive,问一下我用winscp连上主机下载google drive挂载的文件的时候,数据流是:google drive->我的主机->我的电脑么,这样是不是消耗了进站和出站双倍的的流量
按理说是这样的,需要消耗双倍流量,不过很多只算单向的服务器可以无视
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
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和3最后提示Failed to create file system for "DriveName:/ero": didn't find section in config file,哪里出错了
这个一般是权限问题,选择1就可以了,后面的没配置了很多次都没遇到过,你重新配置看看,步骤不要错
NOTICE: Time may be set wrong - time from "www.googleapis.com" is -22m47.343563393s different from this computer
时间要怎么调?
调时间的话,百度一下
请问下:Error while copying file to target location (copied bytes: 0, expected filesize: 3422507 )
重新复制看看
博主,请问下,您试过最近一个月内重新挂在过吗?按照您的方法,试了几个gmail账号,最后虽然都挂载成功了,但却都无法使用,均出现一个问题,就是Error while copying file to target location。求解!!!
按照您的指导一步一步安装好了,显示是绿√,文件里也有了一个目录。就是:①gd那边上传文件后,在nc相应文件夹里没有任何文件;②在nc对应的文件夹里上传资料,就显示上面的复制文件到目标位置错误;③以为是设置时哪里出了问题,我设置了几遍,重新登录后台,发现有3个外挂谷歌盘,内存显示都一样。(另外,特别想请问下,DriveName:Folder LocalFolder这行命令中的Folder ,是自己在谷歌云盘下创建的一个文件夹吧?) 感谢博主辛勤付出和帮助!
对,Folder就是网盘文件夹路径,如果你直接挂载根目录,那使用/就行了,如果是根目录的xx文件夹,那就使用/xx
老大 修改一下内容:以后如何保存并推出到下一步?谢谢
不会编辑命令的用ftp软件登录vps修改吧。
所有步骤都安装正确,挂载成功,也设置了自启,没有报错,就是重启后不会自启动,系统是ubuntu16.04
自启也可以参考这个文章https://www.moerats.com/archives/870/
同时挂载onedrive和google drive改怎么配置
一次挂一个看看,这是挂载onedrive教程:https://www.moerats.com/archives/491/。
开机 rclone 启动失败,有办法吗
什么系统?办法肯定是有的,最不操心的办法就是换系统。
用的是armbian,用的设备的是斐讯N1盒子。
这个没玩过,不是很清楚。