Compact Flash cards make an ideal media on which to distribute an application but they can be frustrating as a development media. It is quite possible to connect a normal Hard Disk to an Axis board and to use the system as a normal PC. This works, but developing a final image suitable for deployment is harder, and development tools need removing. There is an alternative, the Linux kernel can be made to mount a Network File System (NFS).
Everything apart from the kernel image is loaded across a network using the Unix Network File System. Different systems can each mount unique systems. The target Axis board file system can be mapped into the developer's PC file system. The developer can work on a PC and programs and data appear instantly to the Axis system. When the product is ready, the contents of the network drive are copied to Compact Flash and after a change to the kernel boot command line the system works from Compact Flash.
If you want the kernel to mount an NFS root file system after boot certain options need to be built into the kernel. Assuming that the kernel build is being configured by the make menuconfig command:
Select:
File systems --->
Then:
Network File Systems --->
Enable NFS file system support by selecting:
<*> NFS file system support [*] Provide NFSv3 client support [ ] Allow direct I/O on NFS files (EXPERIMENTAL) [*] Root file system on NFS
Build the kernel and add it to a prepared Compact Flash drive. Before running Lilo on the Compact Flash drive change the append parameter in etc/lilo.conf to the desired network settings so it reads:
append ="root=/dev/nfs rw nfsroot=193.0.0.72:/home/Axis/root ip=193.0.0.221::193.0.0.40:255.255.255.0:Axis1:eth0:off"
Replace the 193.0.0.72 with the IP address of the NFS server that will serve
the root file system.
Replace ip=193.0.0.221 with the IP address you wish to assign to the Axis board.
Replace 193.0.0.40 with the default gateway address and Axis1 with your chosen
Network name.
Replace /home/Axis/root with the path on the server to the directory that is to
serve as the Axis boards root directory.
Run Lilo as normal and then try and boot the system. Rather than mounting a local file system after the kernel has booted it will try and mount the file system specified in the append string.
The NFS server is controlled by a file on the host:
/etc/exports
The line allows a device with IP address 193.0.0.221 free access /home/Axis/root
/home/Axis/root/
193.0.0.221/255.255.255.255(rw,no_root_squash,no_all_squash)
The 255.255.255.255 is a mask which restricts the range of IP addresses accepted. rw Specifies that the mount is read/write
The squash parameters override the NFS's user security permissions. In normal NFS, operations being root on machine A do not give root permissions to files on machine B. Normally this is a sensible security measure but in this case it has been overridden. This is balanced by the restriction that the server only accepts connections from one specific IP address. In some environments this might not be regarded as sufficient security, so please be aware.
Note: /etc/exports can be very sensitive to white spaces.
For security reasons /etc/hosts.deny and /etc/hosts.allow should also be edited:
# #hosts.deny # portmap:ALL lockd:ALL mountd:ALL rquotad:ALL statd:ALL
# #hosts.allow # portmap:193.0.0.221 lockd:193.0.0.221 mountd:193.0.0.221 rquotad:193.0.0.221 statd:193.0.0.221
The rule is that unless an IP address is referenced in hosts.allow, conections are controlled by hosts.deny. In this case all connections are disallowed by hosts.deny except for the connections to 193.0.0.221 allowed in hosts.allow.
The NFS server will then need starting/restarting and this is easily done the commands.
#/etc/init.d/portmap start
and
#/etc/init.t/nfs start
For further information see the Diskless Root NFS HOWTOs and also the NFS HOWTO. These come with many distributions and can be downloaded from the Linux Documentation Project website.