Google drive is a great FREE cloud storage service. It allows you to store your data in the cloud so you can access it anywhere in the world, from just about any device. In this Linux Quick Tip we will show you how to easily mount your Google Drive using Gnome Online Accounts. Once mounted, you can access, copy, and delete your files from the GUI or the command line.
Set Up Google Drive in Gnome Online Accounts
Let's fire up Gnome Online Accounts and add our account. Go to Settings > Online Accounts to access the Add an account screen pictured below.
Click on Google and you will be asked to provide your gmail user account credentials. pass two factor authentication if enabled, and grant Gnome access to your account.
Once you are authenticated, you will be asked what features you want access to. You can select whatever you want here. Some of my friends like to enable everything so they can use the Gnome native apps. Since this article is about mounting Google Drive in Linux, we only need to ensure Files is turned on. Make sure the switch next to Files is on, and click the x
to close the dialog box.
Now you will see that your Google account is connected. Once you are at this point, you are ready to start using Google Drive.
Access Google Drive From Linux GUI
Now that your account is active, you can start using Google Drive. If you open "Files" you will see a new drive on the left menu with your gmail address as it's name. This is your Google Drive and you can copy, delete, and rename files from it just like you would any other folder.
Now that you can access Google Drive from your desktop, so can all of your apps. You can use your favorite backup tool (Deja Dup?) to copy your important files to Google Drive.
Access Google Drive from Linux Command Line
Here is where this became really useful for me. I wanted to access Google Drive from the command line so I can use rsync to synchronize my Documents directory with Google Drive.
Gnome uses it's gvfs (GNOME Virtual file system) to mount Google Drive with your account. The default location for a gvfs mounted drive is /run/user/<user-id>/gvfs/<connection-name>/
. Of course you have to replace <user-id> with your UID and <connection-name> with the Google Drive connection name.
You can your UID by using the echo command like so:
[mcherisi@putor ~]$ echo $UID
1001
Or you can use the following command to add it on the fly:
cd /run/user/$UID/gvfs/google-drive*
Here is it in action:
[mcherisi@putor ~]$ cd /run/user/$UID/gvfs/google-drive*
[mcherisi@putor google-drive:host=gmail.com,user=********]$ ls -lrt
total 8
-rw-------. 1 mcherisi mcherisi 7177 May 22 22:42 1RHAnCZyLC3dXUd1cLTUcyJOISLkGK1QI
-rw-------. 1 mcherisi mcherisi 140 May 22 22:50 1R3-QyxlBRlLjpjpWh28ntuUaep1510VY
[mcherisi@putor google-drive:host=gmail.com,user=********]$
As you can see above, Google Drive doesn't show the "display-name" of the file, but rather the ID of the file. This can make it hard to know what file you are going to be accessing. You can get a list with the filenames by using the gio
command.
[mcherisi@putor google-drive:host=gmail.com,user=********]$ gio list -a "standard::display-name"
1R3-QyxlBRlLjpjpWh28ntuUaep1510VY 0 (regular) standard::display-name=ok.txt
1RHAnCZyLC3dXUd1cLTUcyJOISLkGK1QI 7177 (regular) standard::display-name=Resume.txt
Because I use this so often, I created an alias to quickly get a listing. I added the following to my ~/.bashrc
file.
alias lg='gio list -a "standard::display-name"'
Now I can just lg
when I want a listing with the common names.
[mcherisi@putor google-drive:host=gmail.com,user=********]$ ls
1R3-QyxlBRlLjpjpWh28ntuUaep1510VY 1RHAnCZyLC3dXUd1cLTUcyJOISLkGK1QI
[mcherisi@putor google-drive:host=gmail.com,user=********]$ lg
1R3-QyxlBRlLjpjpWh28ntuUaep1510VY 0 (regular) standard::display-name=ok.txt
1RHAnCZyLC3dXUd1cLTUcyJOISLkGK1QI 7177 (regular) standard::display-name=Resume.txt
Now that I have this setup, I use rsync to synchronize my Documents folder with Google Drive. Now no matter where I am I can log into my gmail account and have access to all my documents. If you are interested in how this works leave a comment below!
Conclusion
There you have it, a simple method for connecting and mounting your Google drive on your Linux system. I use this every day and love it.
Resources and Links
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
4 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
- Uncategorized (1)
Some useful information here. I discovered what userid was being used by issuing the mount command, then explored the /run/user/$UID/gvfs directories that had been set up.
I set up 4 Google accounts usingtthis method recently and observed two detrimental effects :-
1. The gvfs / Google fuse processes were permanently using 400+ MBytes of my system memory.
2. Any attempt to view the new drive folders or copy files to one of them using cp or, rsync (or any applications that use them was extremely sluggish. Took an hour to copy just 4 small files (< 50Kbytes each). Totally impractical.
I then resorted to another method to mount Google drive using rclone,and created a mount point in my home directory. I think that occam fuse works in a similar way in terms of creating a mount point.
Anyway, the new Google drive mount point folder was visible to backup programs like Luckybackup, which just regarded it as another folder. The time taken to backup the files using Luckybackup, direct to my Google drive took a minute, maybe two instead of an hour. Performance (and excessive memory usage) has to be a consideration when choosinga method to mount a Google drive. I have not tried rclone functionality itself yet, apart from mounting the Google drive, but I imagine it will give other benefits too.
Does not seem to work well. On the web I have 44 files in a directory. gvfs only shows 1
Are the files in the google format?
the other software inside linux (librewriter) does not show the <> of the files. it seems not recognize the files type.