Mount Google Drive drive through gdfs on Ubuntu 17.04
I use Google Drive to store backups on some of my servers, but I can invent many scenarios for using this cloud storage.
To do this, we will need to install the client library to work with the Google API, the gdfs driver, get the authorization code and configure the automatic mount when the server boots.
Install the Google Client API
The client is needed to authorize gdfs
sudo apt install -y python-pip git clone cd google-api-python-client sudo python setup.py install install_egg_info
Install Google Drive FS
Install gdrivefs and make a symlink for convenience
sudo pip install gdrivefs cd /sbin sudo ln -s `which gdfs` mount.gdfs
Customization
You need to authenticate to the Google API Client and create a directory to mount the drive
gdfstool auth -u # Open the link in your browser, please log in # and copy the received key as <code> gdfstool auth -a /var/.gdfs.creds "<code>" mkdir /mnt/gdrivefs
Mounting through /etc/fstab
You can add the following entry to /etc/fstab
echo "/var/.gdfs.creds/mnt/gdrivefs gdfs allow_other, big_writes 0 0" >> /etc/fstab mount /mnt/gdrivefs
But the mount takes place before the network connection of the server, and without the network you can not connect Google Drive, so after rebooting the server you will have problems with the mount. You can add the option _netdev:
echo "/var/.gdfs.creds/mnt/gdrivefs gdfs allow_other,big_writes,_netdev 0 0" >> /etc/fstab mount /mnt/gdrivefs
But I could not use this option:
fuse: unknown option "_netdev"
Mounting through /etc/network/interfaces
I mount the disk in the following way
echo "post-up /bin/mount/var/.gdfs.creds/mnt/gdrivefs -t gdfs -o allow_other,big_writes" >> /etc/network/interfaces
After rebooting the server, you will start post-up and mount the disk.
Checking
We will mount it manually and look at the files:
mount /var/.gdfs.creds /mnt/gdrivefs -t gdfs -o allow_other,big_writes ls -la /mnt/gdrivefs
I recommend that you reboot and check that everything works.
По-русски
Comments
Hey I would like some help getting this to work. My first error I have ran into is the command "sudo ln -s" and this is the error that comes from it. ln: missing file operand.
Post your comment