Port busybox to the host

Source: Internet
Author: User

Port busybox to the host


What we need to do today is not to port busybox to the Development Board, but to port it to our host:


Any Linux instance that can be started is composed of three parts:Boot Program, kernel image and File System.


1. Bootstrap program:

In order not to be too complex, today's experiment assumes that grub has been installed on our host (like me, grub is automatically installed after Ubuntu is installed, So skip this step ), we use it to start our mini Linux.



Binary kernel image (Vmlinuz)

Download the Linux Source Code directly on the http://www.kernel.org/, and then compile, note that the target platform is x86 on the line, here not to repeat (detailed process see my another article: http://blog.csdn.net/htttw/article/details/7215873 ), after compilation, bzimage (make
Bzimage) or zimage (make zimage), and then copy to/boot:

Sudo cp arch/x86/boot/bzimage/boot/vmlinuz



Three file systems (Initrd.gz)

We use busybox to build our file system:

1.

Download busyboxin http://busybox.net, and my handler is busybox-1.19.3.tar.bz2

2.

Tar jxvf busybox-1.19.3.tar.bz2

CD busybox-1.19.3

Make menuconfig// Same as configuring Linux

Note that in busybox settings --> build optionsMake sure you select "build busybox as a static binary (no shared libs)" to compile busybox into a static library.!

Keep other default values, and then save

Make

Make install

The _ Install Folder is generated.

(For detailed configuration process, see my other article: http://blog.csdn.net/htttw/article/details/7215874)



Here, we can test it now, which is the same as the final result:

CD _ install

CD ..

Sudo chroot/_ install/bin/sh

In this way, we enter busybox ~~



The above is just preparation, and now it is fun:


The generated _ install directory contains only Bin, sbin, and other directories. To build a Linux file system, we must create other directories:

CD _ install

Mkdir proc sys etc Dev


Then create the console and null Device Files

CD Dev

Sudo mknod console C 5 1

Sudo mknod null C 1 3


Create related files under etc:

The INIT process is the first process created by the kernel. It will explain how to execute the commands in/etc/inittab and then execute init. d/RC Script file. In this script file, we need to mount the file system. The fstab file determines which file system to mount:


First, create the fstab file:

CD etc

Vim fstab, Enter the following content:


Then, create the RCS script file:

CD etc

Mkdir init. d

CD init. d

Vim RCS, Enter the following content:

Do not forget chmod + x RCS!


Then create the inittab file:

CD etc

Vim inittab, Enter the following content:



Then:

Switch to the _ install directory

Rm linuxrc

Run the following command:

Ln-SV bin/busybox Init ()



Finally, we made the _ install directory into our root file system:

Run the following command:

Find. | cpio -- quiet-h newc-o | gzip-9-N> ../initrd.gz ()



Finally, copy the generated initrd.gz to/boot.

Sudo CP initrd.gz/boot




So far, all the above three steps have been completed. Now we have to start our desktop busybox ~~


Restart,Enter "c" in the grub boot menu to enter the grub command mode.In the command form, run the following command:

Linux/boot/vmlinuz // specify the path of the kernel image (if there is no Linux Command, change it to kernel/boot/vmlinuz)

Initrd/boot/initrd.gz // specify the path of the file system

Boot // start boot



If everything is okay, you will go to the shell and wait for us to enter the command. This is our desktop busybox ~~


During the test, I found a directory in mkdir under _ install, and then entered busybox to find this directory. It means that I did enter busybox. In addition, I also deleted the generated Date Link under _ install/bin, and entered date in busybox to prompt that this command is not available, but entered busybox date to output the current time, it also means that I did enter busybox ~~

In addition, press CTRL + ALT + DEL to restart ~~


Done!



Refer:

Use busybox to create a small Linux system (only two files ):

Http://www.cnblogs.com/yangnas/archive/2010/04/26/1721607.html

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.