Wednesday, October 28, 2009

Using Mendeley effectively on multiple systems using an external storage drive

If you do not already know, Mendeley is soon to become the defacto standard for storing, indexing, searching, ordering and sharing all your academic research papers. Its free download and easy to setup. Check the website to get a feel for it. I will not describe Mendeley here but will get to my point.

WARNINGS

The solution presented below worked for me. It may NOT work for you. There is destruction of state involved so please go through the complete post and decide for yourself. I am making certain assumptions about this solution, so make sure your assumptions match mine before trying this out.

Assumptions:
  • My environment is Mendeley Desktop v 0.9.4.1 running on Ubuntu 9.04.
  • I assume good familiarity with Linux and esp. Ubuntu.
  • I assume you have 2 working Mendeley setups on both systems. Will still work if you dont have but all steps may not apply.
  • I assume that you have access to the original data that you indexed with Mendeley.
  • The solution may break with future releases of Mendeley esp. if they change some of the document paths.
  • This solution may not easily port to Windows/ MAC though i believe the line of reasoning should still apply.
  • I have used Mendeley possibly since its first release and i am quite familiar with its interface / settings etc.

My Problem

I have 2 Ubuntu 9.04 systems (home and work) that i use for my research and i spend equal time on both of them. So i end up storing a lot of papers (my total collection is about 5000) on both. Once i discovered Mendeley (about 5-6 months back), i would index documents on both my systems separately and then sync up the bibliographies (and corresponding metadata like notes) with Mendeley Web (which is the online component of the Mendeley system). Now, though i had access to the full bibliography on both my systems, i could not access the corresponding documents on both systems i.e. i could only access documents on the system on which they were indexed.

Mendeley currently gives an online account with 500MB storage and allows storing documents in it. My collection is somewhere about 5GB and its not worth syncing that much anyway esp. since some of it is of proprietary nature. But i desperately needed a solution since i am so used to using Mendeley now and need it whenever i am doing my work.

So this is what i did:

Initial Setup
  • I got a 120GB external harddrive and formatted it with ext4 (filesystem doesnt matter).
  • Then I set the properties of the external drive to always mount as /media/extstor2. This ensures that we always have a constant path prefix whenever you attach the drive. This can be easily done by clicking properties of the drive, selecting Volume tab and fixing the mount point settings (works on Gnome).
  • Created two folders called db and papers on the new drive.
mkdir /media/extstor2/db
mkdir /media/extstor2/papers
On my home system
  • I first reset my complete database. WARNING: This will completely destroy the database (i.e. your bibliography and notes but NOT your documents). I hate this step but this was necessary because mendeley stores absolute paths to all its documents (you can dig into their sqlite3 database and see for yourself) and so if you just shift the database onto a new folder all references to documents get messed up. Even using the repair option of Mendeley doesnt fix this. This should be a good feature for them to add soon. 
mendeleydesktop --reset
    • After this i logged into my online account and deleted the entire collection from there. Note that if you have any notes attached to the document, this is the time to save them. There is no easy way to do that except cut and paste into some text editor.Note that the above step is essential because i think Mendeley has a bug where if it synchronizes again with the online account after you have created a new local database things get extremely messy and it crashes. Talking with experience here.
    • Now come the tricks:
    cd /media/extstor2/db
    mkdir Mendeley\ Ltd.
    cd ~/.local/share/data
    rm -rf Mendeley\ Ltd.

    ln -s /media/extstor2/db/Mendeley\ Ltd./ Mendeley\ Ltd.
    • What i am doing above is essentially repointing the database location to the external drive. Note that this also means that you will always require the external harddrive to use Mendeley.
    • Opened up Mendeley again. This time it should start with nothing in it and offer you to login into your online account. DO NOT LOGIN YET.
    • Opened Tools->Options and clicked on File Organizer.
    • Enabled the 'Organize My Files' tab and set the path to /media/extstor2/papers
    • Enabled other options as desired.
    • Now logged in to my online account and let it sync. Nothing should sync as nothing exists but it is good to let the desktop handshake with the web account.
    • I then added all my folders where i keep my collection. Luckily i had not deleted them.
    • After this i let Mendeley index my complete collection (takes time proportional to your collection and system speed). Took about 5-6 hours.
    • Once done, coped all the saved notes to the corresponding papers. Had to do manually :(.
    • Then i synchronized again with the online account.
    At this point we have a working database stored on the external harddrive. Now take this drive to your other system and proceed as follows:

    On the work system
    • Connected the drive to the system and mount it as /media/extstor2 to begin with.
    • Then set the properties of the external drive to always mount as /media/extstor2. This ensures that we always have a constant path prefix whenever you attach the drive. This can be easily done by clicking properties of the drive, selecting Volume tab and fixing the mount point settings.
    • Reset current database. 
    mendeleydesktop --reset
      • Tricks Again
      cd ~/.local/share/data
      rm -rf Mendeley\ Ltd.

      ln -s /media/extstor2/db/Mendeley\ Ltd./ Mendeley\ Ltd.
        • Opened up Mendeley.
        • Opened Tools->Options and click on File Organizer.
        • Enabled the 'Organize My Files' tab and set the path to /media/extstor2/papers
        • Enabled other options as desired.
        • Now logged in to my online account and let it sync. Now i saw everything just the same way as my home system.
        • Added your desired folders for watching files on my work system.

        That's it!!! Problem solved. Enjoy. Let me know if this solution solves somebody else's pain.