Build a minimum Linux operating system from the source code

Source: Internet
Author: User

The system we want to build here is very small and is not intended to be used as a work product. If you want to build a practical system From the ground up, see Linux From Scratch HOWTO in the Linux karate practice guide by Gerard Beekmans ).

What you need

First, we need to install a Linux distribution kit, such as a red hat (RedHat), to a partition, and then use it to create a new Linux system on another partition. I call the system we want to build a target system and call the system we use to build a new system the source system) the system is confused with the source code we use at the same time.

Therefore, you need a machine with two independent partitions. if possible, try to use a machine with no important information in it to avoid data damage. You can use an existing Linux system to make important information in the machine to avoid data damage. you can use an existing Linux system as the source system, but I do not recommend this method. If you accidentally omit some parameters of the commands we created, you may accidentally install unnecessary things on this system, which may lead to incompatibility and conflict.

For the old PC hardware, most 486 machines or earlier models, the BIOS has some extremely annoying restrictions. they cannot read the space of the hard disk that exceeds the first 512 MB. of course, this is not a big problem for Linux, because as long as Linux can boot, it will use Linux's own disk IO, skipping the BIOS call. however, to enable these old machines to boot Linux, the Linux kernel must be stored at a location before the first 512 MB of the hard disk. if you have such an old

Type machine, you have to prepare a separate hard disk partition that is completely in the range of the first 512 MB, and mount it as/boot, other partitions can be in any location, it can be processed at will without worrying about the locations on the hard disk ..

The last time I built this system, the source system I used was Red Hat 6.1 (RedHat 6.1). I installed the basic system and attached the following software packages:

* Cpp (C compiler)
* Egcs (enhanced C compiler)
* Egcs-c (enhanced C language compiler)
* Patch)
* Make (compile the batch Interpreter)
* Dev86 (device package) * dev86 (device package)
* Ncurses-devel (ncurses Library)
* Glibc-devel (glibc Library)
* Kernel-headers (kernel source code header package)

I also installed the X Window System and the Mozilla web browser to read the document more easily. In fact, these two things are not necessary. At the time of my completion, the source system used approximately 350 MB of disk space (which seems to be a little more, but I am still wondering why ).

The target system occupied 650 MB of disk space at the time of completion, but this value contains all the source code and files created in the middle. if the space is relatively tight, you should execute make clean to clear the temporary files after each software package is created. Of course, I was a little surprised.

Finally, you have prepared the source code package we want to use to build the system. these are the software packages I have discussed in this article. these software packages can be found in the source code disk or on the Internet. I will provide the address of the US site and the image site in Australia.

* MAKEDEV (device generator package)

Site: ftp://tsx-11.mit.edu/pub/linux/sources/sbin

Another US site: ftp://sunsite.unc.edu/pub/Linux/system/admin

* Lilo (Linux boot package)

Site: ftp://lrcftp.epfl.ch/pub/linux/local/lilo/

Ftp://mirror.aarnet.edu.au/pub/linux/metalab/system/boot/lilo, Australia

* The Linux Kernel package (Kernel) uses the image site listed on the home page instead of the U.S. site for download, because these sites are usually overloaded.

Site: ftp://ftp.kernel.org/pub/linux/kernel

Site: ftp://kernel.mirror.aarnet.edu.au/pub/linux/kernel/

* The GNU libc library package and the liuxthreads thread-attached library can be downloaded:

Site: ftp://ftp.gnu.org/pub/gnu/glibc

Site: ftp://mirror.aarnet.edu.au/pub/gnu/glibc

* For the GNU libc additional library package, you may also need the linuxthreads thread additional library and libcrypt encrypted additional library. If libcrypt is not found on that site, it is because of the United States export legal restrictions, then you can get the libcrypt encryption additional library from here. Generally, the threads thread appending Library and the libc library are placed in the same place.

Libcrypt encryption additional library: ftp://ftp.gwdg.de/pub/linux/glibc

* GNU ncurses

Site: ftp://ftp.gnu.org/gnu/ncurses

Site: ftp://mirror.aarnet.edu.au/pub/gnu/ncurses

* SysVinit (initialize the script package)

Site: ftp://sunsite.unc.edu/pub/Linux/system/daemons/init

Ftp://mirror.aarnet.edu.au/pub/linux/metalab/system/daemons/init, Australia

* GNU Bash (command interpreter package)

Site: ftp://ftp.gnu.org/gnu/bash

Site: ftp://mirror.aarnet.edu.au/pub/gnu/bash

* GNU sh-utils (command interpreter Toolkit)

Site: ftp://ftp.gnu.org/gnu/sh-utils

Site: ftp://mirror.aarnet.edu.au/pub/gnu/sh-utils

* Util-linux (commonly used Linux Tool Kit) this software package contains agetty and login.

Another site: ftp://ftp.win.tue.nl/pub/linux/utils/util-linux/

Site: ftp://mirror.aarnet.edu.au/pub/linux/metalab/system/misc

To sum up, all you need is:

* A machine with two separate 400 m and 700 m independent partitions may need less.

* A Linux distribution kit (such as a RedHat disc) and installation method (such as an optical drive)

* The tar package of the source code listed above.

I assume that you can install the source system on your own without the help of me. From here on, I assume that the source system has been installed.

The first milestone of this small project is to make the kernel start up and end up, because it does not find the init initialization program. That is to say, we have to install a kernel and install lilo. To install lilo smoothly, we need to use the device files on the/dev directory of the target system. Lilo needs them to implement the underlying required disk access to write to the boot sector. MAKEDEV is the script program used to create these device files (you can copy the files from the source system, but this is a result of cheating ). But heaviest

All we need is a file system to place all these things.

Related Articles]

  • Open-source space: Cross-Compiling of Linux kernel (2.6.22.6)
  • Compile PHP into Apache static Kernel on Linux
  • Kernel Overview (Solaris kernel structure)

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.