您好,登錄后才能下訂單哦!
本篇內容介紹了“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掛載硬盤”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。