CrashPlan on FreeNAS using Iohyve

The better way to run CrashPlan on your FreeNAS…

With the 9.10 version of FreeNAS, comes a better way to virtualize functionality on your FreeNAS server. It also allows us to move away from the headaches we have seen with the Jails, particularly with the CrashPlan. The CrashPlan jail has required too many hours of tinkering with every upgrade, and after seeing everything break with the release of CrashPlan version 4.8, I decided there must be a better way to back up my data on my NAS.

The solution resides with Iohyve – a built in hypervisor that allows you to run virtual machines.

The first step is to ssh into your FreeNAS installation and identify the zpool you wish to install your virtual machine on – I have added a separate pool running on an SSD disk within my environment, and named the SSD storage zpool “SSD”.

zpool list

iohyve_set_con

 

Identify the correct zpool name in your environment.

Next, run the setup of iohyve on your identified zpool:

iohyve setup pool=SSD

setup

 

You also need to identify the correct interface, to bridge your VM to:

ifconfig

Once identified, set the interface to bridge your VM to, and set the correct kernel module to load:

iohyve setup net=alc0 kmod=1

 

Now create the ubuntu host (named ubuntu_crashplan), allocating 20GB of disk space:

iohyve create ubuntu_crashplan 20G SSD

create

 

Next we need to set the correct parameters for Ubuntu, first allowing to boot with grub, set the OS as debian based, configure the RAM, CPU count, and the con parameter (adjust RAM and CPU as needed):

iohyve set ubuntu_crashplan loader=grub-bhyve os=debian ram=1024M cpu=1 con=nmdm1

set_parameters

 

Now we need to fetch the ISO to install (or copy the link to your preferred version of ubuntu):

iohyve fetchiso http://releases.ubuntu.com/16.04/ubuntu-16.04.1-server-amd64.iso

Then install the ISO image

iohyve install ubuntu_crashplan ubuntu-16.04.1-server-amd64.iso

install_ubuntu

Give the installer a minute to start, then open up a second SSH session to your FreeNAS, and run the console command to connect to the new virtual machine:

iohyve console ubuntu_crashplan

ubuntu-setup

Step through the installer as normal, but once you arrive to the software selection screen of the installer, you may choose “OpenSSH server” to allow direct access to the virtual machine.

Once the installer completes, reboot the new virtual machine.

 Verify the status:

iohyve list

Start the virtual machine:

iohyve start ubuntu_crashplan

Set a static IP if you prefer, or set a DHCP reservation within your firewall. Then either SSH into your new ubuntu server or use the “iohyve console ubuntu_crashplan” command to gain access.

We have several considerations, before implementing CrashPlain:

  1. What paths do we want to mount?
  2. What file system do we use to mount these paths?

In my environment, I will be making the following mounts, with the mkdir command:

/mnt/Movies

/mnt/TV

/mnt/Photos

/mnt/Restore

We will then need to mount the appropriate folder to be backed up on the FreeNAS to the created mount points.

Example mounts of shares using CIFS

In my example, I am going to use CIFS and a separate service account to mount to the share:

sudo apt-get update

sudo apt-get install cifs-utils

Create a samba user:

sudo nano /etc/samba/user

Create (2) lines in the credentials file (I created an account with read-only permissions within FreeNAS for the SMB share)

username=samba

password=password

Use “control+o” to write the file, and “control+x” to exit from Nano.

Set the new user file to read only:

sudo chmod 0400 /etc/samba/user

Backup your fstab file:

sudo cp /etc/fstab /etc/fstab.bak

Edit your fstab file:

sudo nano /etc/fstab

We will need to add the various mount points on your FreeNAS with their associated path on your CrashPlan server. Please note that if you have a share name with a space, you must substitute the space with “\040” in your fstab file. For example:

//192.168.1.10/FreeNAS/Music\040Videos/ /mnt/Music_Videos/ cifs crednetials=/etc/samba/user,noexec 0 0

fstab_example

Suggestion: You will want to map out a restore folder to your NAS. That will direct downloaded files to your NAS instead of the 20GB virtual machine disk. For example, I created a /mnt/Restore directory on the CrashPlan VM that maps to a Downloads folder on my NAS.

Enter your mount points and mappings, and reboot your server to test. Once everything is mapped out correctly, you can install CrashPlan:

cd /tmp/

wget https://download.code42.com/installs/linux/install/CrashPlan/CrashPlan_4.8.0_Linux.tgz

tar -xzf CrashPlan_4.8.0_Linux.tgz

cd /crashplan-install/

sudo ./install.sh

Now we should be prompted with the CrashPlan installer. Use the defaults, except for the incoming backup data. I created a /mnt/Restore mapping in my example:

crashplan_installer

Once completed, some useful information:

crashplan_completed

Headless Setup:

Allow the server to listen to external connections:

sudo nano /usr/local/crashplan/conf/my.service.xml

Identify and change from:

<serviceHost>localhost</serviceHost>

To:

<serviceHost>0.0.0.0</serviceHost>

Copy the key from your Headless CrashPlan .ui_info file, and double checking the listening port:

cat /var/lib/crashplan/.ui_info

Into your local .ui_info on your computer.

This varies by operating system, so please refer to CrashPlan’s site for the file locations at:

https://support.code42.com/CrashPlan/4/Configuring/Using_CrashPlan_On_A_Headless_Computer

Once done, your client will have a .ui_info file that shows the correct port, the correct key, and the IP of the new virtual server. The virtual (and headless) server’s .ui_info will show the IP as 0.0.0.0 after we configure the my.services.xml file.

Complimentary .ui_info files – client on the left, server on the right:

ui_info_compared

Once these are in agreement, restart the crashplan service on the virtual server:

sudo service crashplan restart

Launch the local application from your machine with the correct .ui_info, and you should attach!

crashplan_intro

 

With this replacing a previous CrashPlan Jail, I simply adopted this computer after the login to replace my previous setup. All mount points were named to replicate the setup in the replaced FreeNAS jail.

Once you have connectivity between your client and your host, you can lock each .ui_info file with the immutable bit. For the Ubuntu Crashplan server, use:

sudo chattr +i  /var/lib/crashplan/.ui_info

For OS X, use:

sudo chflags nouchg /Library/Application\ Support/CrashPlan/.ui_info

This will lock both files, and prevent edits. To unlock the files, change the chattr attribute to “-i” (instead of +i) and the chflags attribute from “nouchg” to “uchg”.

 

3 thoughts on “CrashPlan on FreeNAS using Iohyve

  1. Anders Larsen Reply

    I have tried this a handful of times now, but still have no luck getting the ui on my mac to connect to the backup engine (running on Debian via iohyve).
    The token id’s match and I have verified that the server is listening on the correct port.
    Is there a log file somewhere I can look at to give me some clues as to what is missing? The error message from crashPlan is simply “Unable to connect to backup engine”.

    • Norman Kolk Post authorReply

      There are typically (3) items that need to be reviewed to ensure connectivity:

      1. The headless server is accepting connections from external hosts – this is set in the file: /usr/local/crashplan/conf/my.service.xml

      2. The keys agree from the server’s /var/lib/crashplan/.ui_info file with the client’s .ui_info file. The key can regenerate with restarts (server or service) so use the chattr command as outlined in my blog to keep the key static between devices

      3. Run netstat on the server to verify that it is listening on the correct port. Then verify that the .ui_info files on both side have identical ports and keys, and that the client is pointing to the server’s IP and that server is listening on 0.0.0.0

      All logs are located at: /usr/local/crashplan/log

      By using tail -f /usr/local/crashplan/log/service.log.0 I was able to witness the client connecting with the following entry:
      Loaded address=0.0.0.0, port=4244, and token from location=/var/lib/crashplan/.ui_info

      • Zach Reply

        Thank you! I’m especially grateful for the tip to use chattr to lock the .ui_info file.

Leave a Reply

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