Using NFS for the Root File System 1. Overview =========== These steps explain how to mount the root file system via nfs. It is assumed that the following three systems are connected to the network. - A development PC (will also act as the NFS server) - A DHCP Server - A SUZAKU It is also possible for the development PC to act as the DHCP server. If so, please make adjustments to the instructions as appropriate. 2. Downloads ============ Pre-built binary and a patch is also available from: http://download.atmark-techno.com/suzaku/image/rootnfs/ linux-rootnfs.bin the Linux kernel image file to be written to the Flash memory on the SUZAKU. suzaku-rootnfs.tar.gz the root file system archived and compressed with tar and gzip. It must be expanded under the root user. uClinux-dist-20040408-suzaku3-rootnfs.patch A patch file updates the default kernel configuration file (vendor/AtmarkTechno/SUZAKU/config.linux-2.4). 3. Settings and Building ======================== The following changes must be made to the kernel settings. (Please enable those with the asterisk(*) and disable 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 The above changes can also be carried out automatically using the patch. For 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 : : Doing a build produces images/linux.bin. It is this linux.bin file, not the image.bin file that is used. 4. NFS Server Configuration =========================== Please install the NFS server on the development PC. For Debian, it can be done with: [PC ~]# apt-get install nfs-kernel-server Next, copy the files in images/romfs.img. As this is already an image file it needs to be mounted first. Please carry out the following under the root user. The destination directory can be anywhere. In this example, /srv/exports is used: [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 may also be used. Please expand it under the root user. For convenience, a symbolic link called suzaku is also created. For example: [PC ~]# mkdir -p /srv/exports [PC /srv/exports]# tar xzf suzaku-rootnfs.tar.gz [PC /srv/exports]# ln -s suzaku-rootnfs suzaku Now, add the created directory to /etc/exports and refrect the change. [PC ~]# echo "/srv/exports/suzaku *(rw,no_root_squash,sync)" >> /etc/exports [PC ~]# exportsfs -a [PC ~]# exportsfs /srv/exports/suzaku-rootnfs 5. DHCP Server Configuration ============================ ISC DHCP3 is used for this example. Please install it if necessary. For Debian, it can be installed as follows: [Srv ~]# apt-get install dhcp3-server /etc/dhcp3/dhcp.conf is the DHCP3 configuration file. Please carry out configuration appropriate for the operating environment. As a sample: 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"; } } 6. Writing the Image ==================== Either the built linux.bin or pre-built linux-rootnfs.bin is now written to the SUZAKU. Use either NetFlash or hermit to write image file to flash memory. 7. Booting ========== Please confirm that Linux boots and the root file system is mounted. Here is a sample boot log: 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 the DHCP client is activated is printed by dhcp client because SUZAKU already have ip information. This is scheduled to be fixed in the next dist. 8. Confirmed Environment ======================== The above has been confirmed to work under the following environment: SUZAKU: uClinux-dist-20040408-suzaku3 Development PC: Debian Sid nfs-kernel-server 1:1.0.6-3 DHCP Serer: Debian Woody dhcp3-server 3.0+3.0.1rc9-2.2