Build the simplest embedded linux root file system. Next we will teach you step by step ..
Hardware environment:
S3C2440
Software environment:
Busybox-1.16.1 http://www.rayfile.com/zh-cn/files/2e477e14-c1bb-11e0-b287-0015c55db73d/
Cross-4.3.2 http://www.rayfile.com/zh-cn/files/99e727f3-c1a5-11e0-822a-0015c55db73d/
Step 1: Build a directory structure
Create a root file system directory, including the following directories
/Dev/etc/lib/usr/var/proc/tmp/home/root/mnt/bin/sbin/sys
# Mkdir/home/rootfs
# Cd/home/rootfs
# Mkdir Dev etc lib USR var proc TMP home root MNT sys
Step 2: Use busybox to build/bin/sbin linuxrc
Enter the busybox-1.16.1 directory and execute
# Make defconfig
# Make menuconfig
Busybox setting ----->
Build options ----->
// 1 select to perform static compilation of busybox
[*] Build busybox as a static binary (no shared libs)
// 2. Specify the cross compiler
(/Usr/local/ARM/4.3.2/bin/ARM-Linux-) Cross Compiler prefix
Installation Options ----->
// 3. Select don't use/usr
Busybox library tuning --->
[*] Username completion
[*] Fancy shell prompts
[*] Query cursor position from Terminal
// 4. The compiled shell command interpreter of busybox supports displaying the current path and host information
Save and exit
# Make
# Make install
The _ install directory is displayed under the busybox Directory, which contains three files:/bin/sbin linuxrc.
Copy these three directories or files to the rootfs folder created in step 1.
# Cp bin/sbin/linuxrc/home/rootfs-ra
Make sure to include the-a parameter, because most of the bin directories are links. If the-a parameter is not included, copies will be made after the copy, instead of links.
Step 3 build the etc directory:
1) enter the etc directory of the root file system rootfs and perform the following operations:
Copy Busybox-1.16.1/examples/bootfloopy/etc/* to the current directory
# Cp-r busybox-1.16.1/examples/bootfloopy/etc/* rootfs/etc
Modify the inittab and change the second item to: respawn:-/bin/login.
Delete lines 3 and 4
2) copy/etc/passwd,/etc/group,/etc/shadow on the VM to rootfs/etc.
# Cp/etc/passwd rootfs/etc
# Cp/etc/group rootfs/etc
# Cp/etc/shadow roofs/etc
Modify the following three files and only save the items related to root. The content varies according to the actual situation.
Modify passwd to root: X: 0: 0: Root:/root:/bin/sh, that is, only the items related to root are saved, and finally changed to/bin/ash.
Change Group to root: X: 0: Root.
Modify shadow to root: $1 $ x9yv1wlb $ abj2v9joloc9xw/y0qwps.: 14034: 0: 99999: 7 :::
Enter the user name and password when logging on to the Development Board, the same as the Virtual Machine
3) modify the profile
Path =/bin:/sbin:/usr/bin:/usr/sbin // executable program environment variable
Export LD_LIBRARY_PATH =/lib:/usr/lib // dynamic link library environment variable
/Bin/hostname sunplusedu
User = "'id-UN '"
LOGNAME = $ user
Hostname = '/bin/hostname'
PS1 = '[\ U @ \ H \ W] #' // displays host name, current path, and other information:
4) modify the etc/init. d/rc. s file
/Bin/Mount-n-t ramfs/var
/Bin/Mount-n-t ramfs/tmp
/Bin/Mount-n-t sysfs NONE/sys
/Bin/Mount-n-t ramfs NONE/dev
/Bin/mkdir/var/tmp
/Bin/mkdir/var/modules
/Bin/mkdir/var/run
/Bin/mkdir/var/log
/Bin/mkdir-P/dev/PTS // Telnet service required
/Bin/mkdir-P/dev/SHM // Telnet service required
Echo/sbin/mdev>/proc/sys/kernel/hotplug // required for automatic USB mounting
/Sbin/mdev-S // start mdev to automatically create a device file node under/dev
/Bin/Mount-
5) modify the etc/fstab file and add the following files:
None/dev/PTS devpts mode = 0622 0 0
Tmpfs/dev/SHM tmpfs defaults 0 0
Step 4 build the lib directory:
1)# Cd
/Usr/local/ARM/4.3.2/ARM-None-Linux-gnueabi/libc/armv4t/lib
Copy the following dynamic library to rootfs/lib
# Cp * So * roofs/lib-
2) # cd/usr/local/ARM/4.3.2/ARM-None-Linux-gnueabi/libc/armv4t/usr/lib
Copy the following dynamic library to rootfs/lib
# Cp./libstdc ++. So. * rootfs/lib-