Introduction

I recently install Mint Linux on a tiny $200 13″ laptop because Windows 10 was killing its performance since I got it. I got this low powered sad excuse for a laptop because the only thing I actually needed was Chrome and OneDrive. Mint Linux is far lighter weight and the tiny laptop now runs very nicely without Windows murdering the low powered hardware.

  • Getting Chrome on Mint Linux was a no brainer so I am not going into that
  • The only reliable flavor of OneDrive for Linx us onedrive-d, the rest of this post is about that

Installing onedrive-d

There are about a million posts on how to install ondrive-d. Anything I post about how to do it here will be obsolete in about a month so here is a YouTube video I used to get it done:

If you have problems installing Python, look at the comments under the video it explains what to do.

What I want to warn you about

This may be obvious to some people, but when I was working on this at like 02:00 I wasn’t thinking clearly so I just want to throw out some wisdom for anyone else trying to do the same thing as I.

  1. To be absolutely safe (and paranoid) make sure you stop OneDrive on all of your Windows Machines
    1. Turn off any machines that don’t need to be on like your non-primary devices such as:
      1. Secondary PC
      2. Secondary Laptop
      3. A Surface or a other tablet like device that uses Windows
    2. The reason for doing this will be obvious as you read on – it will mitigate mistakes (such as the mistake I made which I will explain)
  2. Make sure you setup your Ignore file before you do ANYTHING else – this is critical because you have very limited options of fixing this later and you could cause some serious headaches for yourself otherwise
    1. The ignore file is typically located here: /home/<username>/.onedrive/ignore_v2.ini
    2. onedrive-d uses the exact opposite methodology of OneDrive on Windows
      1. OneDrive on Windows wants you to state what you DO want to synchronize on your computer
      2. onedrive-d on Linux wants you to state what you DO NOT want to synchronize on your computer
        1. onedrive-d uses the same ignore files as Git, you can read up on it here if you are unfamiliar: https://git-scm.com/docs/gitignore
    3. Make sure you explicitly state which files and folders you do not want to sync, you have to get this right the first time otherwise you could have a serious problem moving forward
      1. If your filenames have spaces in them, it’s okay this is supported. Example: /Finance Documents/American Express
      2. Use forward slashes to denote directories, because this is Linux and that’s how Git Ignore works even on Windows
  3. After doing the above steps you have the choice to run onedrive-d as a daemon (Like a Windows Service) or in debug mode as a process so that you can see what is actively happening. In either case make sure to be in the directory where you installed onedrive-d to run these commands. Everything is case sensitive:
    1. onedrive-d start                 //Run as a daemon
      1. To stop the daemon use: onedrive-d stop
    2. onedrive-d start –debug  //Run as a process
      1. To kill the process use: Ctrl + C  //Like you would any other process in command line, this is even true in Windows
  4. If at this point everything looks okay, then you are good – nothing else to worry about

How I screwed up and why I am warning you

In the same night I had to figure out how to get my tiny laptop to allow me to install Linux, which isn’t as easy as it sounds because Microsoft has basically gotten a number of BIOS/UEFI manufacturers to lock down hardware so that you cannot just install a non-Windows OS. Undoing this isn’t hard, but it isn’t obvious either. I tried installing Arch Linux, but didn’t have such a great experience so I switched over to Mint Linux which was much easier and more pleasant to install. I had to install programs, run OS updates and finally I got around to installing onedrive-d. I had some issues with dependencies and then I got the point where I could run onedrive-d.

My mistake

I wasn’t aware of how onedrive-d actually worked and my mind was so fuzzy at this point that I didn’t give onedrive-d enough credit to realize it was actually tracking what was happening in the file system. I didn’t setup the Ignore file because I didn’t realize what it was really for at the time. I thought I would have the opportunity to setup my preferences after starting the program via a GUI like in Windows, but I was wrong and assumed which is always a mistake. There actually is a GUI component, but it really isn’t anything like the one from Windows as it doesn’t help you setup which files you want to synchronize. I don’t know if there are plans for it in the future, but as of right now you can just ignore it as it is under developed.

Woops

At this point I saw that onedrive-d was actually working and it was downloading files, but of course it was downloading everything in my OneDrive account which I really didn’t want because there are Gigs of stuff I don’t need on this device.

Knee Jerk reaction

I stopped onedrive-d using the stop command and without thinking I deleted all the files that were just downloaded. This was a big huge mistake. I assumed that because onedrive-d was stopped it wasn’t tracking what I was doing… Well I am telling you it tracks what you are doing the moment you restart the process.

Making it worse

I modified the Ignore file at this point to stop onedrive-d from downloading the things I didn’t want it to download. I started onedrive-d again and nothing was happening? I stopped the process, tweaked the Ignore file, started the process, nothing was happening again and I did this several times in puzzlement. I was thinking to myself the whole time “Man this thing just isn’t working…”

The “OH SHIT” moment

I didn’t stop OneDrive on my main machine while I was working on getting onedrive-d setup on my Linux machine. Well… my main machine was working really really hard deleting everything in my OneDrive folder and I mean everything. I panicked and checked my OneDrive account online and I saw that all of my files were gone… Oh joy. This all happened because I deleted all of the stuff that I didn’t want to sync from my Linux machine. So ultimately this is my fault and I felt really dumb when I realized what I did.

Your only safety net

Luckily OneDrive online won’t delete files permanently and you can undo all deletes very easily. Additionally OneDrive will send you an email if it sees that you just deleted a large number of files. So there is nothing to permanently freak out about, but you still have to go through the pain of getting your affected machines back in sync with OneDrive.

Getting your affected machines back in sync with OneDrive

At this point I had done the following to mitigate the issues:

  1. Stopped OneDrive on my Windows machine
  2. Restored all of my files in my OneDrive account online from the Trash bin
    1. This step is critical because this is the master record
  3. Restored all of my files on my Windows machine from the Trash bin
    1. I did this so that I wouldn’t have to re-download ALL of my files all over again (GIGS!)
  4. Attempted to start OneDrive on my Windows machine again and let it run over night. This didn’t work, one drive crashed every time I would start it because it was confused for a lack of better description.
  5. I had to perform a full reset of OneDrive on my Windows machine using these instructions
  6. I let OneDrive run for as long as it needed to. Luckily at this point the executable stopped crashing and was synchronizing. It didn’t have to re-download a ton of files which is great.

Getting onedrive-d to behave at this point

Well at this point, now I knew how onedrive-d would react by me trying to outsmart it while it wasn’t running. Won’t make that mistake again and shame on me for assuming anything. I realized at this point the only thing I could is start over because I wouldn’t dare run it again at this point. So here is what I did:

  1. Using all of the cautionary steps I outlined above, make sure to stop OneDrive on your other machines before proceeding as a precaution
  2. Delete the unwanted files that were synchronized from your OneDrive folder (DO NOT start onedrive-d if you do this)
  3. Upon inspection I realized there is a SQLite database named “entries.db” that is being kept which has to be all of the transactions taking place in the file system
    1. I deleted this file located here: “/home/<username>/.onedrive/entries.db”
  4. I backed up my ignore file because hell if I want to set that up all over again
  5. I installed onedrive-d again, which is much faster at this point by executing the following commands:
    1. Open your ignore file in a text editor and keep it open (you will see why)
    2. user@machine ~ $ cd onedrive-d
    3. user@machine ~ $ ./install.sh install
    4. At this point your ignore file has been overwritten
      1. Go to your text editor and DO NOT reload the file
      2. Save the open file and it will overwrite the ignore file again with your settings
      3. If you make a mistake here it isn’t a big deal because you made a backup of your ignore file (RIGHT!?)
    5. user@machine ~ $ onedrive-pref
      1. Go through the setup steps like you did in the video
      2. The one drive link it provides is different every time, so you have to go through all the motions
      3. Make sure to provide the download location even though it is actually supposed to default (doesn’t appear to on a re-install, that was my experience)
    6. user@machine ~ $ onedrive-d start –debug
  6. Monitor what is being downloaded and ensure that your Ignore file is being adhered to
  7. If you made a mistake, start with step one again to avoid making the mistake I made

Conclusion

Wow what a pain in the ass I caused for myself. I will be more careful moving forward.

Thank you XYBU for this open source project.

 

Leave a Reply

Your email address will not be published. Required fields are marked *