본문 바로가기
서버/리눅스 서버

구글 드라이브 마운트 (rclone, cache, api)

by ㅋㅋ잠자 2019. 3. 18.
반응형

안녕하세요. 도정진입니다.


이번에는 rclone 의 cache 기능을 통해 마운트 하는 방법에 대해서 알아보도록 하겠습니다.


음... 아직까지 directory index cache 가 동작하지 않는 상황이기 때문에 plexdrive 처럼 빠르게 파일 및 폴더가 열리지 않습니다.


그러면 plexdrive, rclone 의 차이에 대해서 먼저 생각해보면 아래와 같습니다.


<plexdrive>

1. 읽기 전용이나 삭제 기능을 가지고 있습니다.

2. 디렉터리 인덱스 캐쉬를 가지고 있어서 파일 탐색이 매우 빠릅니다.

3. 스트리밍에 최적화 되어 있습니다.

4. 업로드를 하려면 unionfs-fuse 를 연동해서 rclone 과 합쳐서 사용해야 합니다.


<rclone>

1. 커맨드 라인으로 copy move sync 등의 명령이 있습니다.

2. 자체 API 가 있어서 API 키를 발급하지 않아도 됩니다. (다만, 속도가 떨어짐)

3. 마운트 기능이 있으나 파일 디렉터리 인덱스 캐쉬가 없어 파일 탐색이 느립니다.

4. 최근에 도입된 cache 기능이 있어서 unionfs-fuse 와 비슷하게 연동이 가능합니다.



최근에 rclone cache 기능을 통해 구글 드라이브 마운트를 해보겠습니다.





1. rclone 다운 받기 및 바이너리 배치


하기는 armhf 기준으로 되어 있습니다. arch 에 맞게 다운받아주세요.


https://rclone.org/downloads/



# 바이너리 받기

root@AOL-Debian:~# wget https://downloads.rclone.org/v1.46/rclone-v1.46-linux-arm.zip

--2019-03-18 20:59:48--  https://downloads.rclone.org/v1.46/rclone-v1.46-linux-arm.zip

Resolving downloads.rclone.org (downloads.rclone.org)... 5.153.250.7, 2a02:24e0:8:61f9::1

Connecting to downloads.rclone.org (downloads.rclone.org)|5.153.250.7|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 8469829 (8.1M) [application/zip]

Saving to: ‘rclone-v1.46-linux-arm.zip’


rclone-v1.46-linux-arm.zip         100%[=================================================================>]   8.08M   126KB/s   in 61s    


2019-03-18 21:00:51 (136 KB/s) - ‘rclone-v1.46-linux-arm.zip’ saved [8469829/8469829]


# 압축풀기

root@AOL-Debian:~# unzip rclone-v1.46-linux-arm.zip 

Archive:  rclone-v1.46-linux-arm.zip

   creating: rclone-v1.46-linux-arm/

  inflating: rclone-v1.46-linux-arm/rclone.1  

  inflating: rclone-v1.46-linux-arm/rclone  

  inflating: rclone-v1.46-linux-arm/README.txt  

  inflating: rclone-v1.46-linux-arm/README.html  

 extracting: rclone-v1.46-linux-arm/git-log.txt  


# unzip 바이너리가 없으면 아래 명령으로 설치

root@AOL-Debian:~# apt install unzip

Reading package lists... Done

Building dependency tree       

Reading state information... Done

unzip is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.


# rclone 바이너리 /usr/bin 으로 옮기고 실행 권한 주기

root@AOL-Debian:~# mv rclone-v1.46-linux-arm/rclone /usr/bin

root@AOL-Debian:~# chmod a+x /usr/bin/rclone 


# 실행 확인

root@AOL-Debian:~# rclone

Usage:

  rclone [flags]

  rclone [command]


Available Commands:

  about           Get quota information from the remote.

  authorize       Remote authorization.

  cachestats      Print cache stats for a remote

  cat             Concatenates any files and sends them to stdout.

  check           Checks the files in the source and destination match.

  cleanup         Clean up the remote if possible

  config          Enter an interactive configuration session.

  copy            Copy files from source to dest, skipping already copied

  copyto          Copy files from source to dest, skipping already copied

  copyurl         Copy url content to dest.

  cryptcheck      Cryptcheck checks the integrity of a crypted remote.

  cryptdecode     Cryptdecode returns unencrypted file names.

  dbhashsum       Produces a Dropbox hash file for all the objects in the path.

  dedupe          Interactively find duplicate files and delete/rename them.

  delete          Remove the contents of path.

  deletefile      Remove a single file from remote.

  genautocomplete Output completion script for a given shell.

  gendocs         Output markdown docs for rclone to the directory supplied.

  hashsum         Produces an hashsum file for all the objects in the path.

  help            Show help for rclone commands, flags and backends.

  link            Generate public link to file/folder.

  listremotes     List all the remotes in the config file.

  ls              List the objects in the path with size and path.

  lsd             List all directories/containers/buckets in the path.

  lsf             List directories and objects in remote:path formatted for parsing

  lsjson          List directories and objects in the path in JSON format.

  lsl             List the objects in path with modification time, size and path.

  md5sum          Produces an md5sum file for all the objects in the path.

  mkdir           Make the path if it doesn't already exist.

  mount           Mount the remote as file system on a mountpoint.

  move            Move files from source to dest.

  moveto          Move file or directory from source to dest.

  ncdu            Explore a remote with a text based user interface.

  obscure         Obscure password for use in the rclone.conf

  purge           Remove the path and all of its contents.

  rc              Run a command against a running rclone.

  rcat            Copies standard input to file on remote.

  rcd             Run rclone listening to remote control commands only.

  rmdir           Remove the path if empty.

  rmdirs          Remove empty directories under the path.

  serve           Serve a remote over a protocol.

  settier         Changes storage class/tier of objects in remote.

  sha1sum         Produces an sha1sum file for all the objects in the path.

  size            Prints the total size and number of objects in remote:path.

  sync            Make source and dest identical, modifying destination only.

  touch           Create new file or change file modification time.

  tree            List the contents of the remote in a tree like fashion.

  version         Show the version number.


Use "rclone [command] --help" for more information about a command.

Use "rclone help flags" for to see the global flags.

Use "rclone help backends" for a list of supported services.





2. api 키 생성


rclone 내장 api 를 사용하면 속도가 느린 문제가 있습니다.


클라우드 콘솔로 이동하여 api 를 하나 생성합니다.


https://console.cloud.google.com/


이하 글은 plexdrive 글을 가지고 왔습니다.


-------------------------------------------------


저는 이미 한번 생성해서 클라우드 플랫폼을 처음 사용할 때 동의하는 화면이 없습니다. 참고하시길 바랍니다.


상기 프로젝트를 누르면 아래의 선택하는 창이 듭니다. 거기서 + 버튼을 누릅니다.



프로젝트 이름을 마음에 드는 것으로 하나 해줍니다.




만들기를 하셨다고 해서 바로 접근이 가능한것은 아닙니다. 알림 아이콘에서 만들어 졌는지 확인을 하시고 진행하시길 바랍니다.



다시 프로젝트 선택 버튼을 누르고 방금 만든 것을 선택합니다.



그럼 방금 만든 프로젝트에 대한 대시보드가 열립니다. 여기서 API 개요로 이동을 누릅니다.



그리고 검색창에 drive 라고 검색을 해 봅니다.



그럼 google drive api 가 뜰것입니다. 해당을 눌러줍니다.



사용설정을 누릅니다.



다음으로 사용자 인증정보 탭으로 이동합니다.



사용자 인증 정보 만들기를 누릅니다.



OAuth 클라이언트 ID 를 선택합니다.


동의 화면 구성을 누르고 동의해 줍니다.



이름을 마음에 드는것으로 입력하고 저장을 누릅니다.



그러면 어플리케이션 유형이 선택이 가능하게 바뀌고 기타를 누른 다음에 또 마음에 드는 이름으로 입력을 합니다. 그 후 생성을 누릅니다.



그러면 팝업이 뜨면서 클라이언트ID 와 클라이언트 보안 비밀 값이 뜹니다.



상기에서 나온 클라이언트 ID 및 보안 비밀번호를 체크하시길 바랍니다.





3. rclone 에 연결


아래의 과정을 거칩니다.


# 설정을 진행합니다.

root@AOL-Debian:~# rclone config


# 기본적으로 계정 폴더 .config/rclone/rclone.conf 에 설정이 작성됩니다.

2019/03/18 21:07:15 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults


# 새로운 리모트를 생성합니다.

No remotes found - make a new one

n) New remote

s) Set configuration password

q) Quit config

n/s/q> n


# 이름을 넣습니다.

name> gdrive


# 스토리지 타입을 선택합니다. 구글 드라이브로 선택하세요.

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 / A stackable unification remote, which can appear to merge the contents of several remotes

   \ "union"

 2 / Alias for a 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 / Dropbox

   \ "dropbox"

 9 / Encrypt/Decrypt a remote

   \ "crypt"

10 / FTP Connection

   \ "ftp"

11 / Google Cloud Storage (this is not Google Drive)

   \ "google cloud storage"

12 / Google Drive

   \ "drive"

13 / Hubic

   \ "hubic"

14 / JottaCloud

   \ "jottacloud"

15 / Local Disk

   \ "local"

16 / Mega

   \ "mega"

17 / Microsoft Azure Blob Storage

   \ "azureblob"

18 / Microsoft OneDrive

   \ "onedrive"

19 / OpenDrive

   \ "opendrive"

20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)

   \ "swift"

21 / Pcloud

   \ "pcloud"

22 / QingCloud Object Storage

   \ "qingstor"

23 / SSH/SFTP Connection

   \ "sftp"

24 / Webdav

   \ "webdav"

25 / Yandex Disk

   \ "yandex"

26 / http Connection

   \ "http"

Storage> 12

** See help for drive backend at: https://rclone.org/drive/ **


# 상기에서 생성한 클라이언트 아이디 및 비번을 넣습니다.

Google Application Client Id

Leave blank normally.

Enter a string value. Press Enter for the default ("").

client_id> 130---------------------------------------------------------.apps.googleusercontent.com


Google Application Client Secret

Leave blank normally.

Enter a string value. Press Enter for the default ("").

client_secret> -------------------------------------------------------------


# 보이는 항목을 선택합니다. 그냥 1번으로 갑니다.

Scope that rclone should use when requesting access from drive.

Enter a string value. Press Enter for the default ("").

Choose a number from below, or type in your own value

 1 / Full access all files, excluding Application Data Folder.

   \ "drive"

 2 / Read-only access to file metadata and file contents.

   \ "drive.readonly"

   / Access to files created by rclone only.

 3 | These are visible in the drive website.

   | File authorization is revoked when the user deauthorizes the app.

   \ "drive.file"

   / Allows read and write access to the Application Data folder.

 4 | This is not visible in the drive website.

   \ "drive.appfolder"

   / Allows read-only access to file metadata but

 5 | does not allow any access to read or download file content.

   \ "drive.metadata.readonly"

scope> 1


# rclone 의 루트폴더 값을 넣습니다. 구글드라이브 웹에서 폴더 선택 후 drive.google.com/-------- 뒷부분을 넣으면 그 폴더가 루트 폴더로 인식됩니다. 빈칸으로 두면 드라이브 전체가 루트로 잡힙니다.

ID of the root folder

Leave blank normally.

Fill in to access "Computers" folders. (see docs).

Enter a string value. Press Enter for the default ("").

root_folder_id> 


# 이것은 정확히 파악을 못하고 있습니다. 그냥 넘어갑니다.

Service Account Credentials JSON file path 

Leave blank normally.

Needed only if you want use SA instead of interactive login.

Enter a string value. Press Enter for the default ("").

service_account_file> 


# 고급설정은 하지 않고 넘어갑니다.

Edit advanced config? (y/n)

y) Yes

n) No

y/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

n) No

y/n> n

If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=---------------------------------------------------------------

Log in and authorize rclone for access

Enter verification code> ----------------------------------------------------------





# 팀드라이브로 설정하지 않을 것입니다.

Configure this as a team drive?

y) Yes

n) No

y/n> n


# 설정 결과가 출력됩니다.

--------------------

[gdrive]

type = drive

client_id = 133----------------------------------------------.apps.googleusercontent.com

client_secret = ----------------------------------------

scope = drive

token = {"access_token":"---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------","token_type":"Bearer","refresh_token":"1/----------------------------------------------------------------------------------------","expiry":"2019-03-18T22:09:09.630293405+09:00"}

--------------------

y) Yes this is OK

e) Edit this remote

d) Delete this remote

y/e/d> y


# 추가 후 등록된 드라이브 목록입니다.

Current remotes:


Name                 Type

====                 ====

gdrive               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

root@AOL-Debian:~#





4. cache 마운트 설정


일단 먼저 의존성 패키지를 설치합니다.


root@AOL-Debian:~# apt install fuse

Reading package lists... Done

Building dependency tree       

Reading state information... Done

fuse is already the newest version.

0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

root@AOL-Debian:~# 


다음으로 DB 와 캐쉬 폴더로 사용될 폴더를 몇가지 생성합니다.


캐쉬 DB 폴더 / 업로드 시 대기할 캐쉬 폴더 / 파일 다운로드시 캐쉬 폴더 3가지 폴더를 생성합니다.


root@AOL-Debian:~# mkdir /var/cache/rclone

root@AOL-Debian:~# mkdir -p /sdcard/temp/rclone_upload

root@AOL-Debian:~# mkdir /sdcard/temp/rclone_chunk


다음으로 cache 마운트를 설정합니다.


root@AOL-Debian:~# rclone config

Current remotes:


Name                 Type

====                 ====

gdrive               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> n

name> cache



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 / A stackable unification remote, which can appear to merge the contents of several remotes

   \ "union"

 2 / Alias for a 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 / Dropbox

   \ "dropbox"

 9 / Encrypt/Decrypt a remote

   \ "crypt"

10 / FTP Connection

   \ "ftp"

11 / Google Cloud Storage (this is not Google Drive)

   \ "google cloud storage"

12 / Google Drive

   \ "drive"

13 / Hubic

   \ "hubic"

14 / JottaCloud

   \ "jottacloud"

15 / Local Disk

   \ "local"

16 / Mega

   \ "mega"

17 / Microsoft Azure Blob Storage

   \ "azureblob"

18 / Microsoft OneDrive

   \ "onedrive"

19 / OpenDrive

   \ "opendrive"

20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)

   \ "swift"

21 / Pcloud

   \ "pcloud"

22 / QingCloud Object Storage

   \ "qingstor"

23 / SSH/SFTP Connection

   \ "sftp"

24 / Webdav

   \ "webdav"

25 / Yandex Disk

   \ "yandex"

26 / http Connection

   \ "http"

Storage> 7

** See help for cache backend at: https://rclone.org/cache/ **


# gdrive: 로 입력하면 전체를 캐쉬하고 gdrive:/video 이런식으로 입력하면 특정 폴더가 캐쉬됩니다.

Remote to cache.

Normally should contain a ':' and a path, eg "myremote:path/to/dir",

"myremote:bucket" or maybe "myremote:" (not recommended).

Enter a string value. Press Enter for the default ("").

remote> gdrive:


# 플렉스 서버와 연동하는 기능이 있는데 이는 넘깁니다.

The URL of the Plex server

Enter a string value. Press Enter for the default ("").

plex_url> 

The username of the Plex user

Enter a string value. Press Enter for the default ("").

plex_username> 

The password of the Plex user

y) Yes type in my own password

g) Generate random password

n) No leave this optional password blank

y/g/n> n

The size of a chunk (partial file data).


# 청크 사이즈를 1MB 로 설정합니다.

Use lower numbers for slower connections. If the chunk size is

changed, any downloaded chunks will be invalid and cache-chunk-path

will need to be cleared or unexpected EOF errors will occur.

Enter a size with suffix k,M,G,T. Press Enter for the default ("5M").

Choose a number from below, or type in your own value

 1 / 1MB

   \ "1m"

 2 / 5 MB

   \ "5M"

 3 / 10 MB

   \ "10M"

chunk_size> 1


# 캐쉬 구조 유지 시간을 설정합니다.

How long to cache file structure information (directory listings, file size, times etc). 

If all write operations are done through the cache then you can safely make

this value very large as the cache store will also be updated in real time.

Enter a duration s,m,h,d,w,M,y. Press Enter for the default ("6h0m0s").

Choose a number from below, or type in your own value

 1 / 1 hour

   \ "1h"

 2 / 24 hours

   \ "24h"

 3 / 48 hours

   \ "48h"

info_age> 2



# 디스크의 청크 캐쉬 전체 사이즈를 입력합니다. U5 내장 메모리라 5G 입력했습니다.

The total size that the chunks can take up on the local disk.


If the cache exceeds this value then it will start to delete the

oldest chunks until it goes under this value.

Enter a size with suffix k,M,G,T. Press Enter for the default ("10G").

Choose a number from below, or type in your own value

 1 / 500 MB

   \ "500M"

 2 / 1 GB

   \ "1G"

 3 / 10 GB

   \ "10G"

chunk_total_size> 5G


# 고급설정을 진행합니다.

Edit advanced config? (y/n)

y) Yes

n) No

y/n> y


# 플렉스 설정은 건너뜁니다.

The plex token for authentication - auto set normally

Enter a string value. Press Enter for the default ("").

plex_token> 

Skip all certificate verifications when connecting to the Plex server

Enter a string value. Press Enter for the default ("").

plex_insecure> 


# DB 경로를 설정합니다. DB를 하드에 설정 시 계속 깨어남으로 메모리에 위치시킵니다.

Directory to store file structure metadata DB.

The remote name is used as the DB file name.

Enter a string value. Press Enter for the default ("/root/.cache/rclone/cache-backend").

db_path> /var/cache/rclone


# 청크 캐쉬 위치를 설정합니다.

Directory to cache chunk files.


Path to where partial file data (chunks) are stored locally. The remote

name is appended to the final path.


This config follows the "--cache-db-path". If you specify a custom

location for "--cache-db-path" and don't specify one for "--cache-chunk-path"

then "--cache-chunk-path" will use the same path as "--cache-db-path".

Enter a string value. Press Enter for the default ("/root/.cache/rclone/cache-backend").

chunk_path> /sdcard/temp/rclone_chunk


# 마운트가 시작 될 때 캐쉬를 지울지 설정하는 부분입니다.

Clear all the cached data for this remote on start.

Enter a boolean value (true or false). Press Enter for the default ("false").

db_purge> false


# 캐쉬 지우는 주기를 설정합니다.

How often should the cache perform cleanups of the chunk storage.

The default value should be ok for most people. If you find that the

cache goes over "cache-chunk-total-size" too often then try to lower

this value to force it to perform cleanups more often.

Enter a duration s,m,h,d,w,M,y. Press Enter for the default ("1m0s").

chunk_clean_interval> 1h


# 연결에 문제가 있을 경우 재시도 횟수 설정입니다.

How many times to retry a read from a cache storage.


Since reading from a cache stream is independent from downloading file

data, readers can get to a point where there's no more data in the

cache.  Most of the times this can indicate a connectivity issue if

cache isn't able to provide file data anymore.


For really slow connections, increase this to a point where the stream is

able to provide data but your experience will be very stuttering.

Enter a signed integer. Press Enter for the default ("10").

read_retries> 10


# 동시에 다운받는 캐쉬의 숫자입니다.

How many workers should run in parallel to download chunks.


Higher values will mean more parallel processing (better CPU needed)

and more concurrent requests on the cloud provider.  This impacts

several aspects like the cloud provider API limits, more stress on the

hardware that rclone runs on but it also means that streams will be

more fluid and data will be available much more faster to readers.


**Note**: If the optional Plex integration is enabled then this

setting will adapt to the type of reading performed and the value

specified here will be used as a maximum number of workers to use.

Enter a signed integer. Press Enter for the default ("4").

workers> 16


# 메모리 캐쉬 사용여부 설정입니다.

Disable the in-memory cache for storing chunks during streaming.


By default, cache will keep file data during streaming in RAM as well

to provide it to readers as fast as possible.


This transient data is evicted as soon as it is read and the number of

chunks stored doesn't exceed the number of workers. However, depending

on other settings like "cache-chunk-size" and "cache-workers" this footprint

can increase if there are parallel streams too (multiple files being read

at the same time).


If the hardware permits it, use this feature to provide an overall better

performance during streaming but it can also be disabled if RAM is not

available on the local machine.

Enter a boolean value (true or false). Press Enter for the default ("false").

chunk_no_memory> false


# API 요청 수와 관련이 있는데 외국포럼에 10이 적당하다고 합니다.

Limits the number of requests per second to the source FS (-1 to disable)


This setting places a hard limit on the number of requests per second

that cache will be doing to the cloud provider remote and try to

respect that value by setting waits between reads.


If you find that you're getting banned or limited on the cloud

provider through cache and know that a smaller number of requests per

second will allow you to work with it then you can use this setting

for that.


A good balance of all the other settings should make this setting

useless but it is available to set for more special cases.


**NOTE**: This will limit the number of requests during streams but

other API calls to the cloud provider like directory listings will

still pass.

Enter a signed integer. Press Enter for the default ("-1").

rps> 10


# 임시 폴더에 업로드 파일을 쓰는 것입니다. true 의 경우 업로드 중에도 파일 액세스가 가능합니다.

Cache file data on writes through the FS


If you need to read files immediately after you upload them through

cache you can enable this flag to have their data stored in the

cache store at the same time during upload.

Enter a boolean value (true or false). Press Enter for the default ("false").

writes> true


# 업로드 임시 디렉터리를 설정합니다.

Directory to keep temporary files until they are uploaded.


This is the path where cache will use as a temporary storage for new

files that need to be uploaded to the cloud provider.


Specifying a value will enable this feature. Without it, it is

completely disabled and files will be uploaded directly to the cloud

provider

Enter a string value. Press Enter for the default ("").

tmp_upload_path> /sdcard/temp/rclone_upload


# 업로드 시작 대기 시간을 설정합니다.

How long should files be stored in local cache before being uploaded


This is the duration that a file must wait in the temporary location

_cache-tmp-upload-path_ before it is selected for upload.


Note that only one file is uploaded at a time and it can take longer

to start the upload if a queue formed for this purpose.

Enter a duration s,m,h,d,w,M,y. Press Enter for the default ("15s").

tmp_wait_time> 1m


# DB 관련으로 다른 작업중에 DB가 응답하지 않으면 직접 로드하게 됩니다. 기다릴 시간을 설정합니다.

How long to wait for the DB to be available - 0 is unlimited


Only one process can have the DB open at any one time, so rclone waits

for this duration for the DB to become available before it gives an

error.


If you set it to 0 then it will wait forever.

Enter a duration s,m,h,d,w,M,y. Press Enter for the default ("1s").

db_wait_time> 1s


# 설정 내용을 전반적으로 보여줍니다.

Remote config

--------------------

[cache]

type = cache

remote = gdrive:

chunk_size = 1M

info_age = 1d

chunk_total_size = 5G

db_path = /var/cache/rclone

chunk_path = /sdcard/temp/rclone_chunk

db_purge = false

chunk_clean_interval = 1h0m0s

read_retries = 10

workers = 16

chunk_no_memory = false

rps = 10

writes = true

tmp_upload_path = /sdcard/temp/rclone_upload

tmp_wait_time = 1m0s

db_wait_time = 1s

--------------------

y) Yes this is OK

e) Edit this remote

d) Delete this remote

y/e/d> y

Current remotes:


Name                 Type

====                 ====

cache                cache

gdrive               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





5. rclone cache 마운트


# 마운트 될 폴더를 생성하고 마운트를 진행합니다.

root@AOL-Debian:~# mkdir /mnt/rclone


# 데몬 옵션을 주면 백그라운드로 작동합니다.

root@AOL-Debian:~# rclone mount cache: /mnt/rclone --daemon --allow-other


# 정상적으로 파일이 보입니다.

root@AOL-Debian:~# ls /mnt/rclone/

001. Users  010. Share folder  Blue  Getting started





6. 캐쉬 테스트


# db 파일 생성 확인 (마운트 하는 드라이브의 이름이 생성되었습니다.)

root@AOL-Debian:~# ls /var/cache/rclone/

cache.db


# 영상 파일 스트리밍시 생기는 캐쉬 확인 (현재 액새스 하고 있는 파일의 캐쉬가 생성되었습니다.)
root@AOL-Debian:~# ls /sdcard/temp/rclone_chunk/cache/010.\ Share\ folder/001.\ Video/001-10\ 한국\ 드라마/1%의\ 어떤것/
1%의어떤것(2016).S01E01_161005_720p-es.mkv  1%의어떤것(2016).S01E03_161012_720p-es.mkv 1%의어떤것(2016).S01E06_161020_720p-es.mkv


파일을 복사할 경우 복사동안에는 업로드가 발생하지 않음으로 상당히 빠른 속도로 복사가 됩니다.


그 후 설정한 대로 1분 뒤에 업로드가 걸립니다.



상기와 같이 복사 후 1분 뒤에 업로드가 시작됩니다.


그 전에는 상기 설정한 캐쉬 폴더에 저장되어 있습니다.


root@AOL-Debian:~# ls /sdcard/temp/rclone_upload/001.\ Users/djjproject/temp/

mobizen_20190311_145757.mp4


업로드 시작 후 아래처럼 트래픽이 올라갑니다.




업로드 후에는 캐쉬 폴더의 내용이 사라집니다.


# 캐쉬 폴더의 사용량이 3.1G 입니다. 업로드 전입니다. (캐쉬 폴더에 남아있는 상태)

root@AOL-Debian:~# df -h

Filesystem                                                       Size  Used Avail Use% Mounted on

/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/userdata   10G  3.1G  7.0G  31% /data

tmpfs                                                            942M  500K  942M   1% /dev

tmpfs                                                            942M     0  942M   0% /mnt

/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/system    1.4G  1.2G  120M  92% /system

/data/media                                                       10G  3.1G  7.0G  31% /mnt/runtime/default/emulated

/data/media                                                       10G  3.1G  7.0G  31% /mnt/runtime/read/emulated

/data/media                                                       10G  3.1G  7.0G  31% /mnt/runtime/write/emulated

tmpfs                                                            947M  8.0K  947M   1% /dev/shm

tmpfs                                                            947M   52K  947M   1% /run

cache:                                                           1.0P   17T  1.0P   2% /mnt/rclone


# 업로드 후입니다. 용량이 줄고 파일이 없습니다.

root@AOL-Debian:~# df -h

Filesystem                                                       Size  Used Avail Use% Mounted on

/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/userdata   10G  1.9G  8.2G  19% /data

tmpfs                                                            942M  500K  942M   1% /dev

tmpfs                                                            942M     0  942M   0% /mnt

/dev/block/platform/soc/f9830000.himciv200.MMC/by-name/system    1.4G  1.2G  120M  92% /system

/data/media                                                       10G  1.9G  8.1G  19% /mnt/runtime/default/emulated

/data/media                                                       10G  1.9G  8.1G  19% /mnt/runtime/read/emulated

/data/media                                                       10G  1.9G  8.1G  19% /mnt/runtime/write/emulated

tmpfs                                                            947M  8.0K  947M   1% /dev/shm

tmpfs                                                            947M   52K  947M   1% /run

cache:                                                           1.0P   17T  1.0P   2% /mnt/rclone

root@AOL-Debian:~# cd /sdcard/temp/rclone_upload/

root@AOL-Debian:/sdcard/temp/rclone_upload# ls

root@AOL-Debian:/sdcard/temp/rclone_upload# 


마운트 언마운트 관련 에러는 아래와 같이 해결하세요.


# rclone 종료

root@AOL-Debian:~# pkill rclone


# 재마운트 시도

root@AOL-Debian:~# rclone mount cache: /mnt/rclone --daemon --allow-other

2019/03/18 22:41:31 Fatal error: Can not open: /mnt/rclone: open /mnt/rclone: transport endpoint is not connected


# lazy umount 실행

root@AOL-Debian:~# umount -l /mnt/rclone


# 재마운트 시도 (성공)

root@AOL-Debian:~# rclone mount cache: /mnt/rclone --daemon --allow-other


여기까지 대장정 마치겠습니다.


제가 보았을 때에는 PlexDrive 와 혼용해서 사용하는게 좋은것 같습니다.

반응형

댓글