CENTOS服务器rclone自动挂载谷歌相册Google photo rclone将谷歌相册挂载为磁盘
谷歌相册分配给每个用户的空间都是无限的,那有没有办法将他挂载到我们服务器当成一个磁盘来存储呢?答案是可以!
步骤还是跟我们之前挂载磁盘类似:
安装EPEL源(这一步国外VPS一般可不用操作):
yum -y install epel-release
安装一些基本组件和依赖:
yum -y install wget unzip screen fuse fuse-devel
下载Rclone解压然后进入目录:(64位系统就下载rclone-current-linux-amd64.zip,32位系统就下载rclone-current-linux-386.zip替换下面代码中的链接就行了)
wget https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cd rclone-v*
注意cd rclone-v*这一步如果系统执行出错,你可以输入ls命令查看一下具体目录名,因为这个是使用最新版本,版本号不一定一样,然后根据真实的目录cd 进去一下
接下来运行Rclone开始配置:
./rclone config
第一步选择n,
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> n
然后回车输入一个name,建议这个name设置的简单好记一点,比如我们这边叫gp这个下面会用到如下所示:
name> gp
下面选择挂载类型-谷歌相册,数字顺序可能会变,记得选google photo的项目
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> 13
下面三个选项留空,直接回车
** See help for google photos backend at: https://rclone.org/googlephotos/ **
Google Application Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
Google Application Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Set to make the Google Photos backend read only.
If you choose read only then rclone will only request read only access
to your photos, otherwise rclone will request full access.
Enter a boolean value (true or false). Press Enter for the default ("false").
read_only>
下面两项选n
Edit advanced config? (y/n)
y) Yes
n) No
y/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
这里会给出一个让你访问授权的网址,把它复制出来贴浏览器访问,然后一路下一步,会给你返回一串验证码
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=****evjaotbpbab1*.apps.googleusercontent.com&redirect_uri=u***Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fphotoslibrary&state=****
Log in and authorize rclone for access
把给你的验证码贴这里
Enter verification code> *******dsadfddsdfdsfdf
*** IMPORTANT: All media items uploaded to Google Photos with rclone
*** are stored in full resolution at original quality. These uploads
*** will count towards storage in your Google Account.
这一步选y
--------------------
[gp]
type = google photos
token = {"access_token":"*******"}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
gp google photos
onedrive onedrive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
这一步选q退出
e/n/d/r/c/s/q> q
然后挂载,还是先创建一个本磁盘,用于映射
[root@www rclone-v1.49.5-linux-amd64]# mkdir -p /gp
手工挂载的话,输入下面命令
[root@www rclone-v1.49.5-linux-amd64]# ./rclone mount gp: /gp --allow-other --allow-non-empty --vfs-cache-mode writes
需要开机自动挂载的话,继续往下看
先把rclone的可执行文件复制到/usr/bin:
cp /root/rclone-v*/rclone /usr/bin/rclone
新建一个rclonegp.service文件:
vi /usr/lib/systemd/system/rclonegp.service
写入:
[Unit] Description=rclonegp [Service] User=root ExecStart=/usr/bin/rclone mount gp: /gp --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 rclonegp
设置开机启动:
systemctl enable rclonegp
停止、查看状态可以用:
systemctl stop rclonegp systemctl status rclonegp
重启你的VPS,然后查看一下rclone的服务起来没,接着查看一下盘子挂上去没:
reboot systemctl status rclonegp df -h
到这里就完成了