Porting of the BusyBox file system

Source: Internet
Author: User
Tags create directory

Related software: Http://pan.baidu.com/s/16yo8Y

FSC100 Development Board

Cross compiler: ARM-CORTEX_A8-LINUX-GNUEABI-GCC

busybox-1.17.3.tar.bz2

First, the root file system production

1. Source code Download

The version we chose is the busybox-1.17.3.tar.bz2 download path:

http://busybox.net/downloads/

2. Extracting source code

$ tar xvf busybox-1.17.3.tar.bz2

3. Enter the source 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. Compiling

$ make

6. Installation

BusyBox default installation path is _install under 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

    • Copy the libraries in the toolchain to the _install directory

$ cp/home/linux/toolchain/arm-cortex_a8-linux-gnueabi/lib./A

    • To delete a symbol table from a static library and a shared library file

$ RM lib/*.a

$ Arm-cortex_a8-linux-gnueabi-strip lib/*

    • Delete unwanted libraries to ensure that all library sizes do not exceed 4M

$ RM lib/libstdc++*

$ DU-MH lib/

10. Add System Boot File

Add File Inittab under etc, the file content is as follows:

#this is the 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. May)

:: askfirst:-/bin/sh

# stuff to does when restarting the INIT process

:: Restart:/sbin/init

# stuff to do before rebooting

:: Ctrlaltdel:/sbin/reboot

Add File Fstab under etc, the file content is as follows:

#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

Here we mount a filesystem with three proc, Sysfs and Tmpfs. In the kernel proc and SYSFS are supported by default, and TMPFS is not supported, we need to add TMPFS support

To modify the kernel configuration:

File Systems--->

Pseudo filesystems--->

[*] Virtual Memory File system support (former SHM FS)

[*] Tmpfs POSIX Access Control Lists

Recompile the kernel

Create the INIT.D directory under etc, and create the RCS file under INIT.D, the contents of the RCS file are:

#!/bin/sh

# This was the first script called by Init process

/bin/mount-a

Echo/sbin/mdev >/proc/sys/kernel/hotplug

/sbin/mdev-s

Add executable permissions for RCS:

$ chmod +x Init.d/rcs

Under etc, add the profile file with the following contents:

#!/bin/sh

Export Hostname=farsight

Export User=root

Export Home=root

Export ps1= "[[email protected] $HOSTNAME \w]\#"

Path=/bin:/sbin:/usr/bin:/usr/sbin

Ld_library_path=/lib:/usr/lib: $LD _library_path

Export PATH Ld_library_path

11. Device File Creation

A device node in the root filesystem is required, and the console node is created under Dev

$ sudo mknod dev/console C 5 1

Important: The newly crafted file system size exceeds 8M , delete the library files that you do not need

Second,theNFS test

1, delete the original/source/rootfs

$ sudo rm-rf/source/rootfs

2. Copy our new root file system to the/source/rootfs directory

$sudo Mkdir/source/rootfs

$ sudo cp _install/*/source/rootfs–a

3. Set UBOOT environment variable

# setenv Bootcmd tftp 20008000 zimage\; Go 20008000

# setenv Bootargs root=nfs nfsroot=192.168.1.100:/source/rootfs init=/linuxrc console=ttysac0,115200 ip=192.168.1.200

# saveenv

Restart the board to see if it is properly mounted and functioning properly

third, the production RAMDisk File System

After the NFS test, you can make the RAMDisk file system, as follows:

1, make a 8M size image file

$ cd ~

$ dd If=/dev/zero of=initrd.img bs=1k count=8192 (initrd.img to 8M)

2. Format this image file as Ext2

$ mkfs.ext2-f initrd.img

3. Create initrd directory as mount point under Mount

$ sudo mkdir/mnt/initrd

4. Mount this disk image file under/MNT/INITRD

Note that the initrd.img here do not mix with initrd.img in the Ubuntu root directory, and initrd.img cannot be stored in the Rootfs directory.

$ sudo mount-t ext2-o loop initrd.img/mnt/initrd

5. Copy our file system to Initrd.img

Copy all the contents of the tested file system to the/MNT/INITRD directory

$ sudo cp/source/rootfs/*/mnt/initrd–a

6, uninstall INITRD

$ sudo umount/mnt/initrd

7, compressed initrd.img for initrd.img.gz and copied to/tftpboot

$ gzip--best-c initrd.img > initrd.img.gz

$ CP Initrd.img.gz/tftpboot

8. Configure Kernel support RAMDisk

After you have finished making initrd.img.gz, you need to configure the kernel to support RAMDisk as the boot file system

Device Drivers

SCSI Device Support--->

<*> SCSI Disk Support

Block Devices--->

<*>ram Block Device Support

(1) Default Number of RAM disks

(8192) Default RAM disk size (Kbytes) (modified to 8M)

General Setup--->

[*] Initial RAM filesystem and RAM disk (INITRAMFS/INITRD) support

Recompile kernel, copy to/tftpboot

9. Reset the startup parameters on the u-boot command line:

# setenv bootcmd tftp 20008000 zimage \; TFTP 20800000 initrd.img.gz \; Go 20008000

# setenv Bootargs root=/dev/ram rw init=/linuxrc initrd=0x20800000,8m console=ttysac0,115200

# saveenv

Restart the board to see if it can start properly

Iv. Production Cramfs File System

1, Cramfs file system image production

As the system provides the tools to make Cramfs file system, it can be used directly. The specific operation is as follows;

$ mkfs.cramfs/source/rootfs Rootfs.cramfs

2. Copy the Rootfs.cramfs to the/tftpboot directory

$ sudo cp rootfs.cramfs/tftpboot

3. Write Rootfs.cramfs to the third section of NAND flash

U-boot Execute the following command

# TFTP 20008000 Rootfs.cramfs

# NAND Erase 400000 400000

# NAND Write 20008000 400000 400000

4. Reset U-boot Startup Parameters

# setenv Bootcmd tftp 20008000 zimage\; Go 20008000

# setenv Bootargs Root=/dev/mtdblock2 INIT=/LINUXRC console=ttysac0,115200

# saveenv

Launch the Development Board and test for success.

[[email protected]/root] # ls/

Bin etc linuxrc Sbin tmp var

Dev lib mnt proc test usr

[[email protected]/root] # mkdir Test

Mkdir:cannot Create directory ' Test ': Read-only file system

Note: Cramfs the format of the file system is read-only the .

v. Production of JFFS2 file System

1. Configuration kernel supports JFFS2 file system

File Systems--->

[*] Miscellaneous filesystems--->

<*> journalling Flash File System v2 (JFFS2) support

Recompile the kernel and copy it to/tftpboot

2, the compilation of zlib

Unzip the zlib-1.2.3.tar.bz2 and enter the zlib-1.2.3 configuration to compile the installation

$ tar xvf zlib-1.2.3.tar.bz2

$ CD zlib-1.2.3

$./configure

$ make

$ sudo make install

3. MTD Tool Compilation

Unzip the mtd-snapshot-20050519.tar.bz2 and enter Mtd/util to compile the installation

$ tar xvf mtd-snapshot-20050519.tar.bz2

$ CD Mtd/util

$ make

$ sudo make install

So we have the MKFS.JFFS2 tool in our system.

4, JFFS2 file system image production

$ mkfs.jffs2-r/source/rootfs-o rootfs.jffs2-e 0x20000--pad=0x400000-n

$ sudo cp rootfs.jffs2/tftpboot

5, JFFS2 file system burn Write

# TFTP 20008000 ROOTFS.JFFS2

# NAND Erase 400000 400000

# NAND Write 20008000 400000 400000

6. Set U-boot startup Parameters

# setenv Bootcmd tftp 20008000 zimage\; Go 20008000

# setenv Bootargs root=/dev/mtdblock2 rootfstype=jffs2 rw init=/linuxrc

console=ttysac0,115200

# saveenv

Restart the development Board to see if it is successful

Porting of the BusyBox file system

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.