Onedrive のネットワークドライブを Linux システムにマウントする#
1. トークンを取得する#
Windows コンピュータに Rclone をダウンロードします。ダウンロードリンク: https://rclone.org/downloads/ その後、解凍し、cmd を使用して解凍したフォルダに移動します。
rclone.exe authorize "onedrive"
ブラウザのログインページにリダイレクトされるので、アカウントとパスワードを入力してログインに成功すると、cmd コマンドウィンドウにトークンが返されます。
囲まれている部分がコピーして保存する必要があるもので、後で使用します。
2. Linux に onedrive をインストールする#
公式が提供するスクリプト
curl https://rclone.org/install.sh | bash
3. 設定#
インストールが完了したら、次のコマンドを入力します:
rclone config
次のように表示されます:
2022/04/27 09:01:17 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
は自由に入力できます。
次に、マウントするサービスの種類が表示されます:
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
1 / 1Fichier
\ (fichier)
2 / Akamai NetStorage
\ (netstorage)
3 / Alias for an existing remote
\ (alias)
4 / Amazon Drive
\ (amazon cloud drive)
5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, RackCorp, SeaweedFS, and Tencent COS
\ (s3)
6 / Backblaze B2
\ (b2)
7 / Better checksums for other remotes
\ (hasher)
8 / Box
\ (box)
9 / Cache a remote
\ (cache)
10 / Citrix Sharefile
\ (sharefile)
11 / Compress a remote
\ (compress)
12 / Dropbox
\ (dropbox)
13 / Encrypt/Decrypt a remote
\ (crypt)
14 / Enterprise File Fabric
\ (filefabric)
15 / FTP Connection
\ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
17 / Google Drive
\ (drive)
18 / Google Photos
\ (google photos)
19 / Hadoop distributed file system
\ (hdfs)
20 / Hubic
\ (hubic)
21 / In memory object storage system.
\ (memory)
22 / Jottacloud
\ (jottacloud)
23 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
24 / Local Disk
\ (local)
25 / Mail.ru Cloud
\ (mailru)
26 / Mega
\ (mega)
27 / Microsoft Azure Blob Storage
\ (azureblob)
28 / Microsoft OneDrive
\ (onedrive)
29 / OpenDrive
\ (opendrive)
30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ (swift)
31 / Pcloud
\ (pcloud)
32 / Put.io
\ (putio)
33 / QingCloud Object Storage
\ (qingstor)
34 / SSH/SFTP Connection
\ (sftp)
35 / Sia Decentralized Cloud
\ (sia)
36 / Storj Decentralized Cloud Storage
\ (storj)
37 / Sugarsync
\ (sugarsync)
38 / Transparently chunk/split large files
\ (chunker)
39 / Union merges the contents of several upstream fs
\ (union)
40 / Uptobox
\ (uptobox)
41 / Webdav
\ (webdav)
42 / Yandex Disk
\ (yandex)
43 / Zoho
\ (zoho)
44 / http Connection
\ (http)
45 / premiumize.me
\ (premiumizeme)
46 / seafile
\ (seafile)
Storage>
直接番号を入力します。例えば、OneDrive をマウントする場合は 28
を入力します。
client_id
はそのまま Enter を押してデフォルトを使用できます。
client_secret
もそのまま Enter を押してデフォルトを使用できます。
次に、OneDrive の地域選択が表示されます:
1234567891011Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
Choose a number from below, or type in your own value
1 / Microsoft Cloud Global
\ "global"
2 / Microsoft Cloud for US Government
\ "us"
3 / Microsoft Cloud Germany
\ "de"
4 / Azure and Office 365 operated by 21Vianet in China
\ "cn"
1
を入力してグローバルを選択します。
次に、高度な設定を行うかどうかを選択します:
123dit advanced config? (y/n)
y) Yes
n) No (default)
n
を入力できます。
次に、自動設定の選択が表示されます:
123456Remote 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
n
を入力できます。
ここで、認証コードを取得する必要があります:
Copy1234567891011For 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:
先ほど保存したトークンを {} を含めて Linux ターミナルに貼り付けます。
次に、OneDrive のタイプを選択します:
123456789101112131415Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
\ "url"
4 / Search for a Sharepoint site
\ "search"
5 / Type in driveID (advanced)
\ "driveid"
6 / Type in SiteID (advanced)
\ "siteid"
7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
\ "path"
1
を入力します。
次に、見つかった OneDrive アカウントが表示されます:
12Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!b_xnJJqyBMSVPjgvhvbP8XmJ_M_dMjhzrbhnaWknnbKqNBm8MTqM3kvEtW67P
指示に従って番号を入力します。
ここで、入力した番号に基づいてアカウントを検索します:
1234Found drive 'root' of type 'business', URL: https://xxx-my.sharepoint.com/personal/changbin_xxx_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
問題がなければ y
を入力します。
次に、選択した設定情報が表示されるので、確認後 y
を入力して設定を保存します。
4. マウント#
次のコマンドを入力します:
rclone mount configName:OneDriveLocation dir --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
configName
は設定名、OneDriveLocation
はマウントする OneDrive のディレクトリ、dir
はマウント先のローカルディレクトリです。
例えば、myonedrive
という名前の設定を /myonedrive
ディレクトリにマウントしたい場合、ディレクトリがない場合は先に作成します:mkdir myonedrive
次のように書くことができます:
nohup rclone mount myonedrive:/ /root/myonedrive --vfs-cache-mode writes --vfs-cache-max-age 10s --onedrive-chunk-size 100M >/dev/null 2>&1 &
ここでは OneDrive の全体をマウントしているので、OneDrive のルートディレクトリ /
を指定しています。
マウントが完了すると何も表示されません。別のターミナルを開いて、df -h
を入力してディスクスペースを確認します:
成功裏にマウントされました!!
一部のシステムではマウントに大きな遅延がある場合があるので、30 秒ほど待ってから再度確認してみてください。一般的にエラーが出なければ問題ありません。
よく使うコマンド
rclone copy – コピー
rclone sync – 同期 ディレクトリの内容をネットワークドライブのディレクトリに同期
rclone move – 移動 ディレクトリ内のファイルをネットワークドライブに移動、デフォルトでパス内のファイルを削除
rclone purge – パスとすべてのファイルを削除
rclone delete – パス内のすべてのファイルを削除するが、パスは削除しない
rclone mkdir – ディレクトリを作成
rclone rmdir – ディレクトリを削除
rclone check – 目標ファイルとソースファイルが一致するか確認
rclone ls – 指定したパス内のすべてのファイルとファイルサイズをリスト
rclone lsl – オブジェクトの変更時間、サイズ、パスのみをリスト
rclone lsd – ディレクトリのみをリスト