FreeNAS + Crashplan

UPDATE

FreeNAS moved to github, and I have happily followed them :) You can find my fork at https://github.com/bionoren/freenas (look for build instructions in README-EXTRA on branches I’ve ported), and ISOs and other helpful files at https://github.com/bionoren/freenas-extra. Please report any future problems on github issues.


Want to run Crashplan on your FreeNAS box? If you’re using the x64 builds, you can either download the 8.3.0-RELEASE-P1 iso right now and skip to Setup Crashplan, or grab some coffee and start at the very beginning…

Setup Virtual Machine

  1. Create a new virtual machine (I used virtual box)
  2. Give it 1gb of memory and a 20gb dynamically sized disk (note: 512mb of RAM is not enough – it won’t crash, but it will take forever)
  3. Edit the VM settings and set the hardware clock to UTC time
  4. Configure any other settings you like[1]
  5. boot from FreeBSD image (FreeBSD-8.3-RELEASE-amd64-dvd1.iso)

Install FreeBSD

  1. Download and mount the FreeBSD install disk FreeNAS is based on (as of this writing, FreeBSD-8.3-RELEASE-amd64-dvd1.iso)
  2. Run the installer
  3. Select your region
  4. From the main menu, choose “Standard” install
  5. From the disk utilization menu, select “Use Entire Disk” and continue
  6. Select “BootMGR” as your boot manager and continue
  7. From the partitioning menu, select “Auto Defaults”
  8. Install the “Kern-Developer” packages
    1. select appropriate doc language
    2. Answer “Yes” to installing the ports collection
  9. Select Exit option
  10. Select CD/DVD install source
  11. commit, and wait a little while (~5 minutes)
    1. For “Configure ethernet devices”, just select whatever the first option is. IPv6 is optional, DHCP is not.
    2. Type a hostname when prompted, then keep hitting tab until Ok is highlighted (don’t worry about the other fields).
    3. Answer no to are you a “network gateway”
    4. No to “inetd”
    5. Yes to “SSH login”
    6. No to “anonymous FTP access”
    7. No to NFS server
    8. No to NFS client
    9. You can customize console settings if you want, but there’s not much to do there
    10. Set your time zone. Your clock IS in UTC (remember, we set that as part of the VM settings), then find your time zone. This isn’t technically necessary – your machine will still build on Costa Rica time – but it’s kind of nice.
    11. No “PS/2, serial, or bus mouse”
    12. No to browsing the ports collection now
    13. No to adding more user accounts
    14. Set a root password
    15. No to “Visit the general configuration menu”
  12. Exit install

Setup install environment

  1. Login as root (this will drop you to a CSH shell). It’s not strictly necessary, but I will assume bash, so lets install it:
    1. pkg_add -r bash
    2. which bash
    3. chsh -s [output of "which bash"] root
    4. exit
    5. login as root
  2. Install packages:
    1. pkg_add -r subversion
    2. pkg_add -r cdrtools
    3. (optional) pkg_add -r vim
    4. pkg_add -r wget
    5. rehash
  3. cd /usr/local
  4. svn co svn://svn.code.sf.net/p/freenas/code/tags tags
  5. go read a book (< hour)
  6. cd tags/8.3.0-RELEASE-p1/ (or whichever version you’re installing today)
  7. wget http://www.bionoren.com/freenas-files.zip
  8. unzip freenas-files.zip
  9. patch -p0 -i freenas.diff
  10. Setup environment (Note: you need to do this every time the VM starts)
    1. kldload linux.ko
    2. export OVERRIDE_LINUX_BASE_PORT=f10
    3. export OVERRIDE_LINUX_NONBASE_PORTS=f10
    4. export FREEBSD_CVSUP_HOST=cvsup10.freebsd.org

Build

  1. ./build/do_build.sh

wait ~5 hours (you can abort if you notice when it gets to building\compressing image)

Notes:

  • if the build dies in emulators_linux_base-f10, you probably forgot to kldload linux.ko
  • if the build dies in sysutils_linux-procps, you probably forgot to set one of the OVERRIDE_ environment variables
  • if packages don’t build, look in nanobsd/common and try things like this (around line 226): SRC_BASE=/usr/src \
    WRKDIRPREFIX=/usr/workdir -C /usr/ports/$port_path \
    clean package BATCH=yes -DUSE_PACKAGE_DEPENDS \
    - $* clean -DFORCE_PACKAGE -DFORCE_PKG_REGISTER"
    + $* clean -DFORCE_PACKAGE -DFORCE_PKG_REGISTER > buildlog.txt"
    rm ${NANO_WORLDDIR}/etc/resolv.conf
    rm -rf ${NANO_WORLDDIR}/usr/obj
    rm -rf ${NANO_WORLDDIR}/usr/workdir

    This will give you a file in /os-base/amd64/buildlog.txt with a log for the last package that tried to build. Well, a log for part of the effort, but you get the idea
  • ignore any warnings about prefetch being disabled

Build Java

  1. shutdown the virtual machine
  2. create a snapshot (in case something goes wrong)
  3. start the VM
  4. login as root
  5. Setup the environment again:
    1. kldload linux.ko
    2. export OVERRIDE_LINUX_BASE_PORT=f10
    3. export OVERRIDE_LINUX_NONBASE_PORTS=f10
    4. cd /usr/local/tags/8.3.0-RELEASE-p1/
  6. cat FreeBSD/ports/java/linux-sun-jre17/distinfo – make sure the jre file name in that output exactly matches the one you downloaded. Note that oracle tends to use *.gz instead of *.tar.gz. Just rename the file to *.tar.gz.
  7. cp jre* FreeBSD/ports/distfiles
  8. cp jre* os-base/amd64/ports/distfiles/
  9. patch -p0 -i freenas2.diff
  10. ./build/do_build.sh (~40 minutes)
    1. If the build dies installing java, you probably forgot to copy the jre* file somewhere, or you have the wrong jre file version
    2. if the build is aborted for any reason after java is built, you’ll need to shutdown and roll back to the pre-java snapshot before trying the build again
  11. ./build/create_iso.sh (~8 min)
  12. scp os-base/amd64/FreeNAS-8.3.0-RELEASE-p1-x64.iso user@ip:/destination/dir/
  13. shutdown the virtual machine

Upgrade FreeNAS

Follow Freenas’ install/upgrade instructions to install/upgrade FreeNAS

Setup Crashplan

  1. Boot freenas
  2. open a shell from the web GUI, or use ssh
  3. cd /mnt/somewhere/on/your/zfs
  4. download and unzip the FreeNAS files in somewhere/on/your/zfs[2]
  5. cp -Rp /compat/linux /mnt/somewhere/on/your/zfs/ (Note: it’s /compat/linux, not /compat/linux/)
  6. Download and extract crashplan for Linux
  7. copy the crashplan install folder to your NAS under /mnt/somewhere/on/your/zfs/linux/
  8. edit fstab to have the right path(s) for your crashplan archive directories and your linux folder at /mnt/somewhere/on/your/zfs/linux
  9. bash /mnt/somewhere/on/your/zfs/setup.sh (ignore error messages related to crashplan)
  10. cd /compat/linux
  11. ./bin/bash
  12. cd CrashPlan-install
  13. ./install.sh – use relative paths from /compat/linux/, not full NAS paths (i.e. /usr/local/, not /mnt/somewhere/on/your/zfs/linux/usr/local)
  14. edit /compat/linux/usr/local/crashplan/bin/run.conf and modify two lines to end with this:SRV_JAVA_OPTS="...
    -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider"
    GUI_JAVA_OPTS="...
    -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider"
  15. /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine start
  16. Follow Crashplan’s instructions to connect to a headless client
  17. Enjoy! :)

Starting after a reboot

run bash /mnt/somewhere/on/your/zfs/setup.sh to mount everything and start crashplan.
Eventually, I’ll put together a cron job to check if /compat/linux/ is mounted, and run setup.sh if it isn’t

Sources:



[1]For reference and time comparison purposes, I gave my VM 8 processors (2Ghz Core i7) with a 95% execution cap and enabled PAE/NX support. I’m also on an SSD. Note: the VM will use 4 core pretty much the whole time, and all 8 only rarely. That may have something to do with hyper-threading though.
[2]You can delete all the files from the *.zip you downloaded except setup.sh and fstab.

About Bion

I'm a software developer at Modo Payments, a mobile payment provider. When I'm not hacking away the office, you I'm usually at home hacking on something else. Or practicing Aikido. Anyway, I just post things here that Google couldn't help me with, so maybe it'll help you in the future. Since you're reading this, I guess it worked :)
This entry was posted in Technology and tagged , . Bookmark the permalink.

18 Responses to FreeNAS + Crashplan

  1. Fracai says:

    Thanks for pulling this together. I’ve wanted CrashPlan on my FreeNAS box since I put it together.

    This install would be even easier though if it was available as a jail plugin. Is there any chance you’d consider putting that together? The only downside that I can think of is the requirement to set mount points for every dataset you want to backup, but the wasier integration with FreeNAS would more than make up for that.

    Thanks again for your work so far here.

    • Bion says:

      I looked into that before embarking on this solution, and the unfortunate answer is no, it’s not possible (well, it’s really annoyingly hard anyway, and there’s not much benefit).

      You need the linux compatibility environment to set up the /proc stuff that Crashplan expects (as well as Java, although that may not be a hard requirement). This means that you need the linux.ko and linprocfs.ko kernel extensions loaded. Alas, they will not load – I am not the first down this road. This seems to be because we need i386 kernel support, and nobody built that into the x64 kernel. (You get messages about “exec format error”. See http://permalink.gmane.org/gmane.os.freebsd.stable/82416, http://lists.freebsd.org/pipermail/freebsd-questions/2010-July/219614.html, and others).

      The recommendation is to recompile your kernel, which you can do on a running FreeBSD system, if you have kernel source (which we don’t), or if you can get kernel source (which is tricky, because none of the BSD download mirrors know about this “FreeNAS” system name). So, I went back a step further and looked at the FreeNAS build-from-source process, which eventually produced this monstrosity.

      So now, since I’m rebuilding FreeNAS, there’s not much point in making a plugin anymore. I mean, in principle you could, but you have to create something that walks and talks like a BSD port (so you can use the plugin build tools) without actually getting it approved as a port (because nobody would approve it – it’s too application-specific). And you’ll either need to store your backups in the plugin jail (not my preference) or do some more mounting to try and bypass the jail. All so you can get a pretty button in the web interface to start/stop crashplan. Bleh. That’s why I stopped here :)

      • fracai says:

        Well… that’s… a pretty good reason. And too bad it’s that complicated.

        If it’s just /proc that leads to requiring the recompile it’ll hopefully get easier in the future. The Crashplan support site lists that they hope to relax the Linux requirements in their “next release”. Though it’s been that response for quite a while. Presumably that next release would make BSD support easier.

        Anyway, thanks again.

  2. Joshua says:

    You are my hero. I use CrashPlan on all of my systems and was just starting the process of planning/building a new NAS system. This makes my day and I will be trying it out as soon as I’ve gathered hardware.

    Do you have a donation link so I can buy you a beer? :D

  3. Roee says:

    Thanks! Your image worked for me.

    However, you might want to refine step 9 in Crashplan Setup (it’s not clear where the fstab should reside and what paths need updating). Also in step 15 I missed the ‘-‘ before ‘Djava’. Took me a while to figure why Crashplan was not started. You might want to fix that as well.

    • daddyo says:

      I seem to be stuck at his point as well. BTW, I created a VM with the same file structure you have to keep it simple: /mnt/somewhere/on/your/zfs/ and I have the fstab file from the “freenas-files” download in this folder. Any help would be great.

  4. Geoffrey says:

    I’m trying to follow your instructions and I have FreeNAS-8.3.1 installed right now.

    I’m stuck on the step where I’m suppose to copy the files in the /compat/linux/ folder as it doesn’t seem to exist?

    Thanks!

    • Bion says:

      The image I built is for 8.3.0, so you obviously can’t use that and will need to start all the way at the beginning with “Setup Virtual Machine” to build your own custom image of FreeNAS-8.3.1 (basically because you need to patch your kernel, but installing the emulation environment from FreeNAS is also non-trivial).
      Of course, this isn’t tested, because I’m still single-mindedly trying to install Java with a poll provider that doesn’t suck (getting close!), so let us know if you run into trouble.

      (In the event you did start from the top, make sure the patches added the linux-base-f10 port to nanobsd/os-base file, and confirm you see it in the build log (it’s around package 150 in the 8.3.0 build. Another way to check would be to build without linux.ko loaded (it should error out then). You could also poke around in os-base/ after the build and see if you can find it in there (or at least an _.cust.add_port_* log file)

      • Geoffrey says:

        Where do I need fstab to reside? It seems like its looking for it in /root but I can’t copy it there.

      • Geoffrey says:

        I think I got the fstab to work. Here is the current error I am getting.

        http://tinypic.com/r/2a7eio4/5

        • Bion says:

          Right. FreeNAS runs on a read only file system, but Crashplan expects to be running on a read/write file system. For reasons I won’t go into, you don’t want to run FreeNAS read/write all the time, so you should install Crashplan in a separate directory in your zpool somewhere. Then, modify the fstab file you downloaded in “Setup Crashplan” step 4 with the appropriate directory path(s) for Crashplan (I included 2 storage locations because that’s how my dataset works, but you probably only use 1 so delete the extra) and try again

        • Aaron says:

          Any chance you could share your 8.3.1 x64 build?

          • Bion says:

            Sorry it’s taken me so long. I’ve published some experimental builds of 8.3.1 on github (see update and link at the top of the article). The more traditional compatibility environment build should be up in the next week. Thanks for your interest!
            EDIT: It’s up!

  5. fracai says:

    With FreeNAS 9.1 in Release Candidate, I was wondering if you’ve experimented at all with the Linux jail support that is now present. It currently looks like Linux jail configuration isn’t going to make it into the GUI, but CLI config should still be available. Does this make anything easier or more compatible?

  6. Great writeup – thanks for going to such amazing detail in this post!

    In our never-ending quest to make FreeNAS easier to use and render “howtos” like this obsolete, however, we have now created a CrashPlan plugin that should be very easy to use. Given that you are clearly a domain expert here, would you mind perhaps trying it out and letting us know if we’ve hit the target or not?

    Thanks!

    • Bion says:

      Thanks for the nudge – this has been on my todo list for awhile, but I’ll try to get to it this weekend. At least the forum posts look promising :)

Leave a Reply to Geoffrey Cancel reply

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