当前位置: 首页 > 淘宝 > 正文

Debian10使用rclone挂载Google云端硬盘网盘

通过Rclone挂载Google Drive无限容量的团队盘,也可以方便地将独服里下载的影片,传输到GD盘,此处简单记录下Rclone的设置挂载过程

安装Rclone

一条命令解决:

curl https://rclone.org/install.sh | sudo bash

配置克隆

安装完成后,配置rclone

rclone config

配置克隆

安装完成后,配置rclone:

No remotes found - make a new one
 n) New remote
 s) Set configuration password
 q) Quit config
 n/s/q> n #输入n
 name> gdrive  #名称随便填
 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 / Citrix Sharefile
    \ "sharefile"
  9 / Dropbox
    \ "dropbox"
 10 / Encrypt/Decrypt a remote
    \ "crypt"
 11 / FTP Connection
    \ "ftp"
 12 / Google Cloud Storage (this is not Google Drive)
    \ "google cloud storage"
 13 / Google Drive
    \ "drive"
 14 / Google Photos
    \ "google photos"
 15 / Hubic
    \ "hubic"
 16 / JottaCloud
    \ "jottacloud"
 17 / Koofr
    \ "koofr"
 18 / Local Disk
    \ "local"
 19 / Mail.ru Cloud
    \ "mailru"
 20 / Mega
    \ "mega"
 21 / Microsoft Azure Blob Storage
    \ "azureblob"
 22 / Microsoft OneDrive
    \ "onedrive"
 23 / OpenDrive
    \ "opendrive"
 24 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
    \ "swift"
 25 / Pcloud
    \ "pcloud"
 26 / Put.io
    \ "putio"
 27 / QingCloud Object Storage
    \ "qingstor"
 28 / SSH/SFTP Connection
    \ "sftp"
 29 / Transparently chunk/split large files
    \ "chunker"
 30 / Union merges the contents of several remotes
    \ "union"
 31 / Webdav
    \ "webdav"
 32 / Yandex Disk
    \ "yandex"
 33 / http Connection
    \ "http"
 34 / premiumize.me
    \ "premiumizeme"
 Storage> 13 #选择13,google drive
 ** See help for drive backend at: https://rclone.org/drive/ **
 Google Application Client Id
 Setting your own is recommended.
 See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
 If you leave this blank, it will use an internal key which is low performance.
 Enter a string value. Press Enter for the default ("").
 client_id>  #留空
 Google Application Client Secret
 Setting your own is recommended.
 Enter a string value. Press Enter for the default ("").
 client_secret>   #留空
 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 #输入1
 ID of the root folder
 Leave blank normally.
 Fill in to access "Computers" folders (see docs), or for rclone to use
 a non root folder as its starting point.
 Note that if this is blank, the first time rclone runs it will fill it
 in with the ID of the root folder.
 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/oauth2/auth?access_type=offline&client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=tZzSXMvZc8iu0lYFB4ANBw
 Log in and authorize rclone for access
 Enter verification code>  #打开以上链接,登录要绑定的Google,此处输入活动的Code
 Configure this as a team drive?
 y) Yes
 n) No
 y/n> y   #如果你的是团队盘,则输入y,否则n
 Fetching team drive list…
 Choose a number from below, or type in your own value
 1 / owejoij
 \ "0AMp-QeDCIy_mUk9PVA" 
 Enter a Team Drive ID> 1 #如果是团队盘,输入序号
 [gdrive]
 type = drive
 scope = drive
 token = {"access_token":"ya29.Il-2B5z7OPWyx59ZHw7__IemaHsR8VT7P__jUN27hnNXZtaj0Rk1HcWPGGt2xqjkJH3e2KaVWuwz1nvW20MT0rfmEd5XAMY-je7wzQWgdjuGaBn9-txOUGh2jkk_CYio2w","token_type":"Bearer","refresh_token":"1//03yKvDZ7SOc80CgYIARAAGAMSNwF-L9Irrptm9elmrbRA1jxPeBsodd2FZw0TG5Utj5dUXeEDxKgZcR2EkYy1D0_wpsWsmgCWDzg","expiry":"2019-12-24T03:17:54.135381482-05:00"}
 team_drive = 0AMp-QeDCIy_mUk9PVA
 y) Yes this is OK
 e) Edit this remote
 d) Delete this remote
 y/e/d> y #输入y
 Current remotes:
 Name                 Type
 ====                 ====
 gdrive               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退出,如果要继续绑定,输入y重复以上步骤

挂载为磁盘

mkdir /root/GoogleDrive #创建用于挂载的路径 即下面的 LocalFolder
rclone mount DriveName:Folder LocalFolder –copy-links –no-gzip-encoding –no-check-certificate –allow-other –allow-non-empty –umask 000 #进行挂载,参数解释看下方

DriveName为初始化配置时随便填写的名称

文件夹为谷歌硬盘里的文件夹路径

LocalFolder为刚刚创建的目录

不会改的,直接保持和我的路径一样,直接复制下面代码:

mkdir /root/GoogleDrive
rclone mount gdrive: /root/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

以上这个示例中,文件夹为空,显示挂载Google Drive所有目录文件

如果挂在目录创建在/root下可能跟后期其他用户例如emby,jillyfin,Aria2等使用不方便,所以我们最好是直接创建在根目录之下,方便全权限分配。代码如下:

mkdir /GoogleDrive
rclone mount gdrive: /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

解决:

# Debian/Ubuntu
apt-get install fuse
# CentOS
yum install fuse

输入df -h查看挂载的硬盘:

开机自启

按照下列路径新建一个rclone.service文件:

nano /usr/lib/systemd/system/rclone.service

写入:

[Unit]
Description = rclone

[Service]
User = root
ExecStart = /usr/bin/rclone mount gdrive: /root/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
Restart = on-abort

[Install]
WantedBy = multi-user.target

重载daemon,让新的服务文件生效:

systemctl daemon-reload

设置开机启动:

systemctl enable rclone

停止,查看状态可以用:

systemctl stop rclone 
systemctl status rclone

完毕

如果重启不能自动启动:

#以下是一整条命令,一起复制到SSH客户端运行

#将后面修改成你上面手动运行命令中,除了rclone的全部参数 
command="mount gdrive:/root/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000" 

 cat > /usr/lib/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

创建完成后给emby,Aria2等用户/GoogleDrive 文件夹的读写权限。命令如下:

chown -R emby /GoogleDrive/
chmod 775 /GoogleDrive/

如果没问题的话此时你的 emby,Aria2 都可以指定/GoogleDrive/为工作文件夹。

本文固定链接: https://www.eoowo.com/?p=1081 | 火星博客

该日志由 Rainer 于2020年10月29日发表在 淘宝 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: Debian10使用rclone挂载Google云端硬盘网盘 | 火星博客

Debian10使用rclone挂载Google云端硬盘网盘:等您坐沙发呢!

发表评论

CAPTCHAis initialing...
快捷键:Ctrl+Enter