For mounting Google Drive on your server. you will require two things.
-
A project created and configured with OAuth client id and scecret on Google
-
google-drive-ocamlfuse installed and configured
Create Project
1. go to https://console.developers.google.com/apis/dashboard
and create new project
Click on create credentials
Select OAuth Client ID
Click on configure Consent Screen
Provide email address and product name
To Create Client ID select others and provide Name and click on create
It will give you OAuth Client ID and Secret. Please note it down and keep safe.
Installation of google-drive-ocamlfuse On debian 9
1. First install the required packages
apt-get install libcurl4-gnutls-dev libfuse-dev libgmp-dev libsqlite3-dev camlp4-extra debianutils libcurl4-gnutls-dev perl m4 pkg-config zlib1g-dev
2. adduser <user> fuse ( adding user to group fuse usrmod also works)
3. Set the Permissions
#sudo chown root.fuse /dev/fuse
#sudo chmod 660 /dev/fuse
4. Install Google Drive Ocamlfuse
# su <user>
# opam init
# opam update
# opam install depext
# eval `opam config env`
# opam depext google-drive-ocamlfuse
# opam install google-drive-ocamlfuse
# . /home/<user>/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
#/home/<user>/.opam/system/bin/google-drive-ocamlfuse -headless -label googledrive -id <OAuth Client ID> -secret <OAuth Client Secret>
It will give you one url ask you to visit that url and get the code from the webpage and provide it
Open that url in browser and copy paste the verification code to termianl
create mount point
# mkdir /mnt/Google-drive
# /home/<user>/.opam/system/bin/google-drive-ocamlfuse -label googledrive /mnt/Google-drive/
Above command will enable that mount only for the user and not others not even root
To enable mount point for user root
edit file /etc/fuse.conf and uncomment below line
#user_allow_other
Then run below command ( In case of ubuntu exclude sudo -u <user> and run command directly as root.)
#sudo -u <user> /home/<user>/.opam/system/bin/google-drive-ocamlfuse -o allow_root -label googledrive /Google-drive/ > /var/log/gdrive_mount.log 2>&1 &
Add below line (/etc/rc.local)
sudo -u <user> /home/<user>/.opam/system/bin/google-drive-ocamlfuse -o allow_root -label googledrive /Google-drive/ 2>$1 &
Thus only user and root will be able to use mounted drive.
Unable to access the drive after mounting. Input/Output error
Hi Carl,
Thank you for writing.
Please check if the user is able to mount the drive using below command
#/home/user/.opam/system/bin/google-drive-ocamlfuse -label googledrive /mnt/Google-drive/
If it doesn’t work for you then please check you have enabled project and also enabled api in that project.
If you want that drive to access as root then you have to edit /etc/fuse.conf
and uncomment below line
#user_allow_other
then use below command
#/home/user/.opam/system/bin/google-drive-ocamlfuse -o allow_root -label googledrive /Google-drive/ > /var/log/gdrive_mount.log 2>&1 &
And for startup add below line in /etc/rc.local
sudo -u user /home/user/.opam/system/bin/google-drive-ocamlfuse -o allow_root -label googledrive /Google-drive/ > /var/log/gdrive_mount.log 2>&1 &
Hope this helps you.