Using NFS for the Root File System

| Updated: 2008/09/17
  1. Overview

    Here, the root file system will be mounted via nfs.  The following explanation assumes the next three systems are connected to the network. 

    • PC being used for development (also acting as the NFS server)

    • DHCP server

    • SUZAKU

    It is possible of the PC to also act as the DHCP server.  If doing so, make changes to the following instructions as necessary.

  2. Downloads

     From http://download.atmark-techno.com/suzaku/image/rootnfs/ , download these files: 

    • linux-rootnfs.bin

    • suzaku-rootnfs.tar.gz

    • uClinux-dist-20040408-suzaku3-rootnfs.patch

    linux-rootnfs.bin is the Linux kernel image file to be written to Flash memory.

    suzaku-rootnfs.tar.gz is a compressed tar file of the root file system.  It must be extracted as a root user.

    The patch file alters the default kernel settings (vendor/AtmarkTechno/SUZAKU/config.linux-2.4.x).

  3. Configuration and Building

    The following changes must be made to the kernel settings (select options with * shown, and deselect those without). 

    
       General setup
         [*] Compiled-in Kernel Boot Parameter
              Default kernel command string: "root=/dev/nfs"
    
       Memory Technology Devices (MTD)
         Mapping drivers for chip access
         < >  Generic uClinux RAM/ROM filesystem support
    
       Networking options
         [*] TCP/IP networking
         [*]   IP: kernel level autoconfiguration
         [*]     IP: DHCP support
    
       File systems
         Network File Systems
           <*> NFS file system support
           [*]   Provide NFSv3 client support
           [*]   Root file system on NFS
    

    This configuration can also be done using the patch file as in the following example: 

    
    [PC ~]$ tar xzf rootnfs.tar.gz
    [PC ~]$ cd uClinux-dist
    [PC ~/uClinux-dist]$ patch -p1 < ../rootnfs/uClinux-dist-20040408-suzaku3-rootnfs.patch
    [PC ~/uClinux-dist]$ make config
      :
      :
    

    Building this configuration will produce images/linux.bin.  Note that it is linux.bin used here and not image.bin. 

  4. NFS Server Configuration

    Install the NFS server on the PC.  For debain, this would be: 

    
    [PC ~]# apt-get install nfs-kernel-server
    

    Next, copy the files from within images/romfs.img.  As it is an image file, it must be first mounted to /mnt under the root user.  The destination directory can be anywhere appropriate.  /srv/exports is used in the following example. 

    
    [PC ~]# mkdir -p /srv/exports/suzaku
    [PC ~]# mount -o loop /home/atmark/uClinux-dist/images/romfs.img /mnt
    [PC ~]# cd /mnt
    [PC ~]# tar -c * | (cd /srv/exprots/suzaku; tar xfv -)
    

    The suzaku-rootnfs.tar.gz file can also be used.  Extract the files under the root user and create a symbolic link as shown below:

    
    [PC ~]# mkdir -p /srv/exports
    [PC /srv/exports]# tar xzf suzaku-rootnfs.tar.gz
    [PC /srv/exports]# ln -s suzaku-rootnfs suzaku
    

    Finally, add the directory to /etc/exports and put the changes into effect: 

    
    [PC ~]# echo "/srv/exports/suzaku *(rw,no_root_squash,sync)" >> /etc/exports
    [PC ~]# exportsfs -a
    [PC ~]# exportsfs
    /srv/exports/suzaku-rootnfs
                  < world >
    
  5. DHCP Server Configuration

    Here ISC DHCP3 is used for this example, so please install it as necessary.  For debian a system: 

    
    [Srv ~]# apt-get install dhcp3-server
    

    /etc/dhcp3/dhcpd.conf is the DHCP3 configuration file.  Please adjust it so that it fits your network environment.  The following is a typical example:

    
      option domain-name "local-network";
      option domain-name-servers 192.168.1.1;
      option subnet-mask 255.255.255.0;
    
      default-lease-time 600;
      max-lease-time 7200;
    
      allow bootp;
      not authoritative;
    
      subnet 192.168.1.0 netmask 255.255.255.0 {
              range 192.168.1.100 192.168.1.254;
              option broadcast-address 192.168.1.255;
              option routers 192.168.1.1;
              option subnet-mask 255.255.255.0;
              host suzaku {
                      hardware ethernet 00:11:C0:00:XX:XX;
                     option root-path "192.168.1.xx:/srv/exports/suzaku,v3";
              }
      }
    

    Take note of the lines in the brackets after "host suzaku".  After "hardware ethernet", specify the MAC address of the SUZAKU, and enter the IP address of the PC after "option root -path". 

  6. Writing Image File to Flash

    Write the built linux.bin or the downloaded linux-rootnfs.bin to the SUZAKU.  If NetFlash is usable, Writing to Flash memory with NetFlash, or use Hermit: Writing to Flash memory with Hermit

  7. Booting

    Boot Linux, and confirm that the root file system mounts correctly.  An example bootlog: 

    
    Copying kernel...done.
    Linux version 2.4.27-uc0-suzaku0 (atmark@build) (gcc version 2.95.3-4 Xilinx EDK 6.1 Build EDK_G.11) #8 Mon Jan 3 17:57:37 JST 2005
    On node 0 totalpages: 4096
    zone(0): 4096 pages.
    zone(1): 0 pages.
    zone(2): 0 pages.
    CPU: MICROBLAZE
    Console: xmbserial on UARTLite
    Kernel command line: root=/dev/nfs
    Calibrating delay loop... 25.44 BogoMIPS
    Memory: 16MB = 16MB total
    Memory: 14928KB available (1035K code, 235K data, 56K init)
    Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
    Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
    Mount cache hash table entries: 512 (order: 0, 4096 bytes)
    Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
    Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
    POSIX conformance testing by UNIFIX
    Linux NET4.0 for Linux 2.4
    Based upon Swansea University Computer Society NET3.039
    Initializing RT netlink socket
    Microblaze UARTlite serial driver version 1.00
    ttyS0 at 0xffff2000 (irq = 1) is a Microblaze UARTlite
    Starting kswapd
    xgpio #0 at 0xFFFF5000 mapped to 0xFFFF5000
    Xilinx GPIO registered
    SMSC LAN91C111 Driver (v2.0), (Linux Kernel 2.4 + Support for Odd Byte) 09/24/01 - by Pramod Bhardwaj (pramod.bhardwaj@smsc.com)
    eth0: SMC91C11xFD(rev:1) at 0xffe00300 IRQ:2 MEMSIZE:8192b NOWAIT:0 ADDR: 00:11:c0:xx:xx:xx
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
    Suzaku MTD mappings:
      Flash 0x400000 at 0xff000000
    Amd/Fujitsu Extended Query Table v1.3 at 0x0040
    flash: Swapping erase regions for broken CFI table.
    number of CFI chips: 1
    cfi_cmdset_0002: Disabling fast programming due to code brokenness.
    Creating 7 MTD partitions on "flash":
    0x00000000-0x00400000 : "Flash/All"
    0x00000000-0x00080000 : "Flash/FPGA"
    0x00080000-0x000a0000 : "Flash/Bootloader"  0x003f0000-0x00400000 : "Flash/Config"
    0x000a0000-0x003f0000 : "Flash/Image"
    0x000a0000-0x00210000 : "Flash/Kernel"
    0x00210000-0x003f0000 : "Flash/User"
    NET4: Linux TCP/IP 1.0 for NET4.0
    IP Protocols: ICMP, UDP, TCP
    IP: routing cache hash table of 512 buckets, 4Kbytes
    TCP: Hash tables configured (established 1024 bind 1024)
    eth0:PHY remote fault detected
    Sending DHCP requests ., OK
    IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.225
    IP-Config: Complete:
        device=eth0, addr=192.168.1.225, mask=255.255.255.0, gw=192.168.1.1,
        host=192.168.1.225, domain=local-network, nis-domain=(none),
        bootserver=192.168.1.1, rootserver=192.168.1.xx, rootpath=/srv/exports/suzaku,v3
    Looking up port of RPC 100003/3 on 192.168.1.xx
    Looking up port of RPC 100005/3 on 192.168.1.xx
    VFS: Mounted root (nfs filesystem).
    Freeing init memory: 56K
    Mounting proc: 
    Mounting var: 
    Populating /var: 
    Running local start scripts.
    Mounting /etc/config: 
    Populating /etc/config: 
    flatfsd: Created 4 configuration files (151 bytes)
    Setting hostname: 
    Setting up interface lo: 
    Starting DHCP client: 
    Jan  1 00:00:15 dhcpcd[33]: dhcpConfig: ioctl SIOCADDRT: File exists
    Starting inetd: 
    Starting thttpd: 
    
    SUZAKU login: 
    

    The message after DHCP client appears because the IP address information already exists.  This will be fixed in the next dist release. 

  8. Confirmed Environment 

    The above method has been confirmed to work under the following environment: 

    • SUZAKU: uClinux-dist-20040408-suzaku3
    • PC: Debian Sid, nfs-kernel-server 1:1.0.6-3
    • DHCP server: Debian Woody, dhcp3-server 3.0+3.0.1rc9-2.2

     

     

Categories: