Ubifs File System
(1). host environment: ubuntu 12.04
(2). Integrated Development Environment: vim
(3) compiling environment: arm-linux-gcc 4.4.3
(4). Development Board: mini2440
(5). u-boot version: u-boot-2009.08
(6). kernel version: linux-2.6.32.2
(7). Required package: busybox-1.17.2-20101120.tgz rootfs_qtopia_qt4-20111212.tgz linux-2.6.32.2.tar mktools.tar.gz
Busybox-1.17.2-20101120.tgz:
Http://download.csdn.net/detail/taozi343805436/4576011
Mktools.tar.gz:
Http://download.csdn.net/detail/taozi343805436/4576014
1. Obtain the source code of the busybox package.
(1) create a directory as the directory created by the File System
Root @ ubuntu:/home/hero # mkdir makeubifs
(2) route the obtained busybox package and Linux kernel package to the makeubifs directory:
Root @ ubuntu:/home/hero/makeubifs # ls
Busybox-1.17.2-20101120.tgz linux-2.6.32.2
2. Description of the root file system directory
In Embedded LINUX, you need to build the root file system. The rules for building the root file system are in the FHS document. below is the top-level directory of the root file system.
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 shared libraries and loaded blocks (drivers). The shared libraries are used to start the system and run executable programs in the root file system.
The static file 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. You can also create an empty subdirectory in it.
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, such as logs.
3. Create a system directory
(1) create a directory named myrootfs under the same Kernel Directory
Root @ ubuntu:/home/hero/makeubifs # ls
Busybox-1.17.2-20101120.tgz linux-2.6.32.2 myrootfs
(2) Go to the directory myrootfs and create a new script file mkrootfs that creates the root file system directory.
Root @ ubuntu:/home/hero/makeubifs # cd myrootfs/
Root @ ubuntu:/home/hero/makeubifs/myrootfs # vim mkrootfs
Edit the script file:
#! /Bin/sh
Echo "------ Create rootfs directons start ...--------"
Mkdir rootfs
Cd rootfs
Echo "-------- Create root, dev ....----------"
Mkdir bin boot dev etc home lib mnt proc root sbin sys tmp usr var www
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 666 dev/console c 5 1
Mknod-m 666 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 ---------"
Save and exit, modify permissions, and execute the script.
Root @ ubuntu:/home/hero/makeubifs/myrootfs # chmod 777 mkrootfs
Root @ ubuntu:/home/hero/makeubifs/myrootfs # ux-2.6.32.2 # make modules./mkrootfs
------ Create rootfs directons start ...--------
-------- Create root, dev ....----------
Make node in Dev/console DEV/null
------- Make direction done ---------
In this way, the root file system directory is created.
4. Compile and install the kernel module
(1) enter the Linux kernel directory and modify the makefile, which is about 182 lines.
Export kbuild_buildhost: =$ (subarch)
Arch? = Arm
Cross_compile? = Arm-Linux-
Then execute make modules compilation. If an error occurs (touch screen problem), run:
Root @ Ubuntu:/home/hero/makeubifs/linux-2.6.32.2 # cp ARCH/ARM/configs/s3c2410_defconfig. config
After compilation, install the compiled module:
Root @ Ubuntu:/home/hero/makeubifs/linux-2.6.32.2 # Make modules_install arch = arm install_mod_path =/home/hero/makeubifs/myrootfs/rootfs/
(2) create a dynamic Connection Library
Decompress the file rootfs_qtopia_qt4 and copy the Lib content to the new root file directory Lib.
Root @ Ubuntu:/home/hero/makeubifs/rootfs_qtopia_qt4 # cp-a lib/*/home/hero/makeubifs/myrootfs/rootfs/lib/
5. Cross-compile bosybox
Bosybox is an open-source project that complies with the GPL v2 protocol. It optimizes the file size during the compilation process and considers the limited system resources (such as memory, busybox can automatically generate the bin, sbin, USR directory, and linuxrc files required by the root file system.
(1) obtain the software package bosybox and decompress it.
Root @ Ubuntu:/home/hero/makeubifs # ls
Busybox-1.17.2-20101120.tgz linux-2.6.32.2 myrootfs rootfs_qtopia_qt4
Root @ Ubuntu:/home/hero/makeubifs # tar-zxf busybox-1.17.2-20101120.tgz
(2) Go to the top-level directory of the bosybox and modify the makefile.
In row 3: cross_compile? = Arm-Linux-
In the row 190: arch? = Arm
(3) Compile the configuration
Run make menuconfig in the top-level directory of busybox.
1. busybox settings --->
Build Options --->
[*] Build BusyBox as a static binary (no shared libs) [] Force NOMMU build (NEW)
[*] Build with Large File Support (for accessing files> 2 GB) (NEW)
(Arm-linux-) Cross Compiler prefix
() Additional CFLAGS (NEW)
2. Busybox Settings --->
Installation Options --->
[*] Don't use/usr
Applets links (as soft-links) --->
(/Home/hero/makeubifs/myrootfs/rootfs) BusyBox installation prefix
3. Busybox Library Tuning --->
[*] Support for/etc/networks
[*] Command line editing
(1024) Maximum length of input
[*] Vi-style line editing commands
(15) History size
[*] History saving
[*] Tab completion
[*] Username completion
[*] Fancy shell prompts
Save and exit and compile bosybox.
Root @ ubuntu:/home/hero/makeubifs/busybox-1.17.2 # make CONFIG_PREFIX =/home/hero/makeubifs/myrootfs/rootfs install
A linuxrc directory is added to the rootfs directory.
6. Create a configuration file under the etc directory
(1) create a configuration file for the/etc/group system user group. The content is as follows:
Root: *: 0:
Daemon: *: 1:
Bin: *: 2:
Sys: *: 3:
Adm: *: 4:
Tty: *: 5:
Disk: *: 6:
Lp: *: 7: lp
Mail: *: 8:
News: *: 9:
U p: *: 10:
Proxy: *: 13:
Kmem: *: 15:
Dialout: *: 20:
Fax: *: 21:
Voice: *: 22:
Cdrom: *: 24:
Floppy: *: 25:
Tape: *: 26:
So: *: 27:
Aio: *: 29:
Ppp: x: 99:
500: x: 500: plg
501: x: 501: fa
(2) create a passwd System Password File
Root: 0: 0: root:/bin/sh
Ftp: 14: 50: FTP User:/var/ftp:
Bin: *: 1: 1: bin:/bin:
Daemon: *: 2: 2: daemon:/sbin:
Nobody: *: 99: 99: Nobody :/:
Sky: 502: 502: Linux User,:/home/sky:/bin/sh
Root @ ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # ls
Group init. d passwd rc. d sysconfig
(3) create a host file named HOSTNAME in the etc/sysconfig directory with the content "hello"
Root @ ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc/sysconfig # cat> HOSTNAME
Hello
^ C
(4) Create the etc/inittab system init process configuration file
# Etc/inittab
: Sysinit:/etc/init. d/rcS
: Askfirst:-/bin/sh
: Ctrlaltdel:/sbin/reboot
: Shutdown:/bin/umount-a-r
Modify the executable permissions of an object:
Root @ ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # chmod 777 inittab
(5) Create the etc/init. d/rcS system startup add-on file
#! /Bin/sh
PATH =/sbin:/bin:/usr/sbin:/usr/bin
Runlevel = S // running level
Prevlevel = N
Umask 022 // folder mask
Export PATH runlevel prevlevel
Echo "---------- munt all ----------------"
Mount-a // mount all the file systems specified by/etc/fstab/File
Echo/sbin/mdev>/proc/sys/kernel/hotplug
Mdev-s
Echo "************************************** *********"
Echo "******* booting to mini2440 ***************"
Echo "Kernel version: linux-2.6.32.2"
Echo "Date: 2012.9.17"
Echo "************************************** *********"
/Bin/hostname-F/etc/sysconfig/HOSTNAME
Modify its permissions: root @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # chmod 777 init. d/RCS
(6) Create an etc/fstab system and mount the file system list file. copy and paste the following content:
# 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) Create the etc/profile user environment configuration file, copy and paste the following content:
# 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
Modify the environment variable PS1 (command line prompt), you can use VI to edit the/etc/profile file, and add:
Export PS1 = '[\ U @ \ H \ W] \ $'
Where \ U shows the current user account, \ h shows the current host name, \ W shows the current path, \ $ shows the '$' symbol
\ W can replace \ W to convert absolute paths to relative paths.
(8) Create ETC/mdev. conf (mdev device configuration file), net. conf (network configuration file), and mime. types: MIME (Multipurpose Internet Mail Extensions.
Root @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # Vim mdev. confroot @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # Vim net. confroot @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # Vim mine. types
(9) create a configuration file for the boa Web Server
In the ETC/BOA directory and create the boa. conf file in the BOA directory, the content is empty.
Root @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # mkdir Boa
Root @ Ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc # Vim BOA/boa. conf
(10) first create the etc/rc. d/init. d directory
Root @ ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc/rc. d # mkdir init. d
Root @ ubuntu:/home/hero/makeubifs/myrootfs/rootfs/etc/rc. d # ls
Init. d
Create the etc/rc. d/init. d/httpd file.
#! /Bin/sh
Base = boa
# See how we were called.
Case "$1" in
Start)
/Usr/sbin/$ base
;;
Stop)
Pid = '/bin/pidof $ base'
If [-n "$ pid"]; then
Kill-9 $ pid
Fi
;;
Esac
Exit 0
(11) Create the etc/resolv. conf and DNS configuration file to store the DNS information required for Internet access. The content is as follows:
Nameserver 61.144.56.100
(12) In the/home/sky directory, it corresponds to the sky in the passwd file of the etc directory.
Mkdir home/sky
7. Create a file system image in UBIFS format
Through the above work, we now get the directory rootfs
# Mkubimage-mlc2 rootfs. ubi will suppress the rootfs directory as the rootfs in UBIFS format. ubi image file, which is applicable to MLC2 Nand Flash with a Block Page Structure of "1 Page = 8 K Byte, 1 Block = 1 MB", and then rootfs. the ubi file system is burned to the Development Board.
Root @ ubuntu:/home/hero/makeubifs/myrootfs # mkubimage-mlc2 rootfs. ubi
Please wait...
Succeed!
Note: mkubimage is designed by FriendlyARM (www.arm9.net)
Root @ ubuntu:/home/hero/makeubifs/myrootfs # ls
Mkrootfs rootfs. ubi
Root @ ubuntu:/home/hero/makeubifs/myrootfs #
8. Build mkubimage-mlc2
Mktools.tar.gz-C/
The corresponding tool set will be created in the/usr/sbin directory.