Making a Linux root file system using BusyBox

Source: Internet
Author: User

STEP 1: Building the directory structure

Create the root file system directory, mainly including the following directories
/dev/etc/lib/usr/var/proc/tmp/home/root/mnt/bin/sbin/sys

#mkdir/home/rootfs
#cd/home/rootfs

#mkdir Dev etc Lib usr var proc tmp home Root MNT sys

STEP 2: Build/bin/sbin LINUXRC with BusyBox

Enter the busybox-1.16.1 directory and execute

#make Defconfig

#make Menuconfig

Busybox Setting----->
Build Options----->
//1 choose to statically compile the BusyBox
[*] Build BusyBox as a static binary (no shared libs)
//2. Specifies that the cross compiler is
(/usr/local/arm/4.3.2/bin/arm-linux-) Cross Compiler Prefix

Installation Options----->

//3. Select Upper Don ' t use/usr
Busybox Library Tuning--->
[*] Username completion
[*] Fancy Shell Prompts
[*] Query cursor Position from terminal
//4. The compiled busybox shell command interpreter supports displaying the current path and host information

Save exit

#make
#make Install

In the BusyBox directory, you will see the _install directory with/bin/sbin linuxrc three files.
Copy these three directories or files to the Rootfs folder that you built in the first step.

#cp Bin/sbin/linuxrc/home/rootfs-ra

Remember to take the-a parameter, because most of the bin directory is a link, if not with the-a parameter, copy the past will do the corresponding replication, is no longer the form of links

STEP 3 Build etc directory:

1) Enter the ETC directory of the root file system Rootfs and do the following:

copy busybox-1.16.1/examples/bootfloopy/etc/* to current directory
#cp –r busybox-1.16.1/examples/bootfloopy/etc/* rootfs/etc

Revise the Inittab and replace the second item with: Respawn:-/bin/login

Delete the third and fourth lines of code

2) Copy the/etc/passwd on the virtual machine,/etc/group,/etc/shadow to Rootfs/etc

# cp/etc/passwd Rootfs/etc
# Cp/etc/group Rootfs/etc
# Cp/etc/shadow Roofs/etc

Changes to the following three files, only the root-related items, depending on the circumstances of the content will be different.

Modify passwd to Root:x:0:0:root:/root:/bin/sh, that is, to save only the root-related items, and finally change to/bin/ash.

Modify Group to Root:x:0:root

Modify Shadow to Root:$1$x9yv1wlb$abj2v9joloc9xw/y0qwps.:14034:0:99999:7:::

Login to the board to enter the user name password, the same as the virtual machine

3) Modify Profile

Path=/bin:/sbin:/usr/bin:/usr/sbin//Executable program Environment variables

Export ld_library_path=/lib:/usr/lib//dynamic link library environment variables

/bin/hostname sunplusedu

User= "' Id-un '"

Logname= $USER

Hostname= '/bin/hostname '

Ps1= ' [\[email protected]\h \w]# '//Display host name, current path and other information:

4) Modify the ETC/INIT.D/RC. S file

/bin/mount-n-T Ramfs Ramfs/var

/bin/mount-n-T Ramfs ramfs/tmp

/bin/mount-n-T Sysfs None/sys

/bin/mount-n-T Ramfs None/dev

/bin/mkdir/var/tmp

/bin/mkdir/var/modules

/bin/mkdir/var/run

/bin/mkdir/var/log

/bin/mkdir-p/dev/pts//telnet Service required

/bin/mkdir-p/DEV/SHM//telnet Service required

Echo/sbin/mdev >/proc/sys/kernel/hotplug//usb Auto Mount required

/sbin/mdev-s//Start Mdev automatically create a device file node in/dev

/bin/mount-a

5) Modify the Etc/fstab file to add the following file

none/dev/pts devpts mode=0622 0 0
TMPFS/DEV/SHM TMPFS Defaults 0 0

STEP 4 Build the Lib directory:

1) #cd/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib

Copy the following dynamic libraries to Rootfs/lib
#cp *so* roofs/lib-a

2) #cd/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib
Copy the following dynamic libraries to Rootfs/lib
#cp./libstdc++.so.* rootfs/lib-a

Making a Linux root file system using BusyBox

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.