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

Leave a Reply

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