共计 4872 个字符,预计需要花费 13 分钟才能阅读完成。
本篇内容介绍了“Debian 怎么使用 rclone 挂载硬盘”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让丸趣 TV 小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
# 安装 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
return 1
do_start(){
check_running
if [[ $? -eq 0 ]]; then
echo -e ${Info} $NAME_BIN (PID ${PID}) 正在运行... exit 0
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 启动成功 !
echo -e ${Error} $NAME_BIN 启动失败 !
do_stop(){
check_running
if [[ $? -eq 0 ]]; then
kill -9 ${PID}
RETVAL=$?
if [[ $RETVAL -eq 0 ]]; then
echo -e ${Info} $NAME_BIN 停止成功 !
echo -e ${Error} $NAME_BIN 停止失败 !
echo -e ${Info} $NAME_BIN 未运行
RETVAL=1
fusermount -zuq $LOCAL /dev/null 2 1
do_status(){
check_running
if [[ $? -eq 0 ]]; then
echo -e ${Info} $NAME_BIN (PID $(echo ${PID})) 正在运行...
echo -e ${Info} $NAME_BIN 未运行 !
RETVAL=1
do_restart(){
do_stop
do_start
case $1 in
start|stop|restart|status)
do_$1
echo 使用方法: $0 { start | stop | restart | status }
RETVAL=1
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 挂载硬盘”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注丸趣 TV 网站,丸趣 TV 小编将为大家输出更多高质量的实用文章!