UOS将阿里云盘挂载到本地
越来越火的阿里云盘
最近这段时间最火的云盘当属阿里云盘了,不限速,又有大量的扩容活动以及不定期发放的扩容福利码,让普通用户也可以拥有大量的云盘空间供使用,特别是当CloudDrive这个神器的出现,可以将云盘挂载为本地磁盘的样子,可以像操作本地硬盘中的文件一样来进行云盘文件的操作,别提有多方便了,阿里云盘不限速的承诺,让这个功能有了更好的使用条件。
喜欢存储蓝光电影的同学,即使云盘app中可以投屏,但是一些多音轨硬字幕的视频文件,在app以及投屏中都无法进行切换,网上说kodi可以切换,经过测试无法切换;但是将云盘挂载到本地,再使用kodi进行播放就完全没有问题了。利用家里的nas服务器挂载云盘,使用kodi媒体库连接,可以刮削影片图片简介信息,一个家庭影院播放系统基本就完成了。
越说越兴奋,接下来就是进行挂载的操作说明了。
百度大部分教程都是讲的Windows使用CloudDrive将阿里云盘挂载为本地磁盘,CloudDrive Linux版本需要安装宝塔面板再部署网页程序去挂载,中间出现的问题较多。
偶然之间在一个blog中看到使用了webdav的方式进行挂载,操作简单方便,但是该blog不稳定,经常打不开,所以在这里做个记录。
Webdav协议
感谢zxbu大神,实现了阿里云盘的webdav协议,只需要简单的配置一下,就可以让阿里云盘变身为webdav协议的文件服务器。 基于此,你可以把阿里云盘挂载为Windows、Linux、Mac系统的磁盘,可以通过NAS系统做文件管理或文件同步
项目地址: https://github.com/zxbu/webdav-aliyundrive
在项目地址中介绍了使用方式,可以jar包运行,需要自行编译后再进行操作;也可以使用docker进行管理,一次性部署完成。
接下来使用比较简单的方式。
1、安装docker服务,
使用新版UOS的同学可以直接使用下边命令进行安装。(因为Beta6以及公测版蓝牙驱动配置的问题,我用的是Beta5)
sudo apt install docker-ce
使用其它版本无法直接安装的,参考百度内容进行安装
2、在docker中安装zx5253/webdav-aliyundriver
docker run -d --name=webdav-aliyundriver --restart=always -p 8080:8080 -v /etc/localtime:/etc/localtime -v /etc/aliyun-driver/:/etc/aliyun-driver/ -e TZ="Asia/Shanghai" -e ALIYUNDRIVE_REFRESH_TOKEN="your refreshToken" -e ALIYUNDRIVE_AUTH_PASSWORD="admin" -e JAVA_OPTS="-Xmx1g" zx5253/webdav-aliyundriver
# /etc/aliyun-driver/ 挂载卷自动维护了最新的refreshToken,建议挂载
# ALIYUNDRIVE_AUTH_PASSWORD 是admin账户的密码,建议修改
# JAVA_OPTS 可修改最大内存占用,比如 -e JAVA_OPTS="-Xmx512m" 表示最大内存限制为512m
--aliyundrive.refresh-token
阿里云盘的refreshToken,登录网页版 按f12打开控制台—application—local storage—token,即可查看refresh token
--server.port
非必填,服务器端口号,默认为8080
--aliyundrive.auth.enable=true
是否开启WebDav账户验证,默认开启
--aliyundrive.auth.user-name=admin
WebDav账户,默认admin
--aliyundrive.auth.password=admin
WebDav密码,默认admin
--aliyundrive.work-dir=/etc/aliyun-driver/
token挂载路径(如果多开的话,需修改此配置)
如果只是使用kodi等播放器播放视频,到这里就可以连接到webdav服务了,需要挂载磁盘的接着看下边的内容
3、安装配置rclone客户端
#安装 rclone
curl https://rclone.org/install.sh | sudo bash
#安装完成后,运行rclone连接webdav完成配置
rclone config
#配置过程代码,参考着一步一步来
#name请自行替换
#密码需要输入两遍进行确认,建议上面运行webdav程序的时候不设置密码或使用默认密码
[root@localhost yum.repos.d]# rclone config
2021/08/12 16:28:35 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> aliyunwebdav
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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Citrix Sharefile
\ "sharefile"
9 / Compress a remote
\ "compress"
10 / Dropbox
\ "dropbox"
11 / Encrypt/Decrypt a remote
\ "crypt"
12 / Enterprise File Fabric
\ "filefabric"
13 / FTP Connection
\ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
15 / Google Drive
\ "drive"
16 / Google Photos
\ "google photos"
17 / Hadoop distributed file system
\ "hdfs"
18 / Hubic
\ "hubic"
19 / In memory object storage system.
\ "memory"
20 / Jottacloud
\ "jottacloud"
21 / Koofr
\ "koofr"
22 / Local Disk
\ "local"
23 / Mail.ru Cloud
\ "mailru"
24 / Mega
\ "mega"
25 / Microsoft Azure Blob Storage
\ "azureblob"
26 / Microsoft OneDrive
\ "onedrive"
27 / OpenDrive
\ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
29 / Pcloud
\ "pcloud"
30 / Put.io
\ "putio"
31 / QingCloud Object Storage
\ "qingstor"
32 / SSH/SFTP Connection
\ "sftp"
33 / Sugarsync
\ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
35 / Transparently chunk/split large files
\ "chunker"
36 / Union merges the contents of several upstream fs
\ "union"
37 / Uptobox
\ "uptobox"
38 / Webdav
\ "webdav"
39 / Yandex Disk
\ "yandex"
40 / Zoho
\ "zoho"
41 / http Connection
\ "http"
42 / premiumize.me
\ "premiumizeme"
43 / seafile
\ "seafile"
Storage> 38
URL of http host to connect to
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Connect to example.com
\ "https://example.com"
url> http://127.0.0.1:8080
Name of the Webdav site/service/software you are using
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Nextcloud
\ "nextcloud"
2 / Owncloud
\ "owncloud"
3 / Sharepoint Online, authenticated by Microsoft account.
\ "sharepoint"
4 / Sharepoint with NTLM authentication. Usually self-hosted or on-premises.
\ "sharepoint-ntlm"
5 / Other site/service or software
\ "other"
vendor> 5
User name. In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a string value. Press Enter for the default ("").
user> admin
Password.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank (default)
y/g/n> y
Enter the password:
password:
Confirm the password:
password:
Bearer token instead of user/pass (e.g. a Macaroon)
Enter a string value. Press Enter for the default ("").
bearer_token>
Edit advanced config?
y) Yes
n) No (default)
y/n>
--------------------
[aliyunwebdav]
type = webdav
url = http://127.0.0.1:8080
vendor = other
user = admin
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
Current remotes:
Name Type
==== ====
aliyunwebdav webdav
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
4、挂载webdav到本地
#新建本地文件夹,位置可以自己选
mkdir /data/aliyunwebdav
#挂载
rclone mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty
DriverName是你在配置rclone的时候设置的名字,Folder没有需要求的话填/即可,LocalFolder是你本地挂载的地址,/tmp比较特殊,上传时缓存目录,其他类型挂载一般时不需要这个参数的,默认/tmp地址即可,除非你的系统特殊。
执行完之后即可访问本地挂载的文件夹查看文件了.
5、设置开机自动挂载
#将后面修改成你上面手动运行命令中,除了rclone的全部参数
command="mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty"
#以下是一整条命令,一起复制到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