Книга: Embedded Linux Primer: A Practical, Real-World Approach

12.3.5. U-Boot NFS Root Mount Example

12.3.5. U-Boot NFS Root Mount Example

U-Boot is a good example of a bootloader that supports a configurable kernel command line. Using U-Boot's nonvolatile environment feature, we can store our kernel command line in a parameter specially named for this purpose. To enable the NFS command line in U-Boot, we do the following (all on one line in our serial terminal):

setenv bootargs console=ttyS0,115200 root=/dev/nfs rw
 ip=dhcp nfsroot=192.168.1.9:/home/chris/sandbox/pdna-target

Then we load a kernel via our TFTP server. Listing 12-8 shows what this might look like on a PowerPC embedded target.

Listing 12-8. Loading Kernel via TFTP Server

=> tftpboot 200000 uImage-pdna   <<< Entered at U-Boot prompt
Using FEC ETHERNET device
TFTP from server 192.168.1.9; our IP address is 192.168.1.68
Filename 'uImage-pdna'.
Load address: 0x200000
    Loading: ##################################################
             ##################################################
             #########################################
    done
    Bytes transferred = 911984 (dea70 hex)
    =>

When we boot the kernel, we see specific evidence of our NFS root mount configuration. Listing 12-9 reproduces selected output from the kernel boot messages to demonstrate this. This output has been formatted (many lines omitted and whitespace added) for readability.

Listing 12-9. Booting with NFS Root Mount

 Uncompressing Kernel Image ... OK
    Linux version 2.6.14 (chris@pluto) (gcc version 3.3.3 (DENX ELDK 3.1.1 3.3.3-10)) #1 Mon Jan 2 11:58:48 EST 2006
    .
    .
    Kernel command line: console=ttyS0,115200 root=/dev/nfs rw nfsroot=192.168.1.9:/home /chris/sandbox/pdna-target ip=dhcp
    .
    .
    Sending DHCP requests ... OK
    IP-Config: Got DHCP answer from 192.168.1.9, my address is 192.168.1.68
    IP-Config: Complete:
          device=eth0, addr=192.168.1.68, mask=255.255.255.0,
          gw=255.255.255.255, host=192.168.1.68, domain=,
          nis-domain=(none), bootserver=192.168.1.9,
          rootserver=192.168.1.9,
          rootpath=/home/chris/sandbox/pdna-target
    .
    .
    Looking up port of RPC 100003/2 on 192.168.1.9
    Looking up port of RPC 100005/1 on 192.168.1.9
    VFS: Mounted root (nfs filesystem).
    .
    .
    BusyBox v0.60.5 (2005.06.07-07:03+0000) Built-in shell (msh)
    Enter 'help' for a list of built-in commands.
    #

From Listing 12-9, first we see the kernel banner followed by the kernel command line. We specified four items in this kernel command line:

• Console device (/dev/console)

• Root device (/dev/nfs)

• NFS root path (/home/chris/sandbox/pdna-target)

• IP kernel-level autoconfiguration method (dhcp)

Shortly thereafter, we see the kernel attempting kernel-level autoconfiguration via DHCP. When the server responds and the DHCP exchange completes, the kernel displays the detected configuration in the following lines. You can see from this listing that the DHCP server has assigned the target the IP address 192.168.1.68. Compare the detected settings with those specified in Listing 12-6. That was similar to the DHCP server configuration that resulted in this configuration.

When the kernel has completed the IP autoconfiguration, it is capable of mounting the root file system using the supplied parameters. You can see this from the three lines ending with the VFS (virtual file subsystem) message announcing that it has mounted the root NFS file system. After the NFS root file system has been mounted, initialization completes as described in Chapter 5, "Kernel Initialization."

It is also possible to pass target IP settings to the kernel in a static fashion instead of having the kernel obtain IP settings from a DHCP or BOOTP server. IP settings can be passed via the kernel command line directly. In this case, the kernel command line might look similar to this:

console=console=ttyS0,115200 ip=192.168.1.68:192.168.1.9::255.255.255.0:pdna:eth0:off
 root=/dev/nfs rw nfsroot=192.168.1.9:/home/chris/pdna-target

Оглавление книги


Генерация: 0.033. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз