Developing a rootfs for an embedded Linux Systems can present some troublesome, since the filesystem ext3 or some kind of image need to be created everytime when you add some files to rootfs and it’s not always an easy/quick task, or if the disk space is very low. The Linux kernel has the ability to read the root filesystem from the network, specifically from a NFS share.
- The Network File System (NFS) protocol is a way for a machine to make a storage location (the so-called export in NFS parlance) available to other hosts on the network.
- NFS isn’t a requirement for embedded development, although it does make development easier because the root file system used by the target board can be easily updated when it’s stored as a directory somewhere on the development host.
- Embedded boards that use flash memory (the same technology as USB drives) must have their file systems built and then placed on the board, and that process can be time consuming early in the development process when changes are frequent.
When using QEMU as a target instead of a real board, the inconvenience is troublesome, the root filesystem image should be created every time. Fortunately, QEMU offers a network model that allows to access the host as thought it was connected with an Ethernet network
Install nfs :
$sudo apt-get install nfs-kernel-server
Informing the NFS server of a mount is done through the /etc/exports file. The format of this file is very simple; for example, to export a directory containing a root file system to be mounted by a board, the file contains the following line.
$ mkdir /rootfs_ES $ sudo vi /etc/exports
# add below line in exports file.
This line says,export /rootfs_ES, allow anyone to connect, allow reads and writes, and if a user with UID=0 connects, don’t attempt to remap the UID to something less dangerous. The * means to allow connections from any host. Reading the man page for this file reveals that the user has great control over what hosts can mount an export: the user can enter host names, IP addresses, and IP address masks.
Restart the NFS server by doing the following:
$ sudo /etc/init.d/nfs-user-server restart or $ sudo service nfs-kernel-server start
NFS isn’t a requirement for embedded development, although it does make development easier because the root file system used by the target board can be easily updated when it’s stored as a directory somewhere on the development host.
Let me know if you have any questions or comments.
Pro Embedded Linux.