Sunday, May 1, 2011

Installing Unison on a Synology DS411j NAS

Since my full-tower 10 hdd raid5 server is apparently making too much noise and polluting the air in the room too much (can't imagine why, just because it has 6 fans?), I bought a NAS as a first step towards replacing the server with something less.. bulky. I got a Synology DS411j NAS, and have spent the last 24h moving data around so that I could use 4 existing WD 1.5 TB drives in it. Seems to be working very well so far and the Synology web gui (DSM) is quite impressive. However, it doesn't have Unison and if there is one thing I need it's Unison!

Luckily it is possible to install it:

  1. Follow the Synology guide for installing ipkg/bootstrapping your NAS. (The DS411j has a Marvel Kirkwood mv6281 ARM processor.)

  2. Install the required packages with: ipkg install ocaml make gcc

  3. Now the tricky part, for me Unison didn't compile initially due to errors in /opt/arm-none-linux-gnueabi/lib/libpthread-2.5.so. Somehow this library is not the correct version, but the correct version IS installed in /lib.
    Fix this by deleting the symlink /opt/arm-none-linux-gnueabi/lib/libpthread.so.0, and creating a new one to /lib using: ln -s /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/libpthread/

  4. Then download the unison source code somewhere (eg /volume1/@tmp), go there and run: make UISTYLE=text NATIVE=false

  5. There might be some error messages, but in the end a functional unison binary is created!

  6. Copy the binary to for example /opt/bin. Set up SSH keys for the root account, and we're all set!

16 comments:

  1. unison auf Synology DS211...

    Um meine Daten immer synchron zu halten hab ich auf meiner Synology DS211 unison nach dieser Anleitung installiert. Die folgende Library Fixes waren nötig: Bevor: /opt/arm-none-linux-gnueabi/lib/libpthread.so.0 -> libpthread-2.5.so Danach: ln -s...

    ReplyDelete
  2. Hi there,

    I tried the steps above on a DS211j and unison 2.40.63 sources,
    but got stuck linking with the following error:

    ocamlc -I lwt -I ubase -I system -I system/generic -I lwt/generic -custom -g -ccopt "-o "/volume1/@tmp/unison-2.40.63/osxsupport.o -c /volume1/@tmp/unison-2.40.63/osxsupport.c
    ocamlopt: pty.c ---> pty.o
    ocamlc -I lwt -I ubase -I system -I system/generic -I lwt/generic -custom -g -ccopt "-o "/volume1/@tmp/unison-2.40.63/pty.o -c /volume1/@tmp/unison-2.40.63/pty.c
    ocamlopt: bytearray_stubs.c ---> bytearray_stubs.o
    ocamlc -I lwt -I ubase -I system -I system/generic -I lwt/generic -custom -g -ccopt "-o "/volume1/@tmp/unison-2.40.63/bytearray_stubs.o -c /volume1/@tmp/unison-2.40.63/bytearray_stubs.c
    Linking unison
    ocamlc -verbose -I lwt -I ubase -I system -I system/generic -I lwt/generic -custom -g -o unison unix.cma str.cma bigarray.cma ubase/rx.cmo unicode_tables.cmo unicode.cmo bytearray.cmo system/system_generic.cmo system/generic/system_impl.cmo system.cmo ubase/projectInfo.cmo ubase/myMap.cmo ubase/safelist.cmo ubase/uprintf.cmo ubase/util.cmo ubase/uarg.cmo ubase/prefs.cmo ubase/trace.cmo ubase/proplist.cmo lwt/pqueue.cmo lwt/lwt.cmo lwt/lwt_util.cmo lwt/generic/lwt_unix_impl.cmo lwt/lwt_unix.cmo case.cmo pred.cmo uutil.cmo fileutil.cmo name.cmo path.cmo fspath.cmo fs.cmo fingerprint.cmo abort.cmo osx.cmo external.cmo props.cmo fileinfo.cmo os.cmo lock.cmo clroot.cmo common.cmo tree.cmo checksum.cmo terminal.cmo transfer.cmo xferhint.cmo remote.cmo globals.cmo fpcache.cmo update.cmo copy.cmo stasher.cmo files.cmo sortri.cmo recon.cmo transport.cmo strings.cmo uicommon.cmo uitext.cmo test.cmo main.cmo linktext.cmo osxsupport.o pty.o bytearray_stubs.o -cclib -lutil
    + gcc -o 'unison' '-Llwt' '-Lubase' '-Lsystem' '-Lsystem/generic' '-Llwt/generic' '-L/opt/lib/ocaml' '/tmp/camlprim3e1bfe.c' '-lbigarray' '-lcamlstr' '-lunix' 'osxsupport.o' 'pty.o' 'bytearray_stubs.o' '-lutil' '-lcamlrun' -I'/opt/lib/ocaml' -lm -ldl -lpthread
    /opt/lib/gcc/arm-none-linux-gnueabi/4.2.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lpthread
    collect2: ld returned 1 exit status
    File "_none_", line 1, characters 0-1:
    Error: Error while building custom runtime system
    make: *** [unison] Error 2

    Any Idea, what's the problem here?

    regards, vans

    ReplyDelete
  3. Thanks for the tip, it worked for me on a DS211.

    ReplyDelete
  4. It's been a while since I did that, but are you sure the binary was not build? I remember getting a bunch of error messages, but in the end the binary was still built.

    ReplyDelete
  5. Hi,

    Any chance I can download the text arm binary for unison from you? Having problems compiling it on my nas.

    Kind Regards,
    wayne

    ReplyDelete
  6. Cool it works!

    I have a DS1511+ (i686 processor) and it worked like a charm. Step 3) was not required.

    Thanks a lot for your help!

    ReplyDelete
  7. It worked for DS411 after changing

    /opt/arm-none-linux-gnueabi/lib/libpthread.so.0 -> libpthread-2.5.so

    to

    ln -s /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/

    as suggested in the "trackbacks".

    I reveived the error messages "tr: not found" and "bash" not found" and "etags: not found" but the unison file was created anyway.

    Thanks! Thomas

    ReplyDelete
  8. Hi,
    Worked great for me with DS211.
    I had to use the following library fixes (from http://blog.thomas-lauria.de/archives/19-unison-auf-Synology-DS211.html):
    delete: /opt/arm-none-linux-gnueabi/lib/libpthread.so.0 -> libpthread-2.5.so
    create: ln -s /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/
    I also got some errors, but the binary was built.
    Moritz

    ReplyDelete
  9. I don't know if this is still checked, but I'm having problems with my DS212j running DSM 4.0. Even after installing ipkg and changing the libpthread.so.0 links, here is the error output:


    DiskStation> make UISTYLE=text NATIVE=false
    /bin/sh: tr: not found
    /bin/sh: tr: not found
    /bin/sh: bash: not found
    ./mkProjectInfo > Makefile.ProjectInfo
    /bin/sh: ./mkProjectInfo: not found
    make: *** Deleting file `Makefile.ProjectInfo'
    UISTYLE = text
    Building for Unix
    NATIVE = false
    THREADS = false
    STATIC = false
    OSTYPE =
    OSARCH =
    make tags
    /bin/sh: tr: not found
    /bin/sh: tr: not found
    /bin/sh: bash: not found
    make[1]: Entering directory `/volume1/@tmp/unison-2.40.61'
    ./mkProjectInfo > Makefile.ProjectInfo
    /bin/sh: ./mkProjectInfo: not found
    make[1]: *** Deleting file `Makefile.ProjectInfo'
    if [ -f `which etags` ]; then \
    etags *.mli */*.mli *.ml */*.ml */*.m *.c */*.c *.txt \
    ; fi
    /bin/sh: etags: not found
    make[1]: [tags] Error 127 (ignored)
    make[1]: Leaving directory `/volume1/@tmp/unison-2.40.61'

    No executable is built.

    Thoughts?

    ReplyDelete
  10. I haven't tried it with DSM 4.0 yet, but I have a new DS411+II running 4.0 so I'll try it with that one in a while. If I figure it out I'll post it here.

    ReplyDelete
  11. Hmm, maybe you can try installing bash before running make? Just a thought.

    ReplyDelete
  12. Also using DSM4.0 and having the same output as you. I was looking in /bin, /usr/bin, /opt/bin, but it turns out it was build in the sources folder (in my case /volume1/@tmp/unison-2.45.4/unison). You just have to copy the unison executable to e.g. /opt/bin yourself...

    ReplyDelete
  13. Just wanted to say thank you -- after researching a bunch of different links regarding unison, this ended up being the one that assisted me.

    Successful installation of optware IPKG and compiled unison 2.40.102 on Synology DS-409.

    ReplyDelete
  14. Same for me, came across your guide and could install unison 2.40.102 on a DS213 and a DS411slim, and a DS112 will follow soon. Just had to update the path of the symb.link a bit.
    So, thanks for you work!
    Best wishes!

    ReplyDelete
  15. Thanks a lot for this very valuable info.

    Note that you need to do the same with libdl now (on a DS212+):
    rm /opt/arm-none-linux-gnueabi/lib/libdl.so.2
    ln -s /lib/libdl.so.2 /opt/arm-none-linux-gnueabi/lib/

    ReplyDelete
  16. # I can confirm that the follwo worked for me on a DS212+ running DSM 5.0-4482
    # Note the extra libdl.so step to aviod 'undefined reference to `_dl_tls_get_addr_soft@GLIBC_PRIVATE'' errors

    ipkg install ocaml make gcc textutils

    rm /opt/arm-none-linux-gnueabi/lib/libpthread.so.0
    ln -s /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/

    rm /opt/arm-none-linux-gnueabi/lib/libdl.so
    ln -s /lib/libdl.so.2 /opt/arm-none-linux-gnueabi/lib/libdl.so

    cd /volume1/@tmp
    wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/unison-2.40.65/unison-2.40.65.tar.gz

    tar xf unison-2.40.65.tar.gz
    cd unison-2.40.65/

    make clean
    make mkProjectInfo
    make NATIVE=false UISTYLE=text CFLAGS="-cclib -L/lib"

    cp ./unison /opt/bin/

    ReplyDelete