Article 1: Installing the CF card partition and extlinux
Part 2: Build a root file system
Part II: 2.6 kernel tailoring and busybox compilation configuration and Analysis
A basic file system should include:
Busybox(Provides the shell command set)
Device Files(If devfs is used, this will be avoided. common methods for creating arm include mdev and udev)
Configuration File(Used to initialize and layout the file system)
Library files(If busybox is statically compiled, the library files of busybox and other libraries such as QT and MiniGUI are not required ).
A previous log, http://blog.csdn.net/dos5gw/archive/2010/08/20/5826054.aspx
We also mentioned the method of using busybox to build rootfs. The steps for establishing the root file system are roughly the same. The difference between the steps is that Dev can be created in three ways:
Solution 1 manual creation:Create with mknod;
Solution 2 Use devfs:Expired;
Solution 3 Use udev (mdev ):Mdev is a simplified version of udev that comes with busybox. udev can dynamically update the device files under Dev based on the current hardware devices (system startup, hot swapping, and driver loading;
If you use 1st manual creation methods, refer to the http://blog.chinaunix.net/u1/56388/showart_438741.html
If you use 3rd manual creation methods, refer to the http://huang-tomey.blog.163.com/blog/static/1247505732009916437175/ and
Http://blog.vckbase.com/websurf/archive/2005/08/23/11386.aspx
(1) Compile and install busybox to the CF card:
The configuration of busybox, see: http://blog.csdn.net/dos5gw/archive/2010/10/26/5965992.aspx
Go to the busybox directory and executeMake menuconfig, make, make install
After the make install command is executed, the busybox/_ install directory is generated.
Mount the CF card to/mnt/Cf:Mount/dev/sdb1/mnt/CF
Copy the file generated by busybox to the CF card:CP-Arn _ install/*/mnt/CF/
Create the necessary directories: (usr/sbin/, usr/bin/, bin/, sbin/has been generated under busybox/_ install ):
Mkdir root Dev etc boot TMP var sys proc lib MNT home
Mkdir etc/init. d etc/rc. d ETC/sysconfig
Mkdir usr/lib usr/modules
Chmod 1777 TMP
# Mkdir var/lib var/lock var/run var/tmp
Chmod 1777 VaR
(2) create a device file:
Some practical scripts can be found in the busybox-1.13.3/examples/bootfloppy directory, mkdevs. SH/mkrootfs. sh, with an example of syslinux configuration file; the following is based on mkdevs. sh script to manually create Dev:
CD/mnt/CF/dev
Mknod console C 5 1
Mknod full C 1 7
Mknod kmem C 1 2
Mknod mem C 1 1
Mknod null C 1 3
Mknod port C 1 4
Mknod random C 1 8
Mknod urandom C 1 9
Mknod zero C 1 5
# Mknod tty C 5 0
Mknod ttys0 C 4 64
Mknod ttys1 C 4 65
# Mknod ttys2 C 4 66
# Mknod ttys3 C 4 67
Format explanation:Mknod node name type master device number slave device number
B: Create a block (cached) special device file.
C, u: create a character (non-cached) special device file.
P: Create a FIFO file.
(3) create a configuration file:
Configuration files include:
(1)/etc/inittab
The INIT process creates other sub-processes based on the/etc/inittab file, such as calling the script file to configure IP addresses, mounting other file systems, and starting the shell,
Refer to the "examples/inittab" file under the busybox source code. The content is as follows:
Or
: Sysinit:/etc/init. d/RCS
: Respawn:-/bin/sh
Tty2: askfirst:-/bin/sh
: Ctrlaltdel:/bin/umount-a-r
Change permission chmod 755 inittab,
Note: In the second example, check that the dev/tty2 node exists.
Console: askfirst:-/bin/sh. before entering the console, press enter to confirm. If askfirst is changed to respawn, press enter to directly go to the console;
(2) etc/init. d/RCS
This is similar to the autobat automatic batch processing file in Windows system. The content is as follows:
Path =/sbin:/bin:/usr/sbin:/usr/bin
Runlevel = s
Prevlevel = N
Umask 022
Export path
Echo "entering/etc/init. d/RCS ..."
Echo "reading/etc/fstab and Mount"
/Bin/Mount-
# Echo "Starting mdev"
#/Bin/ECHO/sbin/mdev>/proc/sys/kernel/hotplug
# Mdev-S
# If use NFS, do not reconfigure IP Address
# Echo "set IP Address"
#/Sbin/ifconfig lo 127.0.0.1
#/Etc/init. d/ifconfig-eth0
# Sleep 5
# Echo "Mount-O remount, RW /"
# Mount-O remount, RW/
Echo "Exit/etc/init. d/RCS ..."
Change permissionsChmod 755/nit. d/RCS
(3)/etc/fstab, which corresponds to mount-A. The content is as follows:
# Device Mount-point type options dump fsck order
Proc/proc defaults 0 0
Sysfs/sys sysfs defaults 0 0
Tmpfs/tmp tmpfs size = 16 m, mode = 1777 0 0
Tmpfs/var tmpfs size = 16 m, mode = 1777 0 0
# None/tmp ramfs defaults 0 0
# Mdev/dev ramfs defaults 0 0
Or:
Change permission chmod 755 fstab
(4)/etc/passwd and etc/group. The content is as follows:
#/Etc/passwd
Root: 0: 0: Root:/root:/bin/sh
Daemon: 1: 1: daemon:/usr/sbin:/bin/sh
Bin: 2: 2: Bin:/bin/sh
SYS: 3: 3: SYS:/dev:/bin/sh
# Etc/group
Root: 0: Root
Daemon: 1:
Bin: 2:
SYS: 3:
TTY: 5:
Change permission chmod 775 passwd Group
(5)/etc/profile. The content is as follows:
Echo "entering/etc/profile ..."
User = "ID-UN"
LOGNAME = $ user
/Bin/hostname test-3355
PS1 = '[/u @/h:/W] #'
Echo "set search library path"
Export LD_LIBRARY_PATH =/lib:/usr/lib
Echo "Set User path"
Path =/sbin:/bin:/usr/sbin:/usr/bin
Export user LOGNAME PS1 path
Echo "Exit/etc/profile ..."
Or:
Echo "processing/etc/profile ..."
/Bin/hostname test2440
Export LD_LIBRARY_PATH =/lib:/usr/lib
Path =/bin:/sbin:/usr/bin:/usr/sbin:/xrft
Export path
PS1 = '[/u @/h/W]/$'
Change the execution permission of the profile file:Chmod 775 Profile
Note: In ps1,/W and/W respectively show "absolute path" and "relative path"
(4) related Runtime library files:
You can use LDD to view the libraries that a apps depends on, for example, to view a GCC-static compiled program:
# LDD test3355
Not a dynamic executable
View non-static compiled programs:
# LDD test3355d
Linux-gate.so.1 => (0x0074a000)
Libc. so.6 =>/lib/tls/i686/cmov/libc. so.6 (0x00afb000)
/Lib/ld-linux.so.2 (0x00d50000)
In addition, you can use the file command to view the program type, including the platform, format, and dynamic/static library of the program:
# File test3355d
Test3355d: Elf 32-bit LSB executable, Intel 80386, Version 1 (sysv), dynamically linked (uses SHARED libs), for GNU/Linux 2.6.15, not stripped
//----------------------------------------------------------------
// ---- Complete and test ------------------------------------------------
After the IPC is started, it can start normally and enter the console. However, files under/etc cannot be changed. When VI or chmod is used to modify files, message "file is read only" or "Read-Only File System", for unknown reason
AddMount-O remount, RW/
It can be solved temporarily;
The solution found later is that the configuration parameter of extlinux (that is, bootloader) is "APPEND noinitrd root =/dev/sda1 init =/linuxrc ide = nodma"
Add 'rw 'to the root, and you can remove the mount in the RCS script!
//------------------------------------------------------------------------
//--------------------Improvements and knowledge points needed to build rootfs---------
1. Differences between cramfs, yaffs, and jffs, MTD Concept
2. Ram-based file system, tmpfs
Usually in etc/rc. d:
Mount-T tmpfs/var-O size = 512 K
Mkdir-P/var/tmp
Mkdir-P/var/log
Or Mount-T ramfs NONE/mnt/ramfs-O maxsize = 2000
Or Add the following to fstab and mount-:
Tmpfs/var tmpfs size = 32 M 0 0
// ----------- Fstab interpretation -----------
To the right:
#/Dev/device Mount-point type rules dump fsck
Tmpfs/var tmpfs size = 32 M 0 0
1./dev/device: Needless to say, right? For example,/dev/hda1 is a C: disk under M $-Win9x.
2. Mount-point: mount point. For example, Mount/dev/hda1 to/mnt/mywinc.
3. Type: ext3, vfat,... is the type of the file system to be mounted.
4. Rules:
Auto: automatic mounting upon startup;
Default, noauto: the device is not automatically mounted upon startup;
Nouser: only root users can be mounted;
RO: Read-Only mounting;
RW: readable and writable;
User: any user can be attached;
5. Dump: backup; 0 indicates never backup, or the number of days since the last backup is displayed;
6. fsck: fsck check sequence at startup. If the value is 0, no check is performed, and "/" is always 1;
# Device Mount-point type options dump fsck order
Proc/proc defaults 0 0
Sysfs/sys sysfs defaults 0 0
Tmpfs/tmp tmpfs size = 16 m, mode = 1777 0 0
None/var ramfs defaults 0 0
# None/tmp ramfs defaults 0 0
# Mdev/dev ramfs defaults 0 0
#/Etc/inittab
# Example
# ID: runlevel: Action: Process
: Sysinit:/etc/init. d/RCS
Console: respawn:-/bin/sh
# Console: askfirst:-/bin/sh
#: Respawn:/sbin/Getty 38400 tty1
: Ctrlaltdel:/sbin/reboot
: Shutdown:/bin/umount-a-r