NFS: Network File System protocol

NFS:
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.

Export Rootfs:

$ mkdir /rootfs_ES 
$ sudo vi /etc/exports

# add below line in exports file.

/rootfs_ES *(rw,sync,no_root_squash,no_subtree_check)

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.

Reference:

Pro Embedded Linux.

Advertisements

About VinayMahadev

I am passionate about Embedded Linux systems . I believe in "If you want to learn something, read about it. If you want to understand something, write about it. If you want to master something, teach it". Here I am just trying to connect the Dots.
Gallery | This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to NFS: Network File System protocol

  1. Pingback: U-boot: ARM Versatile Express Emulation On Qemu With NFS as Rootfs | LearningFromU

  2. Pingback: ARM Versatile Express Emulation On Qemu From Scratch :Part 2 | LearningFromU

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s