说明:我们很多人喜欢用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/
博主,使用rclone挂载网盘,然后复制本地文件到这个挂载盘地址的效果和使用rclone copy直接复制本地文件到网盘的效果一样吗?
使用第一种方式一直复制文件会不会让vps存储空间爆炸?
这种其实差不多的,不过挂载更方便些,还可以直接用服务器做中转直接下载/观看,但有点消耗资源内存啥的,爆炸倒不会,只见过因为内存小而挂掉的。
macOS怎么用rclone挂载gd到本地?不知道路径在哪里
macos还没试过,方法应该都差不多,你可以看下官方文档。https://rclone.org/install/
你好,博主挂无限空间是不是要管理员的账户才可以,被管理员拉进去的成员账户不行吗?
不需要管理员账户
你好,问一下第3步,新建本地文件夹的名字,可以是中文吗?
没试过中文,你可以尝试下
请问我敲完挂载命令后回车,然后终端工具就没有任何提示,没有报错什么的,就是回车后等待刷新出命令那种状态。这是什么原因呢?难道我虚拟机的磁盘空间不够?(这次我在虚拟机上运行的。Debian9.9)
额外再开个窗口使用df -h看下挂上了没
经过我多次测试,假死后等个10几秒,断开重连就显示挂载了,当然screen也应该可以。
我发下一个问题,我挂载了webdev 但是挂载之后 上传到我原来网盘的东西不同步,
是不是意味着我以后上传没办法再原始网盘中上传了
只能通过vps这个地址 上传。
我的意思是我可以上传到原来网盘,然后自动同步过来吗?
应该来说是通的,网盘那边的文件和vps挂载的文件夹可以互相上传,前提要有权限啥的
但是我现在遇到了问题,我挂载的硬盘,现在不能读写,可是我已经chmod777了
好像是挂载的时候选择的权限吧?
挂载完成后,用了几天,突然显示我5T的onedrive用了1019T容量,实际上我通常就用了1、2G左右。但又不影响正常使用。什么鬼。
这个应该计数出现了问题,不影响使用
root@LsyIuAn:~# #新建本地文件夹,路径自己定,即下面的LocalFolder
root@LsyIuAn:~# mkdir /root/GoogleDrive
mkdir: cannot create directory ‘/root/GoogleDrive’: File exists
root@LsyIuAn:~# #挂载为磁盘
root@LsyIuAn:~# rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
2019/04/22 13:55:29 Failed to create file system for "DriveName:Folder": didn't find section in config file
哥,这是啥情况哇
参数填对,别直接复制DriveName:Folder LocalFolder
root@LsyIuAn:~# rclone mount Lsy:VPS GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
参数调对啦,回车之后没反应=-=
没反应一般就可以了,你使用df -h查看下
root@LsyIuAn:~# rclone mount Lsy:VPS GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
root@LsyIuAn:~2019/04/25 22:52:59 mount helper error: fusermount: failed to access mountpoint /root/GoogleDrive: Transport endpoint is not connected
2019/04/25 22:52:59 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
这个GoogleDrive换成绝对路径
而且我发现教育办的都没有API权限qwq
是的,除非是管理员才有权限
怎么换成绝对路径哇0.0
比如你在主目录,也就是root目录新建GoogleDrive文件夹,那绝对路径就是/root/GoogleDrive
root@LsyIuAn:~# apt install fuse -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
fuse is already the newest version (2.9.7-1+deb9u2).
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
我执行了命令~~~
root@laulzgoay:~# mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
2019/04/20 06:22:23 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
安装下fuse,apt install fuse -y,如果你是ovz的话,可能还需要工单要主机商给你开通fuse
是ovz
那发工单要主机商开下
[root@srttgglsy ~]# curl https://rclone.org/install.sh | sudo bash
Dload Upload Total Spent Left Speedsudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /usr/libexec/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins
% Total % Received % Xferd Average Speed Time Time Time Current
100 4276 100 4276 0 0 6907 0 --:--:-- --:--:-- --:--:-- 6896
curl: (23) Failed writing body (220 != 400)
试试curl -sL https://rclone.org/install.sh | sudo bash
[root@srttgglsy ~]# curl -SsL https://rclone.org/install.sh | sudo bash
sudo: /etc/sudo.conf is owned by uid 1000, should be 0
sudo: /usr/libexec/sudoers.so must be owned by uid 0
sudo: fatal error, unable to load plugins
curl: (23) Failed writing body (220 != 400)
还是不行,我的VPS是OVZ=-=
开了fuse的ovz也是可以用的
Updating index cache for path `/usr/local/share/man/man8'. Wait...done.
Checking for stray cats under /usr/local/share/man...
Checking for stray cats under /var/cache/man/local...
104 man subdirectories contained newer manual pages.
14767 manual pages were added.
0 stray cats were added.
0 old database entries were purged.
联系客服开了fuse 没复制完全,这是最后几行,我是ovz centos7
这个貌似与mandb有关系,你可以谷歌下,或者换个系统