侧边栏壁纸
博主昵称
流苏小筑

步伐虽小,密而不止

在Linux系统中使用alist和rclone将云盘挂载在本地系统

2025年04月16日 23阅读 0评论 0点赞

引言

随着云存储服务的普及,用户常常需要同时管理多个云盘(如阿里云盘、Google Drive、OneDrive 等)。如果能够将这些云存储统一挂载到本地文件系统,就能像操作本地文件一样直接访问云端数据,极大地提升效率。本文将通过 AList 和 Rclone 工具,手把手教你实现这一目标。

一、工具简介

1. AList 是什么?

AList官网
AList 是一个开源的 多存储文件列表程序,支持 20+ 种云存储服务,可以将不同云盘整合到统一的 Web 界面中,并通过 WebDAV 协议暴露接口。

2. Rclone 是什么?

Rclone官网
Rclone 是一个命令行工具,专为云存储设计,支持 挂载、同步、加密 等功能,能够将远程存储挂载为本地磁盘。


二、准备工作

Linux 发行版(如 Ubuntu/CentOS)
已安装 Docker 和 Docker Compose(用于运行 AList),这里使用docker,避免环境依赖版本问题。
终端操作权限


三、部署 AList 服务

1. 使用 Docker Compose 安装 AList

创建alist目录:

mkdir -p /home/choba/alist && cd /etc/alist
mkdir data
nano docker-compose.yml

粘贴以下内容:

services:
  alist:
    image: xhofe/alist:latest
    container_name: alist
    volumes:
      - './data:/opt/alist/data'
    ports:
      - '5244:5244'
    environment:
      - PUID=0
      - PGID=0
      - UMASK=022
      - TZ=Asia/Shanghai  # 设置时区(可选)
    restart: unless-stopped

启动容器:

docker compose up -d

2. 获取管理员密码

v3.25.0 及以上版本

  • 随机生成密码

    docker exec -it alist ./alist admin random
  • 手动设置密码(替换 NEW_PASSWORD):

    docker exec -it alist ./alist admin set NEW_PASSWORD

v3.25.0 以下版本

docker exec -it alist ./alist admin

3. 配置云存储

  1. 访问 http://服务器IP:5244/@login,使用管理员账号登录。
  2. 进入 「存储」「添加」 ,选择云盘类型(如阿里云盘),填写 Token 或 OAuth 配置。
  3. 保存后,AList 会通过 WebDAV 协议暴露存储路径(如 http://IP:5244/dav)。

四、使用 Rclone 挂载到本地

1. 安装 Rclone

# 一键安装脚本
curl https://rclone.org/install.sh | sudo bash

# 或者使用apt安装
sudo apt install rclone

2. 配置 Rclone 连接 AList 的 WebDAV

╭─     ~/rclone-v1.69.1-linux-amd64 ··············································· ✔  at 17:06:19   ─╮
╰─ rclone config                                                                                             ─╯

<5>NOTICE: Config file "/home/choba/.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

Enter name for new remote.
name> remote

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, Ceph, China Mobile, Cloudflare, ArvanCloud, Digital Ocean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, 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 / Microsoft Azure Blob Storage                                                                              
   \ (azureblob)                                                                                               
30 / Microsoft OneDrive                                                                                        
   \ (onedrive)                                                                                                
31 / OpenDrive                                                                                                 
   \ (opendrive)                                                                                               
32 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)                                             
   \ (swift)                                                                                                   
33 / Pcloud                                                                                                    
   \ (pcloud)                                                                                                  
34 / Put.io                                                                                                    
   \ (putio)                                                                                                   
35 / SMB / CIFS                                                                                                
   \ (smb)                                                                                                     
36 / SSH/SFTP                                                                                                  
   \ (sftp)                                                                                                    
37 / Sia Decentralized Cloud                                                                                   
   \ (sia)                                                                                                     
38 / Sugarsync                                                                                                 
   \ (sugarsync)                                                                                               
39 / Transparently chunk/split large files                                                                     
   \ (chunker)                                                                                                 
40 / Union merges the contents of several upstream fs                                                          
   \ (union)                                                                                                   
41 / Uptobox                                                                                                   
   \ (uptobox)                                                                                                 
42 / WebDAV                                                                                                    
   \ (webdav)                                                                                                  
43 / Yandex Disk                                                                                               
   \ (yandex)                                                                                                  
44 / Zoho                                                                                                      
   \ (zoho)                                                                                                    
45 / premiumize.me                                                                                             
   \ (premiumizeme)                                                                                            
46 / seafile                                                                                                   
   \ (seafile)                                                                                                 
Storage> webdav                                                                                                

Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a value.
url> http://192.168.0.196:5244/dav

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 / 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                                                                                                      

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

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
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

Configuration complete.
Options:
- type: webdav
- url: http://192.168.0.196:5244/dav
- vendor: other
- user: admin
- pass: *** ENCRYPTED ***
Keep this "remote" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

按提示操作:

  • 选择 n(新建存储)
  • 类型选 webdav
  • 名称填 remote(可自定义)
  • URL 填 http://IP:5244/dav
  • 用户名/密码填 AList 的管理员账号

3. 挂载云盘到本地目录

rclone mount remote:/Quark /home/choba/alist_mount \
  --copy-links \                # 解析符号链接
  --no-gzip-encoding \          # 禁用 GZIP 压缩
  --no-check-certificate \      # 跳过 SSL 验证(不安全!)
  --allow-non-empty \           # 允许非空目录挂载
  --umask 000 \                 # 开放所有权限
  --use-mmap                    # 内存映射优化

核心参数解析

参数作用说明适用场景注意事项
remote:/Quark指定远程存储的路径:
- remote: 预先配置的云存储名称(如 Alist、Google Drive 等)
- /Quark: 远程存储中的目录名
需要挂载特定目录而非根目录时使用确保 remote 已通过 rclone config 正确配置
/home/choba/alist_mount本地挂载点路径将远程存储映射到本地文件系统需提前创建目录并确保有写入权限
--copy-links解析符号链接为实际文件:
- 若远程存在软链接,直接复制其指向的真实文件
需要避免挂载时因符号链接导致路径无效可能增加首次挂载耗时
--no-gzip-encoding禁用 HTTP 传输时的 GZIP 压缩:
- 强制以原始格式传输数据
服务器不支持压缩或传输已压缩文件(如视频)时可能略微增加带宽占用
--no-check-certificate跳过 SSL/TLS 证书验证:
- 允许使用自签名证书或忽略证书错误
测试环境或内网中使用自签名证书时存在中间人攻击风险,生产环境慎用
--allow-non-empty允许挂载到非空目录:
- 默认情况下 rclone 禁止挂载到非空目录
挂载目录已存在其他文件需保留时需确保目录内文件不会被覆盖
--umask 000设置文件权限掩码:
- 000 表示所有用户(所有者、组、其他)拥有读写执行权限(777
需要完全开放挂载目录权限时安全性较低,建议改为 022 (755 权限)
--use-mmap启用内存映射(Memory Mapping)优化
- 利用系统内存加速大文件读写
处理大文件(如视频编辑、数据库文件)时可能增加内存占用,需系统支持

4. 验证挂载

# 查看挂载点内容
ls ~/alist_mount

若成功,会显示 AList 中配置的所有云盘目录。


五、实现开机自动挂载

1. 创建 systemd 服务文件

sudo nano /etc/systemd/system/rclone-remote.service

内容如下:

[Unit]
Description=rclone

[Service]
User=choba
ExecStart=/usr/bin/rclone mount remote:/Quark /home/choba/alist_mount --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --umask 000 --use-mmap

[Install]
WantedBy=multi-user.target

注:这里只使用choba账户,如果需要所有账户都能使用

# 允许其他用户访问(Linux 需配置 /etc/fuse.conf)
--allow-other \

Linux 系统需允许用户挂载 FUSE:

# 编辑 /etc/fuse.conf
sudo nano /etc/fuse.conf

取消注释:

user_allow_other

保存后重新登录用户。

2. 启用并启动服务

sudo systemctl daemon-reload
sudo systemctl enable rclone-remote
sudo systemctl start rclone-remote
0

—— 评论区 ——

昵称
邮箱
网址
取消