Specifications
The first line says that it's a script file for the /bin/nash interpreter.
Note: even if this file looks like a shell script it is NOT interpreted by a shell, but by the nash
interpreter. For a complete list of available nash commands and their syntax please refer to the
manual page, nash(8).
•
The first action is to mount the /proc pseudo file system which is needed to find out some required
information.
•
Then we create block device entries for all partitions listed in /proc/partitions (mkdevices
command).
•
In the next step a block device for our new root file system is created (mkrootdev command).•
Then we mount the CF card. We assume that there is only a single partition on it (/dev/hda1)
which is of type VFAT (which also will work with FAT file systems). These assumptions work fine
with basicly all memory devices used under Windows.
•
We further assume that the file name of the root file system image on the CF card is
"rootfs.img" - this file now gets mounted using a loop device (losetup and mount
commands).
•
Our file system image, is now mounted on the /sysroot directory. In the last step we use
pivot_root to make this the new root file system.
•
As a final cleanup we unmount the /proc file system which is not needed any more.•
There is one tiny flaw in this method: since we mount the CF card on a directory in the ramdisk to be able to
access to root file system image. This means that we cannot unmount the CF card, which in turn prevents us
from freeing the space for the inital ramdisk. The consequence is that you permanently lose approx. 450 kB of
RAM for the ramdisk. [We could of course re-use this ramdisk space for temporary data, but such
optimization is beyond the scope of this document.]
And how does this work on our target?
First we copy the two images to the CF card; we do this on the target under Linux:
bash-2.05b# fdisk -l /dev/hda
Disk /dev/hda: 256 MB, 256376832 bytes
16 heads, 32 sectors/track, 978 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 978 250352 6 FAT16
bash-2.05b# mkfs.vfat /dev/hda1
mkfs.vfat 2.8 (28 Feb 2001)
bash-2.05b# mount -t vfat /dev/hda1 /mnt
bash-2.05b# cp -v linux.img rootfs.img /mnt/
`linux.img' -> `/mnt/linux.img'
`rootfs.img' -> `/mnt/rootfs.img'
bash-2.05b# ls -l /mnt
total 4700
-rwxr--r-- 1 root root 1020729 Jun 14 05:36 linux.img
-rwxr--r-- 1 root root 3788800 Jun 14 05:36 rootfs.img
bash-2.05b# umount /mnt
1.
We now prepare U-Boot to load the "uMulti" file (combined Linux kernel and initial ramdisk)
from the CF card and boot it:
=> setenv fat_args setenv bootargs rw
=> setenv fat_boot 'run fat_args addip;fatload ide 0:1 200000 linux.img;bootm'
=> setenv bootcmd run fat_boot
2.
And finally we try it out:
U-Boot 1.1.3 (Jun 13 2005 - 02:24:00)
CPU: XPC86xxxZPnnD4 at 50 MHz: 4 kB I-Cache 4 kB D-Cache FEC present
3.
9.5.6. Root File System in a Read-Only File in a FAT File System 124