Step-by-step NFS-mounted Root File System

From odroid US
Revision as of 21:47, 17 January 2013 by Osterluk (Talk | contribs)

Jump to: navigation, search

THIS TOPIC ACTIVELY BEING EDITED. IT IS NOT COMPLETE

This tutorial is for Developers. It is written to work with the odroidu2-ubuntu or odroidu2-debian SD-Card images [is this specific enough?]

It is not for Android developers.

Introduction

A common technique for embedded development is to NFS-mount your root file system. This means that all files are actually on a host. The host is configured to export the filesystem. The target (odroid) mounts the filesystem at boot time and uses it as its own. All files are visible on the host.

As targets have increased in storage capacity and speed, the need for NFS-mounting root file systems will decrease. The technique is still useful when bringing up a new port or you have a lot of files that need to change together.

It is common to check in a whole root file system into a source control system for quality control.


Prerequisites

  • You MUST have access to the serial console -- use the USB/Serial adapter [check actual Hardkernel name]
  • You need to be able to edit files on the odroid, or how to move them to a host and back for editing
  • You need to know how to build a kernel. There are many ways to do it. This tutorial walks through a native kernel build: Kernel Compiling
  • You need to know how to abort booting at the u-boot console. [http://odroid.us/mediawiki/index.php?title=U-boot_Topics&action=view&section=5 Abort boot at u-boot console]
  • You will need some patience... NFS exporting and mounting can be frustrating

    Overview

    We are going to:

  • Add some u-boot environment variables to steer the boot process
  • Mount the boot partition read/write
  • Compile a custom u-boot script to add parameters to the kernel command line
  • Replace the standard boot.scr with our custom one
  • Setup the root file system directory
  • Configure NFS-exports
  • Test the NFS server
  • reboot and see that we actually are running from files living on the host

    Steps

    Power-up the odroid and abort the boot at u-boot console

    Exynos4412 #
    

    Copy/paste the following text to a text editor. You need to make changes. See the comments for an explaination

    # replace the ip address below with the ip address of the host you want to NFS-mount
    # This address must be on the same subnet as your odroid -- no routes are in place 
    # so early in the boot, and neither is DNS.
    set nfsserverip 10.4.124.93
    
    # replace home/karlo/targetrfs with the host absolute path of the directory you mean to 
    # use for the odroid root file system.  This can be a symlink, but it must NFS must be
    # able to resolve it (it must be on the same filesystem)
    set rfspath home/karlo/targetrfs
    
    # We will use this macro as 'run setnfs' at the u-boot prompt to turn on NFS mounting
    set setnfs 'set bootdev root=/dev/nfs rw nfsroot=${nfsserverip}:/${rfspath}; saveenv;'
    
    # We will use this macro as 'run unsetnfs' at the u-boot prompt to turn off NFS mounting
    set unsetnfs 'set bootdev;'
    
    # this step saves the u-boot environment variables we just set
    saveenv
    

    Now boot the odroid, nothing we did so far is going to change the boot.

    run bootcmd
    


    Mount the boot partition read-write, if it is not already mounted. The Debian images do not mount the boot partition (at this time)

    mount /dev/mmcblkp1 /boot
    cd /boot
    <pre>
    
    This is the current boot.scr (yours may be different):
    <pre>
    setenv initrd_high "0xffffffff"
    setenv fdt_high "0xffffffff"
    setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
    setenv bootargs "console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro mem=2047M"
    boot
    

    Copy the existing boot script:

    cp boot.scr boot-nfs.scr
    

    Edit boot-nfs.scr. Insert ${bootdev} text to give the following:

    setenv initrd_high "0xffffffff"
    setenv fdt_high "0xffffffff"
    setenv bootcmd "fatload mmc 0:1 0x40008000 zImage; fatload mmc 0:1 0x42000000 uInitrd; bootm 0x40008000 0x42000000"
    setenv bootargs "${bootdev} console=tty1 console=ttySAC1,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro mem=2047M"
    boot
    

    Compile to a u-boot script like this:

    mkimage -T script -A arm -C none -n 'odroid-u2.Boot NFS-mounted RFS' -d boot-nfs.txt boot-nfs.scr 
    

    If that works, replace your existing script with the one just made. If not, you do not have the prerequisites to build a kernel. mkimage comes from a u-boot package, listed in prerequisites for kernel building.

    mv boot.scr boot.scr.orig
    cp boot-nfs.scr boot.scr