You are not logged in.

#1 2016-10-07 19:40:56

kmmcd
Member
From: Orange County, CA
Registered: 2014-05-07
Posts: 2

OneDrive in Linux (kind of)

Hello all, I'm hoping that there's someone out there that finds some use in my solution to this problem.  As you know, Microsoft has no native Linux client for their otherwise acceptable OneDrive cloud storage.  If, like me, you are a university student, you may enjoy up to a Terabyte of storage free of charge, but lamenting its accessibility from Linux.

This solution essentially relies on Windows in a virtual machine (Oracle VM VirtualBox) and it's interface with OneDrive.  The OneDrive folder is shared via cifs over a virtual network with the host system.  There is a lot of overhead here, which I realize is unacceptable to some users, but I'm usually running my Windows VM anyway, and I expect there are others out there that can implement this.  With that said, here's how to set it up:

Package requirements (Linux System):
virtualbox
cifs

Step 1:  Setting up a Host-Only network
Before starting the VM, go to the manager, highlight the VM and click Settigs -> Network -> Adapter 2  (or 3, or 4, if you already have new interfaces set up).  Enable the Network adapter and attach it to a "Host-only Adapter".  The default name is vboxnet0 and you may see some more details under Advanced.  I've disabled Promiscuous Mode because I don't see that providing any more functionality than we need right now.  Start the Virtual Machine and log in.  The new interface should be enabled automatically, but Windows may complain about "limited connectivity"
image.png


Step 2: Sharing the Folder from Windows
Part 1: Preventing sharing to the world
Before sharing the OneDrive folder from Windows, we should limit File and Printer sharing to the new host-only interface (unless you want also to mount this folder from other machines on the network).  To do this, Open the Control Panel and go to the Network and Sharing Center.  On the left, click "Change adapter settings", which will open a new window.  From here, right click on "Ethernet 1" (The adapter connected to the Internet) and click properties.  In this dialogue, uncheck "File and Printer Sharing for Microsoft Networks".  Nota Bene, this will also prevent your Virtual Machine from mounting samba/cifs shares over your LAN.  I'm unaware of a method in Windows to selectively share folders over specific interfaces.
image.png

Part 2: Note-taking
Don't leave the Network and Sharing center yet!  While the "Change adapter settings" window is still open, right click the "Ethernet 2" interface and get the status.  Click "Details" and note the ipv4 address and gateway.  This address is how we will tell the Linux host to interface with the virtual machine as if it were another computer on the network.
Protip:  You can grab this information from ipconfig on the windows command prompt as well.
image.png

Part 3: Share the OneDrive folder
I have my entire User folder shared, but it's possible to limit this to OneDrive as well.  Simply go to your user folder, right click the OneDrive Foler, and open the "Properties" dialogue.  There is a tab here labeled "Sharing", where you'll need to enable it for this folder.  Make sure that your Windows user is the only user allowed to access this over the network!
image.png
image.png

Part 4: Download OneDrive files to your Virtualmachine
It seems that files on OneDrive remain on the server until you access them.  Without this step, they will be visible in Linux, but there's an error when you go to open anything.  To fix this, right click on your OneDrive folder in explorer and select "Make Available Offline"
image.png

Step 3:  Mounting the OneDrive folder from Linux
This is the easy part.  First create a mount point;

mkdir ~/OneDrive

Make a credentials file (~/.vboxcredentials) for your virtualbox user with the following contents

username=USER
password=PASSWORD

Change the permissions so that your user is the only one that can read and write this file

chmod 700 ~/.vboxcredentials

add this line to your /etc/fstab file, changing the mountpoint and ip address to your own values

//192.168.56.101/Users/USERNAME/OneDrive	/home/USERNAME/OneDrive	cifs users,credentials=/home/USERNAME/.vboxcredentials,noexec,noauto,nosuid,nodev 0 0

Save the fstab, and try mounting the OneDrive as your non-root user

mount ~/OneDrive

Protip:  This one liner will also mount, but you'll need to sudo to use the mount -o flag

sudo mount -t cifs -o username=USER,password=PASS //192.168.56.101/Users/USERNAME/OneDrive /home/USERNAME/OneDrive

I've written most of this from memory.  If any of you have problems sharing, please let me know - I may be forgetting to include a step, but I'm happy to update this post if that is the case.  Some of the more experienced users out there may also be able to contribute security tips, or another way to make this more user friendly.

## Edit!:  I forgot to add the step where Onedrive is made available offline.  Mea culpa, I've updated the post smile

Last edited by kmmcd (2016-10-07 20:42:22)

Offline

#2 2016-10-07 22:57:41

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: OneDrive in Linux (kind of)

There are native Linux OneDrive clients in the AUR.

Online

Board footer

Powered by FluxBB