YAFFS2 root file system 1 root file system preparation knowledge embedded Linux all need to build the root file system, the rules for building the root file system are in the FHS (FilesystemHierarchyStandard) document, below is the top-level directory of the root file system. The directory content bin stores basic commands that can be used by all users. Stored in sbin
YAFFS2 root file system 1 root file system preparation knowledge embedded Linux all need to build the root file system, the rules for building the root file system are in the FHS (Filesystem Hierarchy Standard) document, below is the top-level directory of the root file system. The directory content bin stores basic commands that can be used by all users. Stored in sbin
Use YAFFS2 to create the root file system
1 file system prerequisites
In Embedded Linux, you need to build a root file system.
In the FHS (Filesystem Hierarchy Standard) document, the top-level directory of the root file system is shown below.
Contents
Bin stores basic commands that can be used by all users.
Sbin stores basic system commands for starting and repairing systems.
Usr stores shared and read-only programs and data.
Proc is an empty directory and is often used as a mount point for the proc file system.
Dev: This directory stores device files and other special files.
Etc stores system configuration files, including startup files.
Lib stores the Shared Library and the loaded block (that is, the driver). The shared library is used to start the system,
Run the executable program in the root file system.
Static files used by the boot loader
Home user's home directory, including the home directory used by the Service account lock, such as FTP
Mnt is used to temporarily mount the mount point of a file system, usually an empty directory. Or
To create an empty subdirectory.
Opt directory for additional software installation on the host.
Root user's home directory
Tmp stores temporary files, which are usually empty directories.
Var stores variable data.
1.2 build a root file by System
1.2.1 create a root file system directory
Go to the/home/ming directory and create a script file for creating the root file system directory.
Vi make_rootfs_bash: Use the command chmod + x make_rootfs_bash to change the executable permission of the file.
Limited,./make_rootfs_bash run the script to complete the creation of the root file system directory.
#! /Bin/sh
Echo "------ Create rootfs directons start ...--------"
Mkdir rootfs
Cd rootfs
Echo "-------- Create root, dev ....----------"
Mkdir root dev etc boot tmp var sys proc lib mnt home
Mkdir etc/init. d etc/rc. d etc/sysconfig
Mkdir usr/sbin usr/bin usr/lib usr/modules
Echo "make node in dev/console dev/null"
Mknod-m 600 dev/console c 5 1
Mknod-m 600 dev/null c 1 3
Mkdir mnt/etc mnt/jffs2 mnt/yaffs mnt/data mnt/temp
Mkdir var/lib var/lock var/run var/tmp
Chmod 1777 tmp
Chmod 1777 var/tmp
Echo "------- make direction done ---------"
Changed the right to use the tmp directory, and enabled the sticky bit for the right to use the tmp directory.
To ensure that only the user who creates the tmp directory has the right to delete the files. Although embedded
Most of the systems are single users, but some embedded applications do not necessarily use root permissions for execution. Therefore
It should be designed according to the basic rules of the root file system permission bit.
2. Create a dynamic link library
The dynamic link library directly uses the friendly arm, first decompress the friendly arm's root file package, copy the lib
To the new root file directory lib.
Cd/ming/linux: My directory
Tar-zxvf root_qtopia.tgz-C/opt/mini2440
Cp-a/opt/mini2440/root_qtopia/lib/*/home/ming/rootfs/lib /*
2.2.3 cross-compile Bosybox
Bosybox is an open-source project that complies with the GPL v2 protocol.
And considering the limited system resources (such as memory), Busybox can automatically
Generate the bin, sbin, usr directory and linuxrc file required by the root file system.
1. Decompress busybox
Cd/mnt/hgfs/share
Tar-zxvf busybox-1.13.3.tar.tgz-C/opt
2. Go to the source code and modify the Makefile file:
Cd/opt/busybox-1.13.3
Modify:
CROSS_COMPILE? = Arm-linux-// 164th rows
ARCH? = Arm // 189th rows
3. Configure busybox
Enter make menuconfig for configuration
(1) Busybox Settings --->
General Configuration --->
[*] Show verbose applet usage messages
[*] Store applet usage messages in compressed form
[*] Support-install [-s] to install applet links at runtime
[*] Enable locale support (system needs locale for this to work)
[*] Support for-long-options
[*] Use the devpts filesystem for unix98 PTYs
[*] Support writing pidfiles
[*] Runtime SUID/SGID configuration via/etc/busybox. config
[*] Suppress warning message if/etc/busybox. conf is not readable
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
[*] Build with Large File Support (for accessing files> 2 GB)
Installation Options->
[] Don't use/usr
Applets links (as soft-links) --->
(./_ Install) BusyBox installation prefix
Busybox Library Tuning --->
(6) Minimum password legth
(2) MD5: Trade Bytes for Speed
[*] Fsater/proc scanning code (+ 100 bytes)
[*] Command line editing
(1024) Maximum length of input
[*] Vi-style line editing commands
(15) History size
[*] History saving
[*] Tab completion
[*] Fancy shell prompts
(4) Copy buffer size, in kilobytes
[*] Use ioctl names rather than hex values in error messages
[*] Support infiniband HW
(2) Linux Module Utilities --->
(/Lib/modules) Default directory containing modules
(Modules. dep) Default name of modules. dep
[*] Insmod
[*] Rmmod
[*] Lsmod
[*] Modprobe
----- Options common to multiple modutils
[] Support version 2.2/2.4 Linux kernels
[*] Support tainted module checking with new kernels
[*] Support for module. aliases file
[*] Support for modules. symbols file
(3) Configure support for the device types under dev in busybox
There are three methods to create dev:
Manual creation: when creating the root file system, create the device to be used in the dev directory.
File. After the system mounts the root file system, you can use the device files under the dev directory.
Using the devfs File System: This method is outdated, with uncertain device ing and inadequate
Enough primary/secondary device numbers and devfs consume a large amount of memory.
Udev: a user program that dynamically updates device files based on the status of hardware devices in the system,
Including creating and deleting device files. It is relatively complex but flexible.
Mdev is a simplified udev that comes with busybox and is suitable for Embedded Application merge. Its
Easy to use. It is used to enable and hot-swappable the system or dynamically load the driver.
Automatically generate the node files required by the driver. Build embedded linux based on busybox
Is the best choice. The following options will support mdev.
Linux System Utilities --->
[*] Support/etc/mdev. conf
[*] Support command execution at device addition/removal
4. Compile busybox
Compile busybox to the specified directory:
Cd/opt/busybox-1.13.3
Make CONFIG_PREFIX =/home/ming/rootfs install
The contents of bin, sbin, usr, and linuxrc files are generated under the rootfs directory.
The red part is mandatory, that is, to install four busybox files under rootfs.
2.2.4 create a configuration file under the etc directory
1. etc/mdev. conf file. The content is blank.
2. Copy the passwd, group, and shadow files under the etc directory of the host to the rootfs/etc directory.
3. Create a new file HOSTNAME in the etc/sysconfig directory with the content of "Ming ".
4. etc/inittab file:
# Etc/inittab
: Sysinit:/etc/init. d/rcS
: Askfirst:-/bin/sh
: Ctrlaltdel:/sbin/reboot
: Shutdown:/bin/umount-a-r
5. etc/init. d/rcS file:
#! /Bin/sh
PATH =/sbin:/bin:/usr/sbin:/usr/bin
Runlevel = S
Prevlevel = N
Umask 022
Export PATH runlevel prevlevel
Echo "---------- munt all ----------------"
Mount-
Echo/sbin/mdev>/proc/sys/kernel/hotplug
Mdev-s
Echo "************************************** *********"
Echo "*************** MiNi2440 arm9 ******************** *"
Echo "Learning ^: linux-2.6.30.9"
Echo "Student: Wu Jian Ming"
Echo "Date: 2009.12.20"
Echo "************************************** *********"
/Bin/hostname-F/etc/sysconfig/HOSTNAME
Run the following command to change the execution permission of the rcS:
Chmod + x rcS
6. etc/fstab file:
# Device mount-point type option dump fsck order
Proc/proc defaults 0 0
None/tmp ramfs defaults 0 0
Sysfs/sys sysfs defaults 0 0
Mdev/dev ramfs defaults 0 0
7. etc/profile file:
# Ash profile
# Vim: syntax = sh
# No core file by defaults
# Ulimit-S-c 0>/dev/null 2> & 1
USER = "id-un"
LOGNAME = $ USER
PS1 = '[/u @/h = W] #'
PATH = $ PATH
HOSTNAME = '/bin/hostname'
Export user logname PS1 PATH
2.2.5 create a root file system image file
Run the following command to install the yaffs file system creation tool:
Cd/ming/linux
Tar-zxvf mkyaffs2image. tgz-C/
In the/home/ming directory, run the mkyaffs2image rootfs. img command to generate the root file.
System image file.