前言
通过ALits配合Rclone挂载网盘到VPS、NAS本地可以增加VPS、NAS的容量。
准备:
- 一个网盘(推荐123网盘)
- 一台VPS(至少2H4G)
为什么推荐123网盘?
123网盘的价格最便宜也是可以支持302重定向。(302重定向:ALits消耗的配置是网盘的而不是你服务器的)
为什么配置最小都要2H4G?
如果需要上传视频到网盘或者你使用的网盘不能302重定向的话,那么就需要服务器的配置较好。
安装AList
curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s install
其他安装方式:AList文档
添加存储
以夸克为例:
从请求中获取 Cookie 和根文件夹 ID:
方法:按F12打开“调试”,选中“网络”,找到一个以“sort”开头的文件即可找到
或者根目录id也可以从地址栏获取(根目录为0):
安装Rclone
sudo -v ; curl https://rclone.org/install.sh | sudo bash
更多的安装方法:Rclone文档
配置Rclone
rclone config #添加配置
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 S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, ChinaMobile, Cloudflare, DigitalOcean, Dreamhost, GCS, HuaweiOBS, IBMCOS, IDrive, IONOS, LyveCloud, Leviia, Liara, Linode, Magalu, Minio, Netease, Petabox, RackCorp, Rclone, Scaleway, SeaweedFS, StackPath, Storj, Synology, TencentCOS, Wasabi, Qiniu and others
\ (s3)
5 / Backblaze B2
\ (b2)
6 / Better checksums for other remotes
\ (hasher)
7 / Box
\ (box)
8 / Cache a remote
\ (cache)
9 / Citrix Sharefile
\ (sharefile)
10 / Combine several remotes into one
\ (combine)
11 / Compress a remote
\ (compress)
12 / Dropbox
\ (dropbox)
13 / Encrypt/Decrypt a remote
\ (crypt)
14 / Enterprise File Fabric
\ (filefabric)
15 / FTP
\ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
17 / Google Drive
\ (drive)
18 / Google Photos
\ (google photos)
19 / HTTP
\ (http)
20 / Hadoop distributed file system
\ (hdfs)
21 / HiDrive
\ (hidrive)
22 / ImageKit.io
\ (imagekit)
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 / Linkbox
\ (linkbox)
28 / Local Disk
\ (local)
29 / Mail.ru Cloud
\ (mailru)
30 / Mega
\ (mega)
31 / Microsoft Azure Blob Storage
\ (azureblob)
32 / Microsoft Azure Files
\ (azurefiles)
33 / Microsoft OneDrive
\ (onedrive)
34 / OpenDrive
\ (opendrive)
35 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
\ (swift)
36 / Oracle Cloud Infrastructure Object Storage
\ (oracleobjectstorage)
37 / Pcloud
\ (pcloud)
38 / PikPak
\ (pikpak)
39 / Proton Drive
\ (protondrive)
40 / Put.io
\ (putio)
41 / QingCloud Object Storage
\ (qingstor)
42 / Quatrix by Maytech
\ (quatrix)
43 / SMB / CIFS
\ (smb)
44 / SSH/SFTP
\ (sftp)
45 / Sia Decentralized Cloud
\ (sia)
46 / Storj Decentralized Cloud Storage
\ (storj)
47 / Sugarsync
\ (sugarsync)
48 / Transparently chunk/split large files
\ (chunker)
49 / Uloz.to
\ (ulozto)
50 / Union merges the contents of several upstream fs
\ (union)
51 / Uptobox
\ (uptobox)
52 / WebDAV
\ (webdav)
53 / Yandex Disk
\ (yandex)
54 / Zoho
\ (zoho)
55 / premiumize.me
\ (premiumizeme)
56 / seafile
\ (seafile)
Storage> 52 #选择WebDAV
Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a value.
url> http://VPS的IP:5244/dav/ #Alist地址必须加上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 / 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 / rclone WebDAV server to serve a remote over HTTP via the WebDAV protocol
\ (rclone)
7 / Other site/service or software
\ (other)
vendor> 7
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> 12345 #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 #输入AList的密码
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> #回车
Configuration complete.
Options:
- type: webdav
- url: http://VPS的IP:5244/dav/
- vendor: other
- user: ALits用户名称
- pass: *** ENCRYPTED ***
Keep this "Rclone名称" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y #确定
Current remotes:
Name Type
==== ====
Rclone名称 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 #退出配置
mkdir -p /lao/yang #创建一个文件夹
rclone mount Rclone名称 : /lao/yang --config=/root/.config/rclone/rclone.conf --allow-other --allow-non-empty --vfs-cache-mode full --vfs-cache-max-age 48h --vfs-cache-max-size 5G --cache-dir /tmp/cache --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G --buffer-size 128M --umask 000 &
设置开机自动启动
#创建service文件
vim /usr/lib/systemd/system/rclone.service
[Unit]
Description=rclone
[Service]
User=root
ExecStart=/usr/bin/rclone mount Rclone名称 : /lao/yang --config=/root/.config/rclone/rclone.conf --allow-other --allow-non-empty --vfs-cache-mode full --vfs-cache-max-age 48h --vfs-cache-max-size 5G --cache-dir /tmp/cache --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G --buffer-size 128M --umask 000 &
[Install]
WantedBy=multi-user.target
# reload守护进程
systemctl daemon-reload
# 设置service文件自启
systemctl enable rclone.service
# 启动service文件
systemctl start rclone.service