Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Linux / How to Mount Google Drive or OneDrive in Linux?

August 16, 2020 CentOSLinuxQuestions and AnswersRHEL

How to Mount Google Drive or OneDrive in Linux?

In this article we’ll consider how to connect free cloud storages like Google Drive or OneDrive in Linux CentOS. You can use them to backup data or just to exchange files between your hosts. For example, you can install a cloud storage client in your Windows desktop, upload files to it and automatically get access to shared files from Linux (or vice versa).

Often the webmasters or web developers don’t know that they can use cloud storages if there is not enough free space on a virtual machine or in a container. In my work I recommend users to connect cloud storages to store some files they donэt need often or to backup a website or MySQL/MariaDB databases there.

Mount and Use Google Drive and OneDrive on Linux CentOS

In this article we’ll consider how to connect the most popular free storages (OneDrive and Google Drive), to a host running Linux CentOS 7.

Contents:
  • How to Mount Google Drive as a Storage in Linux?
  • Mounting OneDrive in Linux

How to Mount Google Drive as a Storage in Linux?

Let’s take a look at how to connect Google Drive on Linux CentOS 7. The installation is very fast and simple.

Download Google Drive client using the command:

# wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg

Move the file to /usr/sbin:

# mv drive /usr/sbin/drive

Change file permissions:

# chmod +x /usr/sbin/drive

Google Drive installation is over, you only have to start the client and sign in:

# drive

Go to the following link in your browser:

https://accounts.google.com/o/oauth2/auth?client_id=367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state

Enter verification code:

Copy the link and open it in a browser on your PC and allow access to your Google account.

allow access google drive

Then you will get a link to enter in your Linux console:

google drive client on linux
Google Drive is connected, but it does not use the WebDav protocol (it is not supported). So, you do not see it either as a separate file system or a local directory. You can address Google Drive through the drive client.

You can view the files in your Google Drive using the command:

# drive list

Files are displayed as a table having four columns:

  • Id – a unique file code
  • Title – a file name
  • Size – a file size
  • Created – a date of creation

To test it, we can create a file and upload it to g.drive:

touch testdrive.txt && drive upload --file testdrive.txt

The file has been created, you can see it in the console. Also make sure that the file has appeared in Google Drive web interface:

By default, Google offers 15GB space on its Google Drive for free.

So we have connected Google Drive to our Linux server. I like Google Drive since you don’t have to do anything on the server to mount the cloud storage after each server restart. You can restart your server as many times as necessary and Google Drive will be connected automatically. However, there are some disadvantages: you don’t see the cloud storage as a separate directory on the server and cannot manage files on the file system level or using the usual bash commands.

Mounting OneDrive in Linux

OneDrive is a cloud storage by Microsoft. By default it is available for all Windows 10 users with the linked account (5GB are offered in OneDrive for free). Our task is to connect OneDrive in CentOS 7. During the configuration I came across a lot of problems that can be solved after some experimenting. You will only have to read the instructions and follow these steps on your server.

First of all, sign up using this link: https://onedrive.live.com

Then install the required packages in Linux CentOS using yum:

# yum groupinstall 'Development Tools' -y
# yum install libcurl-devel -y
# yum install sqlite-devel -y

Then install the programming language D(dlang). It will be required to install the OneDrive client:

# curl -fsS https://dlang.org/install.sh | bash -s dmd

To run D(dlang), enter this command:

source ~/dlang/dmd-2.088.0/activate — in your case, the dmd version may differ, so specify the one you have.

After running dlang, install OneDrive client:

cd /opt
git clone https://github.com/abraunegg/onedrive.git
cd onedrive
./configure
make clean; make;
sudo make install

install onedrive client on linux centos

The installation is over, then you have to activate the client in OneDrive web version. Run the command:

OneDrive

The system will show you the link you must enter in your browser. Click Allow in the web form of the access request. Then the link will change to the unique one containing the code you will have to enter in your Linux console.

Authorize this app visiting:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=xxxxxx
Enter the response uri https://login.microsoftonline.com/common/oauth2/nativeclient?code=xxxxxx

After the link confirmation, I can synchronize with OneDrive cloud storage:

# onedrive --synchronize

Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Processing 6 changes
Creating directory: Pictures
Creating directory: Documents
Downloading file Getting started with OneDrive.pdf ... done.
Creating directory: backup
Downloading file backup/test.txt ... done.

By default, /root/OneDrive directory containing all folders of my cloud storage has been created on my Linux host.

# ls -la /root/OneDrive/

To test it, I created a file test2.txt and synchronized the storages:

# onedrive --synchronize

Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Uploading new file ./backup/test2.txt ... done.

The file was uploaded to the OneDrive cloud:

upload file from linux to onedrive

To change the default directory, you must change the sync_dir parameter in the configuration file and run this command:

# onedrive --synchronize --resync

Initializing the Synchronization Engine ...
Syncing changes from OneDrive ...
Processing 12 changes

After restarting the server, OneDrive client is started automatically and you don’t need to sign in again.

In the next article, we’ll consider how to use cloud storages to backup data from a Linux server.

2 comments
0
Facebook Twitter Google + Pinterest
previous post
How to View and Close Open Files in Windows Server SMB Share?
next post
Selecting the Number of vCPUs and Cores for a Virtual Machine

Related Reading

Configuring Software RAID on Linux Using MDADM

January 11, 2021

Install and Configure OpenVPN Server on Linux CentOS/RHEL

December 31, 2020

Zabbix: Single Sign-On (SSO) Authentication in Active Directory

December 17, 2020

Zabbix Installation and Basic Configuration Guide

November 23, 2020

Compress, Defrag and Optimize MariaDB/MySQL Database

November 3, 2020

2 comments

Linux User November 12, 2020 - 2:17 pm

It looks like for OneDrive you are installing something which synchronises your local files with the remote files (a la Dropbox) which is not the same as mounting. Mounting means the files are only stored remotely, and your system “thinks” it is local; Synching means you have a copy in OneDrive and one locally.

Reply
javier Perez November 23, 2020 - 5:37 pm

para activar el onedrive con otro usuario como se haria, en el caso de que lo haya activado con otra cuenta

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • Preparing Windows for Adobe Flash End of Life on December 31, 2020

    January 22, 2021
  • Checking User Logon History in Active Directory Domain with PowerShell

    January 22, 2021
  • How to Disable/Remove Thumbs.db File on Network Folders in Windows?

    January 21, 2021
  • MS SQL Server 2019 Installation Guide: Basic Settings and Recommendations

    January 19, 2021
  • USB Device Passthrough (Redirect) to Hyper-V Virtual Machine

    January 15, 2021
  • Windows 10: No Internet Connection After Connecting to VPN Server

    January 13, 2021
  • Updating the PowerShell Version on Windows

    December 24, 2020
  • How to Enable and Configure User Disk Quotas in Windows?

    December 23, 2020
  • Restoring Deleted Active Directory Objects/Users

    December 21, 2020
  • Fix: Search Feature in Outlook is Not Working

    December 18, 2020

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Configure MariaDB Master-Master/Slave Replication?
  • Using iPerf to Test Network Speed and Bandwidth (Throughput)
  • Hyper-V Boot Error: The Image’s Hash and Certificate Are not Allowed
  • Adding VLAN Interface in CentOS/Fedora/RHEL
  • Compress, Defrag and Optimize MariaDB/MySQL Database
  • KVM: How to Expand or Shrink a Virtual Machine Disk Size?
  • Zabbix Installation and Basic Configuration Guide
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top