rclone和alist挂载网盘到本地

528次阅读
没有评论

共计 6294 个字符,预计需要花费 16 分钟才能阅读完成。

参考https://willxup.top/archives/deploy-alist-and-rclone

  alist

最近折腾家庭存储这块时,感觉大多数文件都在,这些公共网盘里,各种APP特别麻烦,所以想把所有不同的网盘都放在一起进行管理,一直听说的大名,还没有用过,这次就来试试。

  地址:https://github.com/alist-org/alist

  主页:https://alist.nn.ci/

docker部署alist

  我是使用进行部署,的安装方法参考部署docker及docker-compose。那么第一步,创建文件:

version: '3.2'

services:
  alist:
    image: xhofe/alist
    container_name: alist
    restart: unless-stopped
    volumes:
      - /docker/alist:/opt/alist/data
    environment:
      PUID: 0
      PGID: 0
      UMASK: 022
    ports:
      - "8080:5244"

  宿主机使用8080端口转发到alist的端口,宿主机/docker/alist目录映射alist的目录

# 启动alist容器
docker-compose up -d

  启动后,访问ip+port即可,不过我们还没有alist的默认密码,alist的默认账号为:admin,执行以下命令获取默认密码:

docker exec -it alist ./alist admin

alist设置

  可以在个人资料里修改用户名和密码

  想要挂载不同的网盘,点击侧边栏的存储,进入设置,详细的设置方式alist官方文档有教程可以参考,因为不同的网盘有不同的方式,这里就不赘述,只需要跟着官方文档的配置方式即可。

  设置签名,只有带有签名的链接才可以访问。alist -> 设置 -> 全局 -> 签名所有 开启

rclone

在设置好alist之后,因为alistwebdav的形式,jellyfin是没办法直接读取的,所以需要将alist挂载到本地,供jellyfin使用。

  地址:https://github.com/rclone/rclone

  主页:https://rclone.org

安装rclone

  安装rclone我没有使用docker进行部署,主要是因为要挂载在宿主机上,来回映射路径相对来说比较麻烦。所以我就根据rclone的官方教程进行安装:

  安装依赖

# Ubuntu系统使用apt安装
apt-get install fuse3 -y
# centos系统使用yum安装
yum install fuse3 -y

二进制文件安装

# 创建rclone目录
mkdir /opt/rclone

# 进入该目录
cd /opt/rclone

# 下载rclone预编译二进制文件压缩包

# 这里如果服务器下载慢,可以用你的电脑下载好传到服务器解压使用。一样用法
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip

# 解压
unzip rclone-current-linux-amd64.zip

# 进入解压目录
cd /opt/rclone/rclone-v1.64.0-linux-amd64

# 将rclone二进制文件放入/usr/bin目录下
cp rclone /usr/bin/

# 授权
chmod 755 /usr/bin/rclone

# 验证是否成功,显示版本号证明成功
rclone --version

设置rclone

要将alist挂载到本地,先要设置rclone remoterclone文档说的比较清晰,可以跟着以下命令进行操作:

root@123# rclone config     #rclone设置配置文件命令
2023/09/24 17:54:23 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     #这里输入n 新建。如果不明白英文意思可复制去翻译

Enter name for new remote.

name> 阿里云    #你的rclone配置文件名

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, China Mobile, Cloudflare, GCS, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Leviia, Liara, Lyve Cloud, Minio, Netease, Petabox, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Synology, Tencent COS, Qiniu and Wasabi
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Combine several remotes into one
   \ (combine)
12 / Compress a remote
   \ (compress)
13 / Dropbox
   \ (dropbox)
14 / Encrypt/Decrypt a remote
   \ (crypt)
15 / Enterprise File Fabric
   \ (filefabric)
16 / FTP
   \ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
18 / Google Drive
   \ (drive)
19 / Google Photos
   \ (google photos)
20 / HTTP
   \ (http)
21 / Hadoop distributed file system
   \ (hdfs)
22 / HiDrive
   \ (hidrive)
23 / In memory object storage system.
   \ (memory)
24 / Internet Archive
   \ (internetarchive)
25 / Jottacloud
   \ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
27 / Local Disk
   \ (local)
28 / Mail.ru Cloud
   \ (mailru)
29 / Mega
   \ (mega)
30 / Microsoft Azure Blob Storage
   \ (azureblob)
31 / Microsoft OneDrive
   \ (onedrive)
32 / OpenDrive
   \ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
   \ (swift)
34 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
35 / Pcloud
   \ (pcloud)
36 / PikPak
   \ (pikpak)
37 / Proton Drive
   \ (protondrive)
38 / Put.io
   \ (putio)
39 / QingCloud Object Storage
   \ (qingstor)
40 / Quatrix by Maytech
   \ (quatrix)
41 / SMB / CIFS
   \ (smb)
42 / SSH/SFTP
   \ (sftp)
43 / Sia Decentralized Cloud
   \ (sia)
44 / Storj Decentralized Cloud Storage
   \ (storj)
45 / Sugarsync
   \ (sugarsync)
46 / Transparently chunk/split large files
   \ (chunker)
47 / Union merges the contents of several upstream fs
   \ (union)
48 / Uptobox
   \ (uptobox)
49 / WebDAV
   \ (webdav)
50 / Yandex Disk
   \ (yandex)
51 / Zoho
   \ (zoho)
52 / premiumize.me
   \ (premiumizeme)
53 / seafile
   \ (seafile)
Storage> 49    #这里就是让你选择协议吧,我也不明白意思你也可以输入webdav

Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a value.
url> http://127.0.0.1/dav/    ##这里设置alist的地址和端口,后面要带dav,这是alist要求的

Option vendor.
Name of the WebDAV site/service/software you are using.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Fastmail Files
   \ (fastmail)
 2 / Nextcloud
   \ (nextcloud)
 3 / Owncloud
   \ (owncloud)
 4 / Sharepoint Online, authenticated by Microsoft account
   \ (sharepoint)
 5 / Sharepoint with NTLM authentication, usually self-hosted or on-premises
   \ (sharepoint-ntlm)
 6 / Other site/service or software
   \ (other)
vendor> 6   # 这里选6就可以了,1-5都不是我们使用的

Option user.
User name.
In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a value. Press Enter to leave empty.
user> admin #这里是你alist的密码

Option pass.# 设置远程密码
Password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y  #这里输入y
Enter the password: #这输入你的密码,密码是看不到的
password:
Confirm the password: #再次输入你的密码
password:

Option bearer_token.
Bearer token instead of user/pass (e.g. a Macaroon).
Enter a value. Press Enter to leave empty.
bearer_token>    #这里直接回车

Edit advanced config?  #是否进入高级配置
y) Yes
n) No (default)
y/n> n  #选择N或者直接回车就行了

Configuration complete.
Options:
- type: webdav
- url: http://dav.yroot.site/
- vendor: other
- user: yang
- pass: *** ENCRYPTED ***
Keep this "阿里云" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y  #输入y即可,

Current remotes:

Name                 Type
====                 ====
阿里云                  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  # 最后按q退出设置

挂载rclone到本地

查看是否连接成功,使用以下命令可以确认是否已经挂载上了alist

# 查看alist的目录   alist: 等于配置文件里面的remote
rclone lsd 阿里云:

# 查看alist的文件  等于配置文件的remote
rclone ls 阿里云:
#新建本地文件夹
mkdir -p /data/aliyunpan
#挂载
rclone mount DriveName:Folder LocalFolder --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty

DriverName是你在配置rclone的时候设置的名字,Folder没有需要求的话填/即可,LocalFolder是你本地挂载的地址,/tmp比较特殊,上传时缓存目录,其他类型挂载一般时不需要这个参数的,默认/tmp地址即可,除非你的系统特殊
最终写成rclone mount 阿里云:/ /data/aliyunpan --cache-dir /tmp --allow-other --vfs-cache-mode writes --allow-non-empty

开机自动挂载

  上面的手动挂载方式,在机器重启后,就失效了,每次都要手动在设置一遍,很麻烦。我们可以使用文件来进行自动挂载。

设置service文件

#创建service文件
vim /usr/lib/systemd/system/rclone.service

  文件内容:

[Unit] 
Description=rclone 

[Service] 
User=root 
ExecStart=/usr/bin/rclone mount 阿里云:/ /data/aliyunpan --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --use-mmap
[Install] 
WantedBy=multi-user.target

上面文件内容mount alist: 根据自己的来修改 这个是挂载目录,

  设置开机自启

# reload守护进程
systemctl daemon-reload

# 设置service文件自启
systemctl enable rclone.service

# 启动service文件
systemctl start rclone.service

 


正文完
 
评论(没有评论)
验证码