Debian怎么使用rclone挂载硬盘
本篇内容介绍了“Debian怎么使用rclone挂载硬盘”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
公司主营业务:成都网站设计、网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出乌当免费做网站回馈大家。
#安装rclone
nano rclone.sh
输入下列内容,并保存
#!/bin/bash apt-get install -y nload htop fuse p7zip-full KernelBit="$(getconf LONG_BIT)" [[ "$KernelBit" == '32' ]] && KernelBitVer='i386' [[ "$KernelBit" == '64' ]] && KernelBitVer='amd64' [[ -z "$KernelBitVer" ]] && exit 1 cd /tmp wget -O '/tmp/rclone.zip' "https://downloads.rclone.org/rclone-current-linux-$KernelBitVer.zip" 7z x /tmp/rclone.zip cd rclone-* cp -raf rclone /usr/bin/ chown root:root /usr/bin/rclone chmod 755 /usr/bin/rclone mkdir -p /usr/local/share/man/man1 cp -raf rclone.1 /usr/local/share/man/man1/ mandb
执行
bash rclone_debian
#初始化配置
rclone config
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> gdrive #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
"amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
"s3"
3 / Backblaze B2
"b2"
4 / Box
"box"
5 / Cache a remote
"cache"
6 / Dropbox
"dropbox"
7 / Encrypt/Decrypt a remote
"crypt"
8 / FTP Connection
"ftp"
9 / Google Cloud Storage (this is not Google Drive)
"google cloud storage"
10 / Google Drive
"drive"
11 / Hubic
"hubic"
12 / Local Disk
"local"
13 / Microsoft Azure Blob Storage
"azureblob"
14 / Microsoft OneDrive
"onedrive"
15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
"swift"
16 / Pcloud
"pcloud"
17 / QingCloud Object Storage
"qingstor"
18 / SSH/SFTP Connection
"sftp"
19 / Webdav
"webdav"
20 / Yandex Disk
"yandex"
21 / http Connection
"http"
Storage> 10 #选择10,Google Drive
Google Application Client Id - leave blank normally.
client_id> #留空
Google Application Client Secret - leave blank normally.
client_secret> #留空
Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login.
service_account_file>
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n #选择n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth.... #复制到浏览器打开,获取验证码
Log in and authorize rclone for access
Enter verification code> #填入上面获取到的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> y #选择y
Fetching team drive list...
No team drives found in your account--------------------
[dengxj]
client_id =
client_secret =
service_account_file =
token = {"access_token":"ya29.GltFBd7UJN2qrxdG8FnG_rMuB18ogb8QlujdL7glvXtfV"}
team_drive =
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #选择y
Current remotes:
Name Type
==== ====
dengxj drive
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退出
挂载为磁盘
#新建本地文件夹,路径自己定,即下面的LocalFolder
mkdir /root/GoogleDrive
#挂载为磁盘
格式:
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
我们这里可以这样填
rclone mount gdrive: /root/GoogleDrive --allow-other --allow-non-empty --vfs-cache-mode writes
如需卸载磁盘
fusermount -qzu LocalFolder
三、自启动
(1)下载并编辑脚本
nano rcloned
输入下面内容
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH NAME_BIN="rclone" ### BEGIN INIT INFO # Provides: rclone # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start rclone at boot time # Description: Enable rclone by daemon. ### END INIT INFO NAME="" #rclone name名 REMOTE='' #远程文件夹 LOCAL='' #挂载地址 Green_font_prefix="[32m" && Red_font_prefix="[31m" && Green_background_prefix="[42;37m" && Red_background_prefix="[41;37m" && Font_color_suffix="[0m" Info="${Green_font_prefix}[信息]${Font_color_suffix}" Error="${Red_font_prefix}[错误]${Font_color_suffix}" RETVAL=0 check_running(){ PID="$(ps -C $NAME_BIN -o pid= |head -n1 |grep -o '[0-9]{1,}')" if [[ ! -z ${PID} ]]; then return 0 else return 1 fi } do_start(){ check_running if [[ $? -eq 0 ]]; then echo -e "${Info} $NAME_BIN (PID ${PID}) 正在运行..." && exit 0 else fusermount -zuq $LOCAL >/dev/null 2>&1 mkdir -p $LOCAL sudo /usr/bin/rclone mount $NAME:$REMOTE $LOCAL --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 >/dev/null 2>&1 & sleep 2s check_running if [[ $? -eq 0 ]]; then echo -e "${Info} $NAME_BIN 启动成功 !" else echo -e "${Error} $NAME_BIN 启动失败 !" fi fi } do_stop(){ check_running if [[ $? -eq 0 ]]; then kill -9 ${PID} RETVAL=$? if [[ $RETVAL -eq 0 ]]; then echo -e "${Info} $NAME_BIN 停止成功 !" else echo -e "${Error} $NAME_BIN 停止失败 !" fi else echo -e "${Info} $NAME_BIN 未运行" RETVAL=1 fi fusermount -zuq $LOCAL >/dev/null 2>&1 } do_status(){ check_running if [[ $? -eq 0 ]]; then echo -e "${Info} $NAME_BIN (PID $(echo ${PID})) 正在运行..." else echo -e "${Info} $NAME_BIN 未运行 !" RETVAL=1 fi } do_restart(){ do_stop do_start } case "$1" in start|stop|restart|status) do_$1 ;; *) echo "使用方法: $0 { start | stop | restart | status }" RETVAL=1 ;; esac exit $RETVAL
修改其中的
NAME="" #rclone name名,及配置时输入的Name
REMOTE=’’ #远程文件夹,Google Drive网盘里的挂载的一个文件夹
LOCAL=’’ #挂载地址,vps本地挂载目录
然后
#Debian系统
apt-get install sudo -y
#设置自启
mv rcloned /etc/init.d/rcloned chmod +x /etc/init.d/rcloned update-rc.d -f rcloned defaults bash /etc/init.d/rcloned start
“Debian怎么使用rclone挂载硬盘”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!
网站标题:Debian怎么使用rclone挂载硬盘
本文来源:http://scyanting.com/article/gcioig.html