Create a linux root file system

Source: Internet
Author: User

From: http://blog.163.com/dong_box/blog/static/26259778200956114858764/

Root file system creation (busybox1.9.2)(09:02:22)

1. Create a directory named rootfs to install the file system.

2 # mkdir bin Dev etc home lib MNT proc root sbin tmp usr VaR
# Mkdir usr/bin usr/sbin
# Mkdir mnt tmp VaR
# Chmod 1777 TMP
# Mkdir MNT/etc MNT/jffs2 MNT/yaffs MNT/Data MNT/temp
# Mkdir var/lib var/lock var/log var/run var/tmp
# Chmod 1777 var/tmp
# Mkdir home root boot

3. In System/dev, pack all devices and copy them to Dev.
The following (the most time-consuming method); or use mknod to build the desired device,
Example:
# Mknod-m 600 DEV/console C 5 1
# Mknod-M 666 DEV/null C 1 3

4. Application Customization

The standard Linux release version has a wide range of applications, and these applications occupy a lot of space. This is not an ideal choice for development boards with limited storage space, in the embedded development process, busybox is often used to customize applications. Busybox has the shell function, which can provide most of the tools required by the system, these tools include editing tools, Network Tools, module loading tools, compression and decompression tools, search tools, account and password management tools, and process-related tools. Currently the latest version of busybox is the BusyBox-1.9.2 version, download unzip, switch to busybox
In the root directory, modify makefile and find arch and cross compile as follows:
Arch? = Arm
Cross_compile? =/Usr/local/ARM/3.4.1/bin/ARM-Linux-

5. Modify the compilation configuration options.
# Make defconfig
# Make menuconfig
With the default options, the options are set as follows:

Build options->

Build busybox as a static binary (no shared libs)

Force nommu build

Build shared libbusybox

Build with large file support (for accessing File> 2 GB)

If you select build busybox as a static binary (no shared libs) for compilation, the required library is already statically linked with the program, these programs can be run independently without additional libraries, but the self-compiled programs must be statically compiled to run on the file system. Otherwise, the following reports will be reported: bin/sh: Hello: not Found error.

Static compilation is as follows:

Arm-Linux-gcc-static hello. C-O hello

If you select build shared libbusybox for compiling, you must copy the dynamic library or symbolic link that is cross-compiled to the corresponding directory. Otherwise, the program cannot run. At the same time, remove the two items in the build shared libbusybox directory during configuration:

Build shared libbusybox->

Produce binary for each applet, linked against libbusybox

Produce additional busybox binary linked against libbusybox

Remove

Build with large file support (for accessing File> 2 GB)

Otherwise, an error is reported during compilation.

Busybox settings --->
Build options ---> (using static compilation)
[*] Build busybox as a static binary (no shared libs)
Install optin -->
[*] Don't use/usr //
Busybox library tuning --->
(2) MD5: Trade bytes for speed
[*] Faster/proc scanning code (+ 100 bytes)
[*] Support for/etc/networks
[*] Support for/etc/networks
[*] Additional editing keys
[*] Vi-style line editing commands
[*] History saving
[*] Tab completion
[*] Username completion
[*] Fancy shell prompts

LINUX module utilities --->
[] Support version 2.2.x to 2.4.x linux kernels // optional
[*] Support version 2.6.x linux kernels
Linux system utilities --->
[*] Support for the old/etc/mtab file // not sure
Miscellaneous utilities --->
[*] Devfs (obsolete) // uncertain
[*] Use devfs names for all device (obsolete) // uncertain
Shell --->
Choose your default shell (Ash) -->
--- Ash // select all the options below
// Use the space key to select. The bin/sh file is generated only when ash is selected.
// In the first line of the linuxrc Script :#! /Bin/sh is interpreted and executed by bin/sh.
// If this option is not selected, the following error occurs: can not run-bin/sh.

# Make
# Make install
In the busybox/_ install directory, the files we need will be generated.
Modify the properties of _ install/bin/busybox. Is 4755
Chmod 4755./_ install/bin/busybox
You must modify attributes. Otherwise, many commands in busybox are restricted.
Copy the compiled busybox to/bin. When copying an object, the parameter-arn or-DPR is included.

(Copy the bin directory and sbin directory under the busybox/_ install directory to the root file system directory)
All other commands except busybox are links
/Sbin is also the link of busybox,
/Usr/bin is also the link of busybox,
All the compiled executable files are placed under/usr/sbin.
7. It is very important to pay attention to/lib.
/Lib library is actually the library for compiling busybox, that is, the library for cross compiler. Here we use 3.4.5 (
Location/usr/local/ARM/gcc-3.4.5-glibc-2.3.2/ARM-Linux/bin /).
# Cd/usr/local/ARM/gcc-3.4.5-glibc-2.3.2/ARM-Linux/bin/
# For file in libc libcrypt libdl libm libpthread libresolv libutil
> Do
> CP $ file-*. So rootfs/lib (copy to the/lib directory of your file system)
> CP-d $ file. So. [* 0-9] rootfs/lib
> Done
# Cp-d ld *. So * rootfs/lib
# Cp libstdc ++. so.6 libgcc_s.so.1 rootfs/lib
8. Create a system configuration file
Put the system configuration file in the/etc directory
(1) profile file
# Set search LIBRARY PATH
Export LD_LIBRARY_PATH =/lib:/qtlib: $ LD_LIBRARY_PATH # Set User path
Export Path =/bin:/sbin:/usr/bin:/usr/sbin: $ path

Export qws_display = "linuxfb: mmwidth100: mmheight130: 0"

Export qws_mouse_proto = "linuxtp:/dev/h3600_tsraw"

Export qws_size = 320x240
Alias LL = 'LS-l'

Ln-S/dev/ts0/dev/h3600_tsraw

(2) fstab file
Proc/proc defaults 0 0
None/tmp ramfs defaults 0 0
Mdev/dev ramfs defaults 0 0
Sysfs/sys sysfs defaults 0 0
(3) inittab File
: Sysinit:/etc/init. d/RCS
: Respawn:-/bin/sh
: Ctrlaltdel:/bin/umount-a-r
: Shutdown:/bin/umount-a-r
: Shutdown:/sbin/swapoff-
(4) Create the/etc/init. d folder and the RCs, and add
#! /Bin/sh
# Set the host name. You must create a file host in the etc.
./Etc/Host
Hostname $ {hostname}
# Mount all filesystem defined in "fstab"
Echo "# mount all ..........."
/Bin/Mount-
Echo "# Starting mdev ........."
/Bin/ECHO/sbin/mdev>/proc/sys/kernel/hotplug
Mdev-S
(5) host file
Hostname = hasotech
(6) Create the mdev. conf file (empty file)
(7) copy the passwd, group, and shadow files under the host/etc/to/etc.
# Cp/etc/group.
# Cp/etc/passwd.
# Cp/etc/shadow.
Modify the shell name used by the user in passwd. Bash is used by default on fc6, while Vivi only supports ash.
Root: X: 0: 0: Root:/root:/bin/Bash -->
Root: X: 0: 0: Root:/root:/bin/ash
(8) modify the permissions of each file and folder
# Chmod 755/rootfs/etc/init. d/RCS
# Chmod 755/rootfs/etc/Host

9 production of the yaffs File System Image
You can use the mkyaffsimg program to create a directory as a yaffs image file, and then download it
Board. Go to the file system directory layer and run the following command.
# Mkyaffsimg rootfs. img
In this way, the rootfs. IMG image file will be generated in this directory and downloaded to the Development Board for running.

10 cramfs file system image creation (cramfs compression rate is relatively high)
Download cramfs-1.1.tar.gz in ftpand decompress it to your own directory, for example:
Cramfs-1.1.tar.gz-C/home/tar xzvf/
Go to the directory where the mkcramfs file is generated (Be sure to enter this directory; otherwise, the system will prompt that the command cannot be found)
Enter the command: #./mkcramfs/rootfs. cramfs
The rootfs. cramfs image file is generated in the current directory. The Linux operating system has been transplanted.

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.