📜 ⬆️ ⬇️

About installing Crashplan in FreeNAS (and solving the Cyrillic problem)

annotation


I always considered Habr as a storehouse of valuable information in solving many problems. Therefore, faced with a problem and finding an adequate solution, I decided to share my experience . I did not try to write a manual, but rather a guide to action, but from my point of view and based on my needs. I hope someone will come in handy.


Prehistory


There are many solutions for self-assembled NAS, but I stopped at FreeNAS for several reasons:

So far I have no regrets about my decision, as I use it not only at home, but also at work.

I have been using Crashplan for a long time and have a paid subscription. I use both cross-archiving and archiving to the cloud. Used before the described events only under Linux and Windows.

Therefore, when I deployed FreeNAS (9.3), the second thing I tried to do after installing VirtualBox was to deploy Crashplan. And here I was waiting for a few surprises. When I first encountered the problem of installing Crashplan, I remembered about the old Fido's rake joke:
')
Classification okologabelnyh characters
User - a person advancing on a rake.
The kettle is a beginner user, who has never attacked rakes and therefore is confident that the rabbits do not exist.
Lamer is a user, regularly advancing on the rails, but still confident that the rabbits do not exist.
Narrow specialist - user, in complete possession of the attack on the same treads.
A broad specialist is a user with more than two cones on his forehead.
The programmer is the one for whom the result is most important in the attack on the rakes. Charter tread on other people's treads, manufactures their own.
An advanced programmer is a program that advances on each weight no more than two times.
Copywriting is a concept that limits the amount of available financial capabilities of the user.
The gamer is the one for whom the process is the most important in the attack on the rakes. Usually not able to make their own treads.
Cheater is a type of gamer; comes only on the rails with half-nozzles on the handle and usually no more than one time.
Hacker - the one who is able to step on the rails, even if they are hidden in a sarai and locked up.
A hacker-idealist is a benevolent warrior, for every one of them, to attack an unlimited number of rakes.
Microsoft - the corporation, the world leader in the production of rakes
Bill Gates is a mythical creature from programmer folklore; evil spirit - patron of rabbits.
Upgrade - a process of permanently spending money on the purchase of all new rakes, each of which beats more painfully than the previous ones.
Beta-version - a version in which the rakes are visible to the unaffected eye.
The release is a version in which the pile is covered with leaves.
Versatility is a principle that allows new treads to fall exactly on the bump from previous ones.
Assembler is a programming language that allows you to attack several millions of times per second.
A local network is a technology that allows you to get on your forehead, even when someone else comes on the ramp.
The Internet is a technology that allows you to step on the rails located on the other side of the globe.
A network conference is a technology that allows everyone to step not only on their own, but also on other people's profits.
Russian codings are an optional set of tolls for Internet users.
The interface is a rubber pad on the rake handle.
Flexible (adjustable) interface - pad on the handle with rakes, which can be moved, adjusting to the height of its forehead.
Graphic interface - the rake, allowing to regulate color and intensity of sparks after striking the forehead.
An unreliable system is a rake that hits you even when you do not step on them.
Reliable system - the raids that beat you on the forehead, even when you stand with their backs to them.
Multitasking is a concept that allows you to attack several rakes simultaneously.
Object-oriented programming is the method of making rakes on the basis of a matryoshka.
The manual is a book describing the various ways of attacking a rake. Never used by lamers and hackers. The advanced programmers use it after they step on the same treads a second time.
Tech support is a service that gives advice on what to do after stepping on rakes. Usually her first advice is to step on the rails once more and compare the sensations.

And there were several rakes (as well as bumps from them).

The first bump (or everything is so bad with Cyrillic)


Looking at
list of plugins

We see that there is a Crashplan plugin available. So we try to put it.

We take “How-to: Crashplan & Freenas” as a basis, shamanim and dance with a tambourine - Update Crashplan , that is, do not forget about the need for the /usr/pbi/crashplan-amd64/share/crashplan/bin/run.conf file both lines
such a parameter
-Djava.nio.channels.spi.SelectorProvider = sun.nio.ch.PollSelectorProvider
the file will look something like this
SRV_JAVA_OPTS = " -Djava.nio.channels.spi.SelectorProvider = h.xio.ch.PollSelectorProvider -Dfile.encoding = UTF-8 -Dapp = CrashPlanService -DappBaseName = CrashPlan -Xms20m-hr-hr-hr-off, 5 hr-rshPlanService Dsun.net.inetaddr.ttl = 300 -Dnetworkaddress.cache.ttl = 300 -Dsun.net.inetaddr.negative.ttl = 0 -Dnetworkaddress.cache.negative.ttl = 0 -Dc42.native.md5.enabled = false "
GUI_JAVA_OPTS = " -Djava.nio.channels.spi.SelectorProvider = sun.h.pl.P. Dsun.net.inetaddr.ttl = 300 -Dnetworkaddress.cache.ttl = 300 -Dsun.net.inetaddr.negative.ttl = 0 -Dnetworkaddress.cache.negative.ttl = 0 -Dc42.native.md5.enabled = false "

Connect and see that Cyrillic is incorrectly displayed:
we see kryakozyabry


Here is our "bump".

Finding a solution


Finding a solution to the forehead (with the help of Google) led to the fact that I am not alone in my problem: "FreeBSD + CrashPlan + / compat / linux = krakozyabry . "
There were several possible solutions:
  1. Try to set the correct Cyrillic display in the plugin.
    Discarded
    Plugines are made as pbi-files, which, when deployed, do not use standard jail directories, but build additional ones. Attempting to sort things out did not lead to anything, I was drowned in the complexities of the structure and decided not to continue.
  2. Install linux-jail from templates.
    Discarded
    In version 9.3, templates from 9.2 did not work normally (I tried Debian and CentOS) - the network in jails did not want to work at all, which is a pity.
  3. Run in VirtualBox Linux (for example, Debian).
    Postponed
    In VirtualBox of FreeNAS, you can run only a 32-bit kernel. This is not a hindrance, but somehow mounting directories to a virtual machine is necessary. There are several options: nfs (problem with nested datasets), smb / cifs (most working solution, but smb-balls require, but this is not always possible), VirtualBox share-resources (for some reason, they do not always work). Postponed this decision in case of emergency.
  4. Install a clean jail and run Crashplan in it through a BSD-Linux emulator.

Honestly, I tried all the options (and in that order as indicated). Defeated clause 4, about which I will tell.

So is there a light at the end of the tunnel? (new rake)


The search for a solution led me to the article [How-To] CrashPlan in FreeNAS 9.1 Jail (tested on 32bit) , which was taken as a basis.
And so they went (or flew, as you like).

Preparatory work

All the moments of FreeNAS initial setup, after the first launch, I will omit, a lot has been written about this.
  1. Connect to FreeNAS via ssh.
  2. Check if the kernel module for Linux is loaded:
    kldstat | grep linux 

    If we see something like this:
     22 2 0xffffffff81d09000 46855 linux.ko 

    then we have already downloaded it, if not, then:
     kldload linux 
  3. Enable linux-compat in the system
    in the web interface
    Enabling linux-compat causes the linux.ko kernel module to automatically load, so the linux_load parameter can be omitted.

  4. Create a jail.
    creature
    The default settings, you can not change. Parameter «VIMAGE» leave enabled.



    And wait for the end of the installation



    The process takes 10-45 minutes.


Installing Crashplan and everything you need in jail

Actions are performed in FreeNAS ssh (unless otherwise noted).
  1. Determine ID of our jail
     jls 

    We get this answer


    From where it is clear that ID jail'a = 2.
  2. Connect to jail.
     jexec 2 /bin/tcsh 

  3. Update packages and ports in jail
     pkg update pkg upgrade portsnap fetch extract 

    We are waiting for completion.
  4. Install the nano editor (vi lovers skip this item)
     cd /usr/ports/editors/nano make install clean 

  5. Install the fedora-linux emulator
     cd /usr/ports/emulators/linux_base-f10/ make install clean 

  6. Install the procfs emulator
     cd /usr/ports/sysutils/linux-f10-procps/ make install clean 

  7. Install JRE for linux
     cd /usr/ports/java/linux-sun-jre17 make install clean 

    and get
    an error


    This is due to the fact that Orakl has forbidden to download this file directly. Therefore, go to this link and download the file jre-7u75-linux-i586.tar.gz (do not forget to agree with their license). The downloaded file must be placed in the / usr / ports / distfiles directory ( jail path) or in FreeNAS in the / <jail path> / <jail name> / usr / ports / distfiles directory (for example, I have / mnt / poolz / jail / crashplan / usr / ports / distfiles )
    And repeat
     cd /usr/ports/java/linux-sun-jre17 make install clean 

    And wait for the end of the installation.
  8. Mounting procfs for linux in FreeNAS
    We leave from jail'a
     exit 

    We fall into the FreeNAS command line. Remount the root filesystem in write mode:
     mount -uw / 

    Create a procfs mount script:
     nano /conf/base/etc/rc.d/mountproc 

    Script text (subject to change)
     #!/bin/sh # PROVIDE mountproc # REQUIRE LOGIN # BEFORE: ix-jail . /etc/rc.subr name=mountproc rcvar=mountproc_enable start_cmd="${name}_start" stop_cmd="${name}_stop" mountproc_start () { /sbin/mount -t linprocfs linproc /mnt/poolz/jail/crashplan/compat/linux/proc/ } mountproc_stop() { echo "--- mountproc stopped ---" } load_rc_config $name run_rc_command "$1" 


    Important! Check that the mountproc_start command starts from the first position in the line!
    You change the path / mnt / poolz / jail / crashplan / compat / linux / proc / to your own (as in the previous paragraph).
    Making the script executable:
     chmod +x /conf/base/etc/rc.d/mountproc 

    And turn on the autorun script
    how to turn on


  9. Whether we check everything is done correctly (first of all, the text of the script) and overload FreeNAS.
  10. After reboot, check if our settings are enabled:
     kldstat | grep linux mount | grep linprocfs 

    If after the second command we do not see a line like this:
     linprocfs on /mnt/poolz/jail/crashplan/compat/linux/proc (linprocfs, local) 

    then go back to the script creation item and look for the error.
    If all is well, then continue.
  11. We put Crashplan
    Go to jail (similar to the first two points):
     jls jexec <jail_id> /bin/tcsh 

    Go to the directory / compat / linux , download Crashplan, unpack and install:
     cd /compat/linux fetch http://download1.us.code42.com/installs/linux/install/CrashPlan/CrashPlan_3.7.0_Linux.tgz tar -xzf CrashPlan_3.7.0_Linux.tgz cd CrashPlan-install /compat/linux/bin/bash /compat/linux/CrashPlan-install/install.sh 

    We read the license agreement and agree with it.
    In principle, you can leave everything by default. If you want to change something - change it, only carefully!
    After installation, the CrashPlan_3.7.0_Linux.tgz file and the CrashPlan-install directory from the / compat / linux directory can be deleted, they are no longer needed.
  12. We edit run.conf Crashplan'a.
     nano /compat/linux/usr/local/crashplan/bin/run.conf 

    At the beginning of each line, after the characters SRV_JAVA_OPTS = " and GUI_JAVA_OPTS =" insert
    -Djava.nio.channels.spi.SelectorProvider = sun.nio.ch.PollSelectorProvider .
    As a result, should receive:
     SRV_JAVA_OPTS="-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Dfile.encoding=UTF-8 -Dapp=CrashPlanService -DappBaseName=CrashPlan -Xms20m -Xmx1024m -Djava.net.preferIPv4Stack=true -Dsun.net.inetaddr.ttl=300 -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.negative.ttl=0 -Dnetworkaddress.cache.negative.ttl=0 -Dc42.native.md5.enabled=false" GUI_JAVA_OPTS="-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Dfile.encoding=UTF-8 -Dapp=CrashPlanDesktop -DappBaseName=CrashPlan -Xms20m -Xmx512m -Djava.net.preferIPv4Stack=true -Dsun.net.inetaddr.ttl=300 -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.negative.ttl=0 -Dnetworkaddress.cache.negative.ttl=0 -Dc42.native.md5.enabled=false" 

  13. Fix the path to java to the correct one.
    By default, Crashplan uses the path / usr / local / crashplan / jre / bin / java
    We will change to the java path installed from the ports /usr/local/linux-sun-jre1.7.0/bin/java
     nano /compat/linux/usr/local/crashplan/install.vars 

    In the variable JAVACOMMON, we change the path to /usr/local/linux-sun-jre1.7.0/bin/java
    It should be like this
     TARGETDIR=/usr/local/crashplan BINSDIR=/usr/local/bin MANIFESTDIR=/usr/local/var/crashplan INITDIR=/etc/init.d RUNLVLDIR=/etc/rc.d INSTALLDATE=20150314 APP_BASENAME=CrashPlan DIR_BASENAME=crashplan JRE_X64_DOWNLOAD_URL=http://download.code42.com/installs/proserver/jre/jre-7u45-linux-x64.tgz JRE_I586_DOWNLOAD_URL=http://download.code42.com/installs/proserver/jre/jre-7u45-linux-i586.tgz JAVACOMMON=/usr/local/linux-sun-jre1.7.0/bin/java 


  14. We check the performance.
    From jail
     /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine start /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine status 

    From FreeNAS
     jexec <jail_id> /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine start jexec <jail_id> /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine status 

    If at startup we received "ok" and we see a lot of PIDs when checking the status, then everything works.
  15. Setting up Crashplan autorun
    Go to jail:
     jexec <jail_id> /bin/tcsh 

    Create an autorun script:
     nano /etc/rc.d/crashplan 

    Script text
     #!/bin/sh # PROVIDE crashplan # REQUIRE LOGIN . /etc/rc.subr name=crashplan rcvar=crashplan_enable start_cmd="${name}_start" stop_cmd="${name}_stop" crashplan_start() { /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine start } crashplan_stop() { /compat/linux/bin/bash /compat/linux/usr/local/crashplan/bin/CrashPlanEngine stop } load_rc_config $name run_rc_command "$1" 

    We check that the crashplan_start and crashplan_stop commands are in the first position of the line!

    Making the script executable:
     chmod +x /etc/rc.d/crashplan 

    We edit the rc.conf script.
     nano /etc/rc.conf 

    Add a string
     crashplan_enable="YES" 

    Along the way we rule
     sshd_enable="YES" hostname="crashplan" 

    to enable SSH and set the host name for us.
  16. Connection of storage folders in jail.
    How to connect folders in jail is well described in the documentation .
    It is important to remember that the root file system for Crashplan is not the jail root ( / directory), but the / compat / linux directory !!!
    That is, it is necessary to connect, for example, not to the / mnt directory, but to the / compat / linux / mnt directory, otherwise Crashplan will not see your directories.
    And do not forget that nested datasets must also be registered!
  17. The final touch for ssh.
    Set a password for root:
     passwd 

    Important! On FreeBSD (and FreeNAS jail), root login via ssh is prohibited. To log in via ssh, you need to either add a user (by including him in the wheel group, allow him to su ) or edit the / etc / ssh / sshd_config file. In terms of security, the first option is more literate.
    I will not tell you how to use the adduser command, but will talk about the second option.
    Editing the sshd_config file:
     nano /etc/ssh/sshd_config 

    Looking for the string
     #PermitRootLogin no #PasswordAuthentication no 

    and change to
     PermitRootLogin yes PasswordAuthentication yes 

    Save and run SSH:
     service sshd start 

    or restart:
     service sshd restart 



Crashplan setup

Check whether Crashplan is running, if not, then run.
The connection and setup itself is well described in USING CRASHPLAN ON A HEADLESS COMPUTER .
If it is necessary for someone, I can paint.

And after connecting, we look at the result.
Hooray! Earned!



After rebooting, everything works!

PS I would like to hear constructive criticism.

PPS Fixed errors in scripts

Source: https://habr.com/ru/post/253235/


All Articles