使用rclone挂载无限容量的googleDrive到本地磁盘并使用plex搭建家庭影院
摘要
文章前说明:
GoogleDrive是谷歌提供的云盘服务
GoogleDrive需要VPN才可以连接
GoogleDrive教育网邮箱注册的用户可以拥有无限容量的网盘空间
教育邮箱可以和学校要,注册方法:https://zhuanlan.zhihu.com/p/35953039
没有教育邮箱的童鞋,可以百度:超详细免费申请无限容量的谷歌云盘Google Drive
rclone挂载
安装rclone
# debian ubuntuapt-get install wget -y && wget https://www.uud.me/usr/shell/rclone_debian.sh && bash rclone_debian.sh# centoscurl https://rclone.org/install.sh | sudo bash
配置Rclone
rclone config
No remotes found - make a new one n) New remote s) Set configuration passwordq) Quit confign/s/q> n #输入nname> 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 IdSetting 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 #输入1ID of the root folder Leave blank normally. Fill in to access "Computers" folders (see docs), or for rclone to usea non root folder as its starting point. Note that if this is blank, the first time rclone runs it will fill itin 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) Yesn) Noy/n> n #输入nRemote configUse auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yesn) Noy/n> n #输入nIf 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=tZzSXMvZc8iu0lYFB4ANBwLog in and authorize rclone for accessEnter verification code> #打开以上链接,登录要绑定的Google,此处输入活动的Code Configure this as a team drive? y) Yesn) Noy/n> y #如果你的是团队盘,则输入y,否则nFetching team drive list...Choose a number from below, or type in your own value 1 / 幽游地资源收集 \ "0AMp-QeDCIy_mUk9PVA"Enter a Team Drive ID> 1 #如果是团队盘,输入序号--------------------[gdrive]type = drivescope = 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 OKe) Edit this remoted) Delete this remote y/e/d> y #输入yCurrent remotes:Name Type==== ==== gdrive drivee) Edit existing remoten) New remoted) Delete remote r) Rename remotec) Copy remote s) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q #绑定完成后输入q退出,如果要继续绑定,输入y重复以上步骤
挂载为磁盘
mkdir -p /home/gdrive #创建需要映射的目录rclone mount gdrive: /home/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes #gdrive为你的配置名称(最开始输入的姓名)#/home/gdrive对应你本地映射的目录
可能出现的问题
Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
解决方法:
# Debian/Ubuntuapt-get install fuse# CentOSyum install fuse
输入 df -h
可以查看挂载的硬盘
开机自启
新建一个rclone.service文件
vi /usr/lib/systemd/system/rclone.service
写入
[Unit]Description = rclone[Service]User = rootExecStart = /usr/bin/rclone mount gdrive: /root/GoogleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000Restart = on-abort[Install]WantedBy = multi-user.target
重载daemon,让新的服务文件生效
systemctl daemon-reload
设为开机自启
systemctl enable rclone
若需要映射多个网盘
新建/etc/systemd/system/rclone@.service 文件
vi /etc/systemd/system/rclone@.service
写入
# cat /etc/systemd/system/rclone@.service[Unit]Description=rclone mount %I driveAfter=network.target [Service]#Type=notifyType=simple#PrivateTmp=trueExecStart=/usr/bin/rclone mount %i: /home/%i --allow-other --config /root/.config/rclone/rclone.conf#/home/%i 为挂载路径,你也可以设置为其他,如/root/%i [Install]WantedBy=multi-user.target
启动命令
for a in `grep '^\[' /root/.config/rclone/rclone.conf`do b=${a:1:-1} [ ! -d "/home/${b}" ] && mkdir /root/${b} systemctl enable rclone@${b} systemctl start rclone@${b}done
重载daemon,让新的服务文件生效
systemctl daemon-reload
设为开机自启
systemctl enable rclone
安装plex家庭影音服务
安装plex
打开 https://www.plex.tv/media-server-downloads/#plex-media-server
选择对应的系统版本,复制链接,并使用wget下载到本地
如
wget https://downloads.plex.tv/plex-media-server-new/1.19.4.2865-4fa317f77/debian/plexmediaserver_1.19.4.2865-4fa317f77_amd64.deb
安装:
# Debian/Ubuntusudo dpkg -i fileName.deb #fileName对应刚刚下载的包名# CentOSrpm -ivh fileName.rpm #fileName对应刚刚下载的包名
配置plex
首次配置Plex时,必须通过127.0.0.1:32400/web或localhost:32400/web访问Plex
重定向登录:
无脑下一步,但是到这一步注意要打开允许家庭外访问:
添加媒体库中路径选择我们刚刚映射到本地的路径就可以愉快的让googleDrive中的文件成为我们的家庭影院了
评论(0)