Experiment and process of root file system construction

Source: Internet
Author: User

Create a new folder in which to create a Rootfs folder and create a LINUXRC file

First,the NFS way to start the self-made simple folder form Rootfs

Configure the kernel to support NFS as ROOTFS; Configure Support for NFS startup in Menuconfig

(1), configure the network part, mainly enables CONFIG_IP_PNP to be able to see the root file System on NFS option in 2

Networking Support

Networking options

TCP/IP Networking

Ip:kernel level Autoconfiguration

[*] IP:DHCP Support

[*] IP:BOOTP Support

(2), configure to open NFS Services

File Systems--->

Network File Systems--->

<*> NFS Client Support

[*] NFS Client Support for NFS version 3 [*] NFS Client Support for the NFSv3 ACL protocol ex Tension

[*] NFS Client Support for NFS version 4 (experimental)

[*] NFS Client Support for NFSv4.1 (DEVELOPER only)

[*] Root file system on NFS

1. Set the NFS startup mode Bootargs

Set the following startup parameters in Uboot (IP based on actual usage changes)

setenv Bootargs Root=/dev/nfs Nfsroot=192.168.1.141:/root/rootfs/rootfs ip= 192.168.1.88:192.168.1.141:192.168.1.1:255.255.255.0::eth0:off INIT=/LINUXRC console=ttySAC2,115200

Note: (1) NFS starts the same as the kernel on the Development Board remote mount to the host Rootfs

(2) NFS mode start without making rootfs mirrors

(3) NFS mode is not suitable for real products, generally as a product development phase debugging use

Ii.transplantation of BusyBox

1. Download BusyBox can go to LINUXIDC and other mirror sites, can also go to www.busybox.net official website to download.

2. Modify Makefile

(1) ARCH = Arm

(2) Cross_compile =/usr/local/arm/arm-2009q3/bin//arm-none-linux-gnueabi-

(3) Make Menuconfig configuration

Busybox Settings--->

Build Options--->

[*] Build BusyBox as a static binary (no shared libs)

Busybox Library Tuning--->

[*]vi-style Line Editing commands

[*] Fancy Shell Prompts

Linux Module Utilities--->

[]simplified Modutils

[*]insmod

[*]rmmod

[*]lsmod

[*]modprobe

[*]depmod

Linux System Utilities--->[*]mdev

[*] Support/etc/mdev.conf

[*] Support Subdirs/symlinks

[*] Support Regular Expressions substitutions when renaming dev

[*] Support command execution at device Addition/removal

[*] Support Loading of Firmwares

(4) made and make install (you need to set the install directory first to the folder we do Rootfs)

Third, add the necessary files and folders

1.inittab files are copied to the/etc/directory under the root directory of the Rootfs we made

Understanding Inittab Files

First one: #开始的行是注释

The second: The colon is delimited inside, separating the parts.

Third: Inittab content is in behavior units, there is no association between rows and rows, each row is a separate configuration item, each configuration item represents a specific meaning.

Fourth: The configuration items for each row are determined by 4 configuration values separated by 3 colons. These four configuration values are id:runlevels:action:process. It is worth noting that some of the configuration values can be vacant, after the vacancy, the colon can not be vacant, so sometimes see a continuous 2 colon.

Fifth: The most important of the 4 configuration values in each row of the configuration items is that action and process,action are a condition/state, and the process is a pathname of the program that can be executed. Together, it means that the process is executed when the action condition is met.

Note: The key to understanding Inittab is to understand that the process is executed when the action condition is met. ”

2.rcS files to/etc/init.d/rcs (start with #!/bin/sh)

Path=xxx

(1) First from the syntax of the shell script analysis, this line defines a variable path, the value is equal to the following string

(2) After exporting this path with export, path becomes an environment variable.

(3) Path this environment variable is an environment variable defined within the Linux system, meaning that the operating system executes the program by default to the directory specified by path. If you can't find it, assume that the program does not exist, and if you find it, execute it. Exporting a directory of executable programs to path allows us to execute this program without a path.

(4) Why should the RCS guide the path. Just because we want to get to the command line, the PATH environment variable has the default/bin/sbin/usr/bin/usr/sbin of these common executable programs, so that we can go to the command line and use the LS, CD, etc. directly.

(5) Why our RCS file has not been added, the system boot has the value in path. The reason for this is that BusyBox has exported some environment variables to us using code hard-coded, including path.

Runlevel=

(1) RunLevel is also a shell variable and is exported as an environment variable.

(2) RunLevel What is the use of this environment variable.

(3) Runlevel=s indicates that the system is set to single user mode

umask=

(1) umask is a Linux command, the role is to set the Linux system Umask value.

(2) The Umask value determines the default permissions for the current user when creating the file.

Mount-a

(1) Mount command is used to mount the file system

(2) Mount-a is mounted on all of the file system should be mounted, in BusyBox mount-a BusyBox will go to find a file/etc/fstab file, which is listed in a certain format to all the file systems should be mounted (including the virtual file system)

Add a FSTSB file under/etc

(3) All errors occurred while mounting the test:

mount:mounting proc On/proc failed:no such file or directory

Mount:mounting Sysfs on/sys failed:no such file or directory

Mount:mounting TMPFS on/var failed:no such file or directory

Mount:mounting TMPFS on/tmp failed:no such file or directory

Mount:mounting TMPFS on/dev failed:no such file or directory

The reason is because the mount point is not found in the root file system. The mount point is that we want to mount the target file system (and, of course, the virtual file system) to a directory in the current file system, which is the mount point.

The solution is to create these mount point directories in the Rootfs root directory you are making.

Verify that the mount is successful, you can look at the output information when mounted, you can also start to see the proc and sys folder, if there is a file to prove that the mount succeeded, if there is nothing to prove failure.

Mdev

(1) Mdev is a udev embedded simplified version, Udev/mdev is used to match the Linux driver of an application layer software, Udev/mdev work is to match the Linux driver to generate the appropriate/dev directory of the device files.

(2) Because this problem involves driving, so the detailed explanation to wait until the driving part. Here we are only through some intuitive phenomenon to understand the udev/mdev work effect.

(3) When the RCS file does not start Mdev, the/dev directory is empty after startup, after adding Mdev related 2 line configuration items in the RCS file, it is found that a lot of device driver files are generated in the/dev directory after the system is restarted.

(4)/dev directory of the device driver file is Mdev generated, this is the Mdev effect and significance.

Hostname

(1) hostname is a shell command in Linux. Command (hostname XXX) can be used to set the current system's host name of XXX, direct hostname without parameters can display the current system's host name.

(2)/bin/hostname-f/etc/sysconfig/hostname-f to specify a hostname configuration file (this file is a generic file named hostname or hostname)

Use: a hostname (KING210) is defined in the/etc/sysconfig/hostname file

Ifconfig

(1) Sometimes we want to boot into the command line IP address is a specified IP address (such as 192.168.1.30), this time can be in the RCS file ifconfig eth0 192.168.1.30

3.profile file and user login theory

Profile file added to the/etc/directory to add the following experimental phenomenon: The command line prompts before: [@king210]#

User Login Combat

Add/bin/login to Sysinit

(1) Modify in Inittab, remove/bin/sh, put on/bin/login, then the login interface appears after the system starts. You can enter a user name and password.

(2) Experimental phenomenon: The successful appearance of user login interface, but the password is wrong.

Add passwd and Shadow files

(1) Why the username and password are not correct. Because we have not set a password for root user at all.

(2) The files used to describe user names and passwords in Linux systems are passwd and shadow files, all two of which are in the ETC directory. The passwd file stores the password settings for the user, and the encrypted password is stored in the shadow file.

(3) We directly copy the/etc/passwd and/etc/shadow files in the Ubuntu system to the currently produced Rootfs directory, and then make changes.

(4)/etc/passwd and/etc/shadow repaired, the shadow default has an encrypted password, this password and your copy of the shadow itself, like my Ubuntu root user password is root, So the password or root when the copy comes in.

Reset Password

(1) When Ubuntu is just installed, the default login is logged in with a normal user, and the default root user is closed. Ordinary user's password is installed when installing the system, the ordinary user can use Su passwd root to set the password to the root user after logging in, set the password after the root user can log in.

(2) In fact, the reason is that the root user in the/etc/shadow file encryption password is blank. So you can't log in.

(3) BusyBox because there is no ordinary users, so the practice is: the default root user if the encrypted password is empty, the default password is no direct login. After we log in, we can still use passwd root to set the password for the root user.

(4) Sometimes we forget the password of our own operating system, how to do. One solution is to use other systems (windowsPE system or Ubuntu Single-user mode etc. To boot, mount it on our hard drive, then locate the/etc/shadow file, and save the ciphertext password. Then reboot the system and the password will be gone.

4. Porting Dynamic Link Libraries

1. Locate and copy the dynamic link library file into the Rootfs

(1) We use the arm-2009q3 of this cross compilation tool chain in the dynamic link library under the/usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib directory. The directory of the dynamic link libraries in some of the other cross-compilation tool chains is not necessarily here, but find out. Finding is the way to find

(2) Copy the dynamic link library to the Roots/lib directory. When copying to note the parameters with-RDF, the main purpose is to copy the symbolic link or symbolic link.

Copy command: CP lib/*so*/root/porting_x210/rootfs/rootfs/lib/-RDF

2. Use the Strip tool to remove symbolic information from the library

The dynamic link library so file contains debug symbol information that is useless at run time (when debugging), which takes up a certain amount of space. In the traditional embedded system, the flash space is limited, in order to save space, these symbolic information is often removed. This saves space and does not affect running.

Remove symbol command: Arm-linux-strip *so*

Can compile an executable program test

Static Link: arm-linux-gcc hello.c-o hello_satic-static

Dynamic Link: arm-linux-gcc hello.c-o hello_dynamic

To perform dynamic linking on the developer Board console

Note: power-on self-starter and the mainstream RCS format introduction

Modify RCS to achieve power-on self-starter

(1) Starting from startup means that some applications can be automatically launched after the boot

(2) The principle of power-on self-priming is to add the statement code to execute a program in the script RCS that will be executed automatically on power-on.

Four, the production ext2 format mirroring and burning start

Determine Rootfs available in folder format

(1) Set Bootargs for NFS startup mode, and then start from the folder format rootfs in the host Ubuntu, and then look at the start effect as a future reference.

Make a mirror of ext2 format

DD If=/dev/zero of=rootfs.ext2 bs=1024 count=10240

Losetup/dev/loop0 rootfs.ext2

Mke2fs-m 0/dev/loop0 10240

Mount-t ext2/dev/loop0./ext2_rootfs/(Note the new folder)

(2) Copy content to./rootfs, with CP. /rootfs/*./-RF

(3) Umount/dev/loop1

Losetup-d/DEV/LOOP1

(4) After the completion of the ROOTFS.EXT2 is that we do a good rootfs image. Take it to burn it.

Burn the mirror and set the appropriate Bootargs

(1) Use FastBoot to record the ROOTFS.EXT2 to the Development Board Inand

FastBoot Flash System Rootfs.ext2

Reboot the system after the burn is complete

(2) Set Bootargs as: Set Bootargs console=ttysac2,115200 root=/dev/mmcblk0p2 rw init=/linuxrc rootfstype=ext2

(3) After the start of the discovery Phenomenon and NFS before the start of the Rootfs-mount after the same, so far Rootfs production experiment successfully completed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.