Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

May 10, 2023 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.

5 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

How to Increase Size of Disk Partition in...

October 5, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Fixing ‘The Network Path Was Not Found’ 0x80070035...

August 30, 2023

How to Install and Configure Ansible on Linux

August 27, 2023

Computer Doesn’t Turn Off After Shutting Down Windows...

August 26, 2023

5 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
Amey Abhyankar December 7, 2020 - 10:12 am

1) wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg
2) I open Google Chrome web browser and paste the generated URL
3) I click on my user name and then Google shows message saying this app is not verified hence can not proceed

Reply
Luis Cabrera March 13, 2021 - 2:40 pm

[root@chost onedrive]# onedrive
Cannot connect to Microsoft OneDrive Service – Network Connection Issue

ERROR: Microsoft OneDrive API returned an error with the following message:
Error Message: Timeout was reached on handle 2033C00
Calling Function: testNetwork()

Unable to reach Microsoft OneDrive API service, unable to initialize application

Reply
Mack May 26, 2021 - 10:27 pm

The app was blocked by Goolge as danger.

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Configure MariaDB Master-Master/Slave Replication?
  • KVM: How to Expand or Shrink a Virtual Machine Disk Size?
  • Adding VLAN Interface in CentOS/Fedora/RHEL
  • Install and Configure SNMP on RHEL/CentOS/Fedor
  • Configuring High Performance NGINX and PHP-FPM Web Server
  • Configuring Network Settings on RHEL/CentOS
  • Configuring Routing on Linux (RHEL/CentOS)
Footer Logo

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


Back To Top