This is a quick guide on how I configured rar2fs on my FreeNAS-220.127.116.11 and shared a rar2fs directory using Samba. My disk is mounted on /mnt/vol1.
Did some tests on my “a few years old hardware” and I got average file transfer speeds around 50 MB/s using cifs.
*** EDIT: THERE IS A QUICK WAY, SEE ‘THE QUICK WAY’ AT THE BOTTOM ***
I found that fusefs-kmod and fusefs-libs packages comes with the FreeNAS embeded install – nice. The module is however not loaded by default.
This can be verified with this command:
>kldstat | grep fuse
27 1 0xffffffff81aaa000 aa63 fuse.ko
That row will not be returned by default.
Load the module with command “kldload fuse.ko”.
To be able to add the rar2fs binary to /usr/local/bin/ and the unrar library to /usr/local/lib/ you need to use unionfs.
First create a directory on your data disk which you can use to mount to /usr/local
>mkdir -p /mnt/vol1/opt/usr_local
Now mount the drive with command:
>mount_unionfs /mnt/vol1/opt/usr_local /usr/local
Note: If you also like to install ports using pkg_add , you also need create directory /mnt/vol1/opt/var and do a mount_unionfs /mnt/vol1/opt/var /var .
Now create a directory somewhere to put the source for unrar, fuse and rar2fs.
>mkdir -p /mnt/vol1/opt/build
Download the needed files.
See: http://sourceforge.net/projects/fuse/files/fuse-2.X/ (In my case 2.9.3)
See: https://code.google.com/p/rar2fs/ (in my case 1.20.0)
>tar zxvf fuse-2.9.3.tar.gz
>tar zxvf unrarsrc-5.2.1.tar.gz ; cd unrar
For some reason I needed to edit the makefile and make the below changes, otherwise I got some errors, not sure if it is due to differences between linux and freebsd. (Using gmake may also work but its not included in freenas embeded)
Change row 98:
Comment out these 2 rows around row number 134.
Compile and copy the unrar library.
>make lib -f makefile
If I remember correctly, I got some make error regarding missing lgcc , I solved it by creating a temporary mount like “mount_unionfs /mnt/vol1/opt/usr/lib /usr/lib” and then a “ln -s /usr/lib/libgcc_s.so /lib/libgcc-something”. Only needed when building libunrar.
>cp libunrar.so /usr/local/lib/
Now you can compile rar2fs.
>tar zxvf rar2fs-1.20.0.tar.gz ; cd rar2fs
> ./configure –with-fuse=/mnt/vol1/opt/build/fuse-2.9.3/include –with-fuse-lib=/usr/local/lib –with-unrar=/mnt/vol1/opt/build/unrar –with-unrar-lib=/usr/local/lib
>cp rar2fs /usr/local/bin/
Try if its working (don´t forget to do a kldload fuse.ko first):
>/usr/local/bin/rar2fs /mnt/vol1/path/to/your/rars/dir /mnt/vol1/rar2fs_myrars
rar2fs: mounted /mnt/vol1/rar2fs_myrars
If its not working, you can add “-o debug” to run it in debug mode.
If it is working, unmount your rarfs with “umount /mnt/vol1/rar2fs_myrars”.
Now create a startup script to run at freenas start. I added it to /mnt/vol1/opt/rar2fs.sh , dont forget to chmod 755 rar2fs.sh.
I´ve added seek-length=1 option to rar2fs for performance reasons.
The allow_other option is needed for non-root access to the file system. If you want to browse it with samba, you need this option.
#!/bin/sh echo "Loading module fuse.ko ..." /sbin/kldload fuse.ko echo "Mounting unionfs filesystem /mnt/vol1/opt/usr_local => /usr/local ..." /sbin/mount_unionfs /mnt/vol1/opt/usr_local /usr/local # Uncomment below if you want this as well. #echo "Mounting unionfs filesystem /mnt/vol1/opt/var => /var ..." #/sbin/mount_unionfs /mnt/vol1/opt/var /var echo "Starting rar2fs ..." /usr/local/bin/rar2fs --seek-length=1 -o allow_other /mnt/vol1/path/to/your/rars/dir /mnt/vol1/rar2fs_myrars
Create a init script in FreeNAS. Go to System / Add Init/Shutdown scripts.
Reboot your freenas box.
You can check the console output and you should see the script output like “Starting rar2fs …” etc. (Make note of any error messages)
If your rar2fs mounts well, share it using CIFS if you like.
Note: Sharing using NFS is not working according to some forum threads, something about NFS interacts with the filesystem differently.
You can also add the rar2fs filesystem as storage to a freenas jail, like Plex 🙂
UPDATE: Someone told me that gcc isnt a part of FreeNAS 9.3 , I haven´t confirmed it myself though. Its possible to just add a compiled rar2fs executable and unrar library to a 9.3 install so I made it available in the tar archive below.
If you use these you could get by with just copying rar2fs/unrar-lib to your data disk and perhaps setting LD_LIBRARY_PATH to the correct directory before running rar2fs.
THE QUICK WAY (verified it myself on a clean 9.2 and 9.3 installation):
# Download the file below
tar xvf rar2fs-freenas9-x86_64.tar
setenv LD_LIBRARY_PATH /mnt/vol1/opt ; /sbin/kldload fuse.ko ; /mnt/vol1/opt/rar2fs –seek-length=1 -o allow_other /mnt/vol1/path/to/your/rars/dir /mnt/vol1/rar2fs_mountpoint