wholesale jerseys nba jersey discounts ncaa college jerseys nfl cheap jerseys with free shipping nfl authentic football jerseys new york giants apparel cheap

How to mount Google Drive on a Linux VPS (only mapping no sync)

This tutorial will help you setup mounting your Google Drive onto your Linux. This will only map the drive not sync which saves your local space.

googledrivemount

KVM VPS is required. The VPS that is OpenVZ virtualized will not work. Try DigitalOcean 's KVM VPS.

Debian 7 64 bit is required

apt-get update
apt-get dist-upgrade

update and upgrade OS up-to-date

[email protected]:~# uname -a
Linux GoogleDrive 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux
[email protected]:~# cat /etc/issue
Debian GNU/Linux 7 \n \l
[email protected]:~#

install the following packages

apt-get install ocamapt-get install ocaml
apt-get install ocaml-findlib
apt-get install sqlite3
apt-get install camlidl
apt-get install m4 libcurl4-gnutls-dev libfuse-dev libsqlite3-dev
apt-get install camlp4-extra
apt-get install fuse
apt-get install build-essential sudo ssh make gitl

install opam

git clone https://github.com/OCamlPro/opam
cd opam
./configure && make && make install

Build Successful in 76.86s. 840 jobs (parallelism 1.8x), 1124 files generated.
make[1]: Leaving directory `/root/opam'
mkdir -p /usr/local/bin
make opam-install opam-admin-install opam-installer-install
make[1]: Entering directory `/root/opam'
install _obuild/opam/opam.asm
install _obuild/opam-admin/opam-admin.asm
install _obuild/opam-installer/opam-installer.asm
make[1]: Leaving directory `/root/opam'
mkdir -p /usr/local/share/man/man1 && cp doc/man/* /usr/local/share/man/man1
[email protected]:~/opam# opam init
default    Downloading https://opam.ocaml.org/urls.txt
default    Downloading https://opam.ocaml.org/index.tar.gz
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Creating a cache of metadata in ~/.opam/state.cache ...
...
Do you want OPAM to modify ~/.bashrc and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bashrc)
    [N/y/f] {type enter}
...
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

1. To configure OPAM in the current shell session, you need to run:

      eval `opam config env`

2. To correctly configure OPAM for subsequent use, add the following
line to your profile file (for instance ~/.bashrc):

      . /root/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

3. To avoid issues related to non-system installations of `ocamlfind`
  add the following lines to ~/.ocamlinit (create it if necessary):

      let () =
        try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
        with Not_found -> ()
      ;;

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

install google-drive-ocamlfuse

[email protected]:~/opam# opam update
default    Downloading https://opam.ocaml.org/urls.txt
Downloading https://opam.ocaml.org/repo
Updating ~/.opam/repo/compiler-index ...
Updating ~/.opam/compilers/ ...
Updating ~/.opam/repo/package-index ...
Updating ~/.opam/packages/ ...
Updating the cache of metadata (~/.opam/state.cache) ...
[email protected]:~/opam#

 

[email protected]:~/opam# opam install google-drive-ocamlfuse
The following actions will be performed:
 - install   ocamlfind.1.4.0                       [required by google-drive-ocamlfuse]
 - install   cppo.0.9.3                            [required by yojson]
 - install   camlidl.1.05                          [required by google-drive-ocamlfuse]
 - install   xmlm.1.1.1                            [required by gapi-ocaml]
 - install   sqlite3-ocaml.2.0.5                   [required by google-drive-ocamlfuse]
 - install   ocurl.0.7.0                           [required by gapi-ocaml]
 - install   extlib.1.6.1                          [required by gapi-ocaml]
 - install   easy-format.1.0.2                     [required by yojson]
 - install   cryptokit.1.9                         [required by gapi-ocaml]
 - install   ocamlfuse.2.7.1-cvs2                  [required by google-drive-ocamlfuse]
 - install   biniou.1.0.9                          [required by yojson]
 - install   ocamlnet.3.7.3                        [required by gapi-ocaml]
 - install   yojson.1.1.8                          [required by gapi-ocaml]
 - install   gapi-ocaml.0.2.1                      [required by google-drive-ocamlfuse]
 - install   google-drive-ocamlfuse.0.5.3
15 to install | 0 to reinstall | 0 to upgrade | 0 to downgrade | 0 to remove
Do you want to continue ? [Y/n] {type enter}

1.trouble shooting:

=-=-= Synchronizing package archives =-=-=
[ERROR] Actions cancelled because of # opam-version    1.1.1 (71b2a01ee571507c1819fbd282b0500d628f92d3)
# os              linux
opam: "fork" failed: Cannot allocate memory
Fatal error:
# opam-version    1.1.1 (71b2a01ee571507c1819fbd282b0500d628f92d3)
# os              linux
opam: "fork" failed: Cannot allocate memory
[email protected]:~/opam#

You need to add some swap to be able to run this installation.

when you see the following, you are on the track.

=-=-= Synchronizing package archives =-=-=
default    Downloading https://opam.ocaml.org/archives/biniou.1.0.9+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/cppo.0.9.3+opam.tar.gz
Downloading https://opam.ocaml.org/archives/cppo.0.9.3+opam.tar.gz
Downloading https://opam.ocaml.org/archives/biniou.1.0.9+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/camlidl.1.05+opam.tar.gz
Downloading https://opam.ocaml.org/archives/camlidl.1.05+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/cryptokit.1.9+opam.tar.gz
Downloading https://opam.ocaml.org/archives/cryptokit.1.9+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz
Downloading https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/extlib.1.6.1+opam.tar.gz
Downloading https://opam.ocaml.org/archives/extlib.1.6.1+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/gapi-ocaml.0.2.1+opam.tar.gz
Downloading https://opam.ocaml.org/archives/gapi-ocaml.0.2.1+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/google-drive-ocamlfuse.0.5.3+opam.tar.gz
Downloading https://opam.ocaml.org/archives/google-drive-ocamlfuse.0.5.3+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/ocamlfind.1.4.0+opam.tar.gz
Downloading https://opam.ocaml.org/archives/ocamlfind.1.4.0+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/ocamlfuse.2.7.1-cvs2+opam.tar.gz
Downloading https://opam.ocaml.org/archives/ocamlfuse.2.7.1-cvs2+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/ocamlnet.3.7.3+opam.tar.gz
Downloading https://opam.ocaml.org/archives/ocamlnet.3.7.3+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/ocurl.0.7.0+opam.tar.gz
Downloading https://opam.ocaml.org/archives/ocurl.0.7.0+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/sqlite3-ocaml.2.0.5+opam.tar.gz
Downloading https://opam.ocaml.org/archives/sqlite3-ocaml.2.0.5+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/xmlm.1.1.1+opam.tar.gz
Downloading https://opam.ocaml.org/archives/xmlm.1.1.1+opam.tar.gz
default    Downloading https://opam.ocaml.org/archives/yojson.1.1.8+opam.tar.gz
Downloading https://opam.ocaml.org/archives/yojson.1.1.8+opam.tar.gz

here takes a bit longer which is normal.

=-=-= Installing ocamlnet.3.7.3 =-=-=

Go into Google Project and create a Project

https://console.developers.google.com/project

googleproject

进入项目的API设置开启Drive API

googledriveenabledriveapi

 

create an OAuth ID

google_project_credentials_oauth

create a Client ID for the project

google_project_create_client_ID

 

write down the two masked values for later use

google_project_client_id_native_application

go into /root/.opam/system/bin/

cd /root/.opam/system/bin/
./google-drive-ocamlfuse -headless -label googledrive -id ##Client ID##.apps.googleusercontent.com -secret ##secret key##

replace ##Client ID## with your first part of the client ID and ##secret key## with your secret key. The echo of this command will provide you a https link. copy and paste it to your broswer. click accept and write down the returned password key.

google_drive_accept

eg:

[email protected]:~/.opam/system/bin# ./google-drive-ocamlfuse -headless -label googledrive -id 123123231.apps.googleusercontent.com -secret ASDASDASDASQWE!@#
Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=123123231.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force
Please enter the verification code:[input here]
Access token retrieved correctly.
[email protected]:~/.opam/system/bin#

go into ~/.gdfuse/googledrive

cd ~/.gdfuse/googledrive
nano config

edit "config" and fill up:

verification_code= [key returned from browser]

client_id= [eg. 123123231.apps.googleusercontent.com]

client_secret= [eg. ASDQWEWGSD!$@#@#ASD]

mount remote Google Drive to local folder /googledrive

mkdir /googledrive
cd ~/.opam/system/bin
./google-drive-ocamlfuse -label googledrive /googledrive

 

[email protected]:/googledrive# df -h
Filesystem                 Size  Used Avail Use% Mounted on
rootfs                      20G  5.7G   14G  31% /
udev                        10M     0   10M   0% /dev
tmpfs                       50M  124K   50M   1% /run
/dev/disk/by-label/DOROOT   20G  5.7G   14G  31% /
tmpfs                      5.0M     0  5.0M   0% /run/lock
tmpfs                      100M     0  100M   0% /run/shm
google-drive-ocamlfuse      15G  6.2G  8.9G  42% /googledrive
[email protected]:/googledrive#

 

[email protected]:/googledrive# dd if=/dev/zero of=/googledrive/1 bs=1024 count=1k
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 6.05313 s, 173 kB/s
[email protected]:/googledrive#

Done

Reference:

http://opam.ocaml.org/doc/Quick_Install.html

https://github.com/astrada/google-drive-ocamlfuse

https://github.com/ocaml/opam/releases

http://ocaml.org/docs/install.html

https://github.com/astrada/google-drive-ocamlfuse/wiki/How-to-install-from-source-on-Debian-Jessie

https://github.com/astrada/google-drive-ocamlfuse/wiki/Installation

https://console.developers.google.com/project

https://github.com/astrada/google-drive-ocamlfuse/wiki/Authorization

https://github.com/astrada/google-drive-ocamlfuse/wiki/Headless-Usage-%26-Authorization

http://ubuntuforums.org/showthread.php?t=148359

https://github.com/astrada/google-drive-ocamlfuse

 

 


6 comments

  1. AlexW UNITED STATES Safari Mac OS says:

    Do you have to do this for every user, or can you just do it in a domain? I’d like to map GoogleDrive like a network drive for school computers on Linux, if possible, but so far it doesn’t seem like it is! I definitely don’t want to go through all this for each student account though.

    • kyaky AUSTRALIA Google Chrome Windows says:

      If your server is a windows server, mount googledrive as a network drive is easier than this because you can just setup googledrive and share it as a network drive. This method introduced in this tutorial is for a command-line-based linux server once you succeed, you can still share the mounted drive as a network drive for students to access through network. xD

    • kyaky AUSTRALIA Google Chrome Windows says:

      just to remind you that currently GoogleDrive has a terrible upload peak limit. They limit you max upload speed to the server. I don’t suggest you use a GoogleDrive as a high performance network drive solution.

  2. Mariusz POLAND Google Chrome Windows says:

    Could you please help me?

    [email protected]:/home/pi# nano /etc/dphys-swapfile
    [email protected]:/home/pi# dphys-swapfile setup
    want /var/swap=1024MByte, checking existing: deleting wrong size file (536870912), generating swapfile … of 1024MBytes
    [email protected]:/home/pi# opam install base-threads base-bigarray base-unix
    Creating a cache of metadata in ~/.opam/state.cache …
    Fatal error:
    Out of memory

    • kyaky AUSTRALIA Google Chrome Windows says:

      1. you probably need to setup some more room for swap. check these out first:
      https://vpsmate.net/create-swap-kvmxen-vpses-ubuntudebian.html
      https://vpsmate.net/create-swap-kvmxen-vpses-centos.html

      2.Make sure you are using either KVM VPS or XEN. OpenVZ has too much trouble to setup this.

  3. Angie LATVIA Mozilla Firefox Ubuntu Linux says:

    Cheers!

    Good tutorial thumbs up! I was kind of lost in GitHub’s Astradas manual…

make a comment

(opt)