黑科技神器rclone,挂载到服务器后,秒变大盘鸡
开始上教程,以debian为例:
安装必要组件:
apt install curl -y;apt-get install fuse -y;apt-get install fuse3 -y
安装rclone:
curl https://rclone.org/install.sh | bash
配置rclone:
rclone config
具体设置如下:
n) New remote s) Set configuration password q) Quit config n/s/q> n //填n name> onedrive //填名称,随便你自己喜欢 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 / In memory object storage system. \ "memory" 17 / Jottacloud \ "jottacloud" 18 / Koofr \ "koofr" 19 / Local Disk \ "local" 20 / Mail.ru Cloud \ "mailru" 21 / Mega \ "mega" 22 / Microsoft Azure Blob Storage \ "azureblob" 23 / Microsoft OneDrive \ "onedrive" 24 / OpenDrive \ "opendrive" 25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 26 / Pcloud \ "pcloud" 27 / Put.io \ "putio" 28 / QingCloud Object Storage \ "qingstor" 29 / SSH/SFTP Connection \ "sftp" 30 / Sugarsync \ "sugarsync" 31 / Tardigrade Decentralized Cloud Storage \ "tardigrade" 32 / Transparently chunk/split large files \ "chunker" 33 / Union merges the contents of several upstream fs \ "union" 34 / Webdav \ "webdav" 35 / Yandex Disk \ "yandex" 36 / http Connection \ "http" 37 / premiumize.me \ "premiumizeme" 38 / seafile \ "seafile" Storage> 23 //填23,其他盘自行研究 OAuth Client Id Leave blank normally. Enter a string value. Press Enter for the default (""). client_id> //留空 OAuth Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> //留空 Edit advanced config? (y/n) y) Yes n) No (default) y/n> n //填n Remote config Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes (default) n) No y/n> n //填n For this to work, you will need rclone available on a machine that has a web browser available. For more help and alternate methods see: https://rclone.org/remote_setup/ Execute the following on the machine with the web browser (same rclone version recommended): rclone authorize "onedrive" Then paste the result below: result>
比如在D盘,用cmd进去
C:\Users\admin>cd /d d:/rclone
d:\rclone>rclone authorize "onedrive"
浏览器会弹出网页,登入onedrive账号,等待返回值,将整个 {"access_token":"xxxxxxxxxxxxxxxxxxxxx"} 部分粘贴到上个步骤的result
继续配置
Choose a number from below, or type in an existing value 1 / OneDrive Personal or Business \ "onedrive" 2 / Root Sharepoint site \ "sharepoint" 3 / Type in driveID \ "driveid" 4 / Type in SiteID \ "siteid" 5 / Search a Sharepoint site \ "search" Your choice> 1 //选择1 Found 1 drives, please select the one you want to use: 0: OneDrive (business) id=b!Cn0j9lDJfkiM5ndP5tipCnH0nwFNxB4xTPSD--pKf9t80QK8JRET4M9m4 Chose drive to use:> 0 Found drive 'root' of type 'business', URL: https://xxxx-my.sharepoint.com/personal/air_ningboschool_cn/Documents Is that okay? y) Yes (default) n) No y/n> y //选择y -------------------- y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y //选择y Current remotes: Name Type ==== ==== onedrive onedrive 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 退出
挂载磁盘
新建目录,这里我建在root目录下为例,你也可以建在其他目录
mkdir /root/onedrive
挂载为磁盘,下面的DriveName、Folder、LocalFolder参数根据说明自行替换
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
我刚设置的则为
rclone mount onedrive: /root/onedrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
如果成功一般无返回值,
然后新建一个ssh窗口,看下是否挂载成功
df -h
开机自启
新建一个rclone.service文件:
nano /etc/systemd/system/rclone.service
复制粘贴以下配置(根据自己前面挂载命令替换成自己路径):
[Unit] Description=Rclone After=network-online.target [Service] Type=simple ExecStart=/usr/bin/rclone mount onedrive: /root/onedrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 Restart=on-abort User=root [Install] WantedBy=default.target
设置重载配置,系统自启
systemctl daemon-reload
systemctl start rclone
systemctl enable rclone