LoginSignup
44

More than 3 years have passed since last update.

google-drive-ocamlfuseでGoogleドライブをマウント

Last updated at Posted at 2020-03-03

概要

google-drive-ocamlfuseを使うと、Googleドライブをマウントできます。
「同期」ではなく「マウント」なので、ストレージ容量を(たぶん)圧迫しません。

インストール

sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt-get update
sudo apt-get install google-drive-ocamlfuse

もしこう言われたときは

-bash: add-apt-repository: コマンドが見つかりません

こうしましょう

sudo apt install software-properties-common

認証

google-drive-ocamlfuse

google-drive-ocamlfuseはGUIのブラウザで認証を求めるので、もしVPSなどでGUI環境がない場合以下のようなエラーが発生します。

$ google-drive-ocamlfuse 
/bin/sh: 1: xdg-open: not found
/bin/sh: 1: firefox: not found
/bin/sh: 1: google-chrome: not found
Cannot retrieve auth tokens.

このエラーを解消するには以下の方法があります

  1. 手元に用意した仮想マシン上で認証ファイルを作成し、実環境に転送する
    → 手元にある程度パワみのあるPCが必要
  2. 実環境にGUI環境とVNCサーバーをインストールし、手元からVNC接続する
    → 実環境のストレージに少なくとも約10GBの空き容量が必要
  3. 以下の方法で実環境上で認証する

3の場合、Slackのワークスペースが必要です。
まず、こちらに倣ってSlackアプリをセットアップし、ここまで進めます。
その際、

  • 最終行にreadを挿入します。
  • 保存先を/usr/local/bin/slacknotifyではなく/usr/local/bin/xdg-openにします。

そしてまた以下のコマンドを実行します。

google-drive-ocamlfuse

するとSlackで認証URLが届きます。
TyyzRNGgfK8b8DN1583235404_1583235445.jpg
あとはこれを手元のPCで開きログインすれば、認証は完了します。

セットアップ

適当な場所にディレクトリを作り、そこにマウントします。

mkdir ~/google-drive
google-drive-ocamlfuse /home/ubuntu/google-drive

これでマウントできました。

以下のコマンドで確認できます

$ df -h --total
Filesystem              Size  Used Avail Use% Mounted on
udev                    471M     0  471M   0% /dev
tmpfs                    99M  1.2M   98M   2% /run
:
google-drive-ocamlfuse   15G  3.6G   11G  24% /home/ubuntu/google-drive
total                   115G   24G   91G  20% -

アンマウント

fusermount -u /home/ubuntu/google-drive

参考元

公式リポジトリ
https://github.com/astrada/google-drive-ocamlfuse

debian で google-drive-ocamlfuse を使って Google ドライブをマウントする
https://k-side.hatenablog.jp/entry/2016/09/05/205407

Ubuntu 14.04 で add-apt-repository が無いと言われた
https://loumo.jp/wp/archive/20150626000042/

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44