# [FreeNAS] Compiling inside an embedded FreeNAS system



## pixies (Oct 27, 2012)

Hi there,

I have an ATOM D525 based FreeNAS system (now called NAS4Free), which is loaded from a Flash drive and based on FreeBSD 7.3 amd64-embedded version. Everything (dedicated NAS storage) is working flawlessly, and I'm very happy with it.

I would like to have the ability to compile some open source utilities which are not included in my OS, and would like to know how can I do it on my running FreeNAS system. Specifically, I would really like to compile this Wake-On-Lan utility in order to use it for waking up other computers in my home network:
http://sourceforge.net/projects/wake-on-lan/files/wol/0.7.1/

I'm quite certain that my embedded OS does not contain any compilation tools, and this is in order to save some space on my 2GB Flash drive.

But I do have a very large space on my RAID-Z array, specifically in the /mnt/zfspool directory of my filing system.

Is it possible to download the FreeBSD compilation tools separately to this storage space and make some compilations there?

If yes, how can it be done?

Thanks!


----------



## DutchDaemon (Oct 27, 2012)

Disclaimer: Topics about PC-BSD | *FreeNAS* | *NAS4Free* | DesktopBSD | m0N0WALL | pfSense | kFreeBSD


----------



## wblock@ (Oct 27, 2012)

A few problems.  First, we are FreeBSD users, and the NAS versions of FreeBSD are heavily customized.  The people who did the customizing are the better ones to ask.

Second, that appears to be a Windows utility which won't run on FreeBSD.

The good news is that FreeBSD already has a wake-on-lan utility, wake(8).  Putting the machine name and MAC address in /etc/ethers allows machines to be referred to by name:
`# wake mymachine`


----------



## pixies (Oct 27, 2012)

Thanks for the reply.
As a matter of fact, it seems that the "wol" project can also be compiled in Linux and FreeBSD:
http://sourceforge.net/projects/wake-on-lan/

However, the "wake" utility seems like the best solution for me.
But it's only available in FreeBSD 8.3 and up, while I have a system which is based on FreeBSD 7.3.

Is there any chance that copying the "wake" binary to a FreeBSD 7.3 system will work?
If not, can it be compiled to that FreeBSD version?
10x!


----------



## AlexJ (Oct 27, 2012)

pixies said:
			
		

> If yes, how can it be done?



You need to switch to the one of the latest versions of NAS4Free (9.1.0.1.xxx)
It is pretty stable and well supported that I can't say about 7.x

wake(8)() utility depended only on /lib/libc.so.7

```
# ldd /usr/sbin/wake
/usr/sbin/wake:
        libc.so.7 => /lib/libc.so.7 (0x2808e000)
```

that is already present on a 7.x version of NAS4Free, but you can't run it there because 7.x version doesn't have bpf(4)() compiled in kernel, so there no /dev/bpf which is need to run wake(8)()

(so, just copying wake(8)() from FreeBSD8 or FreeBSD9 will allow you to run it, but wake(8)() will complain about absents of bpf(4)() )

[CMD=""]P.S.[/CMD]
As about compiling under embedded versions of NAS4Free it can be realized also relatively easy without effecting limited RAM based space. 

Install VirtualBOX
Install FreeBSD inside it
Issue pkg_create -Rb "PackageThatYouNeed" command that will download package you needed and all its dependency.
Unpack and remove any unneeded files from archive (+COMMENT, docs, etc), keep only executable and libraries (Actually you  can do it already on your host computer(Windows?))
Archive this and import/download it to your *NAS* on your ZFSpool or UFS drives to dedicated directory that keep directories in the same order as it is in the base system. (example: /mnt/MyAttachedHDD/SysDir/usr/local) You need to keep directories structure *(!!!)* of archives when you cleaning it. You can use tar(1)() to combine all software(include dependency) that you want to run to a single archive.
Write script that will run on start of NAS4Free (System->Advanced->Command scripts), the main purpose of which will be to populate symlinks from /mnt/MyAttachedHDD/SysDir/usr/local to you base system /usr/local
That is all that you needed. Even monstrous packages like misc/mc can be installed to embedded version of NAS4Free without effecting FreeBSD OS that run in RAM.


----------



## pixies (Oct 27, 2012)

Well, looks like the best thing for me to do is to upgrade to latest Nas4Free.
Thanks again for all your kind and extensive help.


----------



## pixies (Oct 27, 2012)

Using some kind help from the Nas4Free forum guys, I have it working.

If anybody is interested, there are ready compiled binaries for older FreeBSD versions here, e.g. for 7.1:
http://ftp-archive.freebsd.org/pub/...amd64/7.1-RELEASE/7.1-RELEASE/packages/Latest

and the binaries for the "wol" project are there.
I just copied the bin contents of that package (3 files), chmod'ed them to executables, and could run them.

Thanks again for all your answers.


----------

