Exynos4412 file system production (3) - file system transplantation

       The root file system has always been an important part of all Unix-like operating systems, and it can also be regarded as an important feature that distinguishes embedded Linux systems from other traditional embedded operating systems. It brings many powerful and flexible features to Linux. functionality, but also brings some complexity. We need to clearly understand the basic structure of the root file system, and carefully select the required system libraries, kernel modules and applications, and configure various initialization script files, as well as select the appropriate file system type and put it in A suitable location for the actual storage device

      The root file system of Linux is organized in a tree structure, including various files and programs required by the kernel and system management. Generally speaking, the top-level directories under the root directory "/" have some relatively fixed names and uses.

The following lists the more common directory structures in a Linux root file system:

/bin is the directory where binary executable commands are stored

  This directory stores basic commands that all users can use. These commands can be used before other file systems are mounted, so the /bin directory must be in the same partition as the root file system.

  The commonly used commands in the /bin directory are: cat, chgrp, chmod, cp, ls, sh, kill, mount, umount, mkdir, m knod, [, test, etc. The "[" command is actually the test command. We are using Busybox to make it. When the root file system is used, in the generated bin directory, you can see some executable files, that is, some available commands.

/dev The directory where device files are stored

  Device files are stored in this directory. Device files are a unique file type in Linux. Under Linux, various devices are accessed as files, that is, to operate a specific hardware by reading and writing a device file. For example, the serial port 0 can be operated through the "dev/ttySAC0" file, and the second partition of the MTD device can be accessed through "/dev/mtdblock1".

/etc Directory for system management and configuration files

  Various configuration files are stored in this directory. For the Linux system on the PC, there are many files and directories in the /etc directory. These directory files are optional. They depend on the applications owned by the system. Whether the program requires a configuration file. In embedded systems, these can be greatly reduced.

/home The home directory of the user, for example, the home directory of the user user is /home/user, which can be represented by ~user

   User directory, which is optional. For each ordinary user, there is a subdirectory named after the user name in the /home directory, which stores user-related configuration files.

/lib The directory where the dynamically linked shared library is stored

 Shared libraries and loadables (drivers) are stored in this directory, and shared libraries are used to start the system. Run executable programs in the root file system, such as programs in the /bin/sbin directory.

/sbin The directory where the management programs used by the system administrator are stored

  This directory stores system commands, that is, commands that only administrators can use. System commands can also be stored in /usr/sbin and /usr/local/sbin directories. The /sbin directory stores basic system commands. For booting the system, repairing the system, etc., similar to the /bin directory, /sbin can be used before other file systems are mounted, so the /sbin directory must be in the same partition as the root file system.

  Common commands in the /sbin directory are: shutdown reboot fdisk fsck, etc. The system commands installed by local users are placed in the /usr/local/sbin directory.

/tmp public temporary file storage point

  It is used to store temporary files, usually an empty directory. Some programs that need to generate temporary files use the /tmp directory, so the /tmp directory must exist and be accessible.

/root System administrator's home directory

  The directory of the root user. Correspondingly, the directory of ordinary users is a subdirectory under /home.

The /mnt system provides this directory to allow users to temporarily mount other file systems.

  The mount point used to temporarily mount a file system, usually an empty directory, or an empty subdirectory can be created in it, such as /mnt/cdram /mnt/hda1 . Used to temporarily mount CDs and hard disks.

/proc Virtual file system, you can directly access this directory to get system information .

  This is an empty directory, which is often used as the mount point of the proc file system. The proc file system is a virtual file system without actual storage devices. The directories and files in it are temporarily generated by the kernel to indicate the operation of the system. state, you can also operate the file control system in it.

/usr The largest directory, almost all the applications and files used are in this directory.

  The contents of the /usr directory can be stored in another partition, and then mounted to the /usr directory in the root file system after the system is started. It stores shared, read-only programs and data, which indicates that the contents of the /usr directory can be shared among multiple hosts, and these are mainly in line with the FHS standard. Files in /usr should be read-only, other host-dependent, variable files should be stored in other directories, such as /var. The /usr directory can be reduced in embedded.

/var overflow area for some large files

  In contrast to the /usr directory, the /var directory stores variable data, such as the spool directory (mail, news), log files, and temporary files.


---------------------------------------------------------------------

First, the transplant environment:

1. Ubuntu 10.10 release

2、  u-boot.bin

3. Target machine: FS4412 platform

4. Cross compiler arm-none-linux-gnueabi-gcc

------------------------------------ ----------------------------------


2. Transplantation steps

1. Source code download

The version we chose is busybox-1.17.3.tar.bz2 The download path is: http://busybox.net/downloads/

2. Unzip the source code

$ tar xvf  busybox-1.17.3.tar.bz2

3. Enter the source code directory

$ cd busybox-1.17.3

4. Configure the source code

$ make menuconfig
Busybox Settings --->
       Build Options --->
              [*] Build BusyBox as a static binary (no shared libs)
              [] Force NOMMU build
              [ ] Build with Large File Support (for accessing files > 2 GB)
              (arm-cortex_a8-linux-gnueabi-) Cross Compiler prefix
              () Additional CFLAGS

5. Compile

$ make

6. Installation

The default installation path of busybox is _install in the source directory

$ make install

7. Enter the installation directory

$ cd _install
$ ls
bin  linuxrc  sbin  usr

8. Create other required directories

$ mkdir  dev etc  mnt proc var tmp sys root

9. Add library

在_install目录下创建一个lib文件夹,将工具链中的库拷贝到lib目录下

$ mkdir lib
$ cp /home/linux/x-tools/arm-cortex_a8-linux-gnueabi/arm-cortex_a8-linux-gnueabi/lib/*  ./lib/

删除lib下的所有目录、.o文件和.a文件,对库进行瘦身以减小文件系统的大小

$ rm *.o *.a
$ arm-cortex_a8-linux-gnueabi-strip  lib/*

10、 添加系统启动文件

在etc下添加文件inittab

$ vim /etc/inittab

文件内容如下:

#this is run first except when booting in single-user mode.
:: sysinit:/etc/init.d/rcS
# /bin/sh invocations on selected ttys
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
# Stuff to do when restarting the init process
::restart:/sbin/init
# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot

在etc下添加文件fstab

$ vim /etc/fstab

文件内容如下:

#device     mount-point     type        options         dump     fsck order
proc          /proc         proc        defaults        0          0
tmpfs      /tmp         tmpfs       defaults          0          0
sysfs         /sys          sysfs       defaults         0          0
tmpfs         /dev          tmpfs       defaults         0          0

  这里我们挂在的文件系统有三个proc、sysfs和tmpfs,在内核中proc和sysfs默认都支持,而tmpfs是没有支持的,我们需要添加tmpfs的支持

修改内核配置:

$ make menuconfig
File systems --->
       Pseudo filesystems --->
              [*] Virtual memory file system support (former shm fs)
              [*] Tmpfs POSIX Access Control Lists

重新编译内核

$ make zImage

在etc下创建init.d目录,并在init.d下创建rcS文件

$ mkdir /etc/init.d -p
$ vim /etc/init.d/rcS

rcS文件内容为:

#!/bin/sh
# This is the first script called by init process
/bin/mount -a

为rcS添加可执行权限:

$ chmod  +x init.d/rcS

在etc下添加profile文件

$ vim /etc/profile

文件内容为:

#!/bin/sh
export HOSTNAME=farsight
export USER=root
export HOME=root
#export PS1="\[\u@\h \W\]\$ "
export PS1="[$USER@$HOSTNAME \W]\# "
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH
export PATH LD_LIBRARY_PATH

11、 设备文件创建

根文件系统中有一个设备节点是必须的,在dev下创建console节点

$ mknod   dev/console  c 5 1

重要:新制作的文件系统尺寸若超出8M,删除不需要的库文件。


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324673511&siteId=291194637