Article Title: Build a minimal Linux system from the source code. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The following describes how to create a minimal Linux system from the source code. it was once part of "starting From power-on to Bash Prompt (From PowerUp to Bash Prompt. but I separate them to make them shorter and more centralized. 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 create a practical system From Scratch, see the Linux karate practice guide (Linux From Scratch HOWTO) written by Gerard Beekmans ).
_________________________________________________________________
1. The conditions you need
First, we need to install a Linux distribution kit such as 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 as the source system ). don't confuse the source system 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 without any important information to avoid data loss. you can use an existing Linux system as an important data machine to avoid data loss. 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 machine, you have to prepare an independent hard disk partition that is completely in the range of the first 512 MB and mount it as/boot. other partitions can be processed at any location without worrying about the location of 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 US site and the address of 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/
Australia: ftp://mirror.aarnet.edu.au/pub/linux/metalab/system/boot/lilo
* The Linux Kernel package (Kernel) uses the image site listed on the home page instead of the United States.
Site 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
* GNU libc additional library package you may also need linuxthreads thread additional library and libcrypt Encryption
Additional library. If libcrypt is not found on that site, it is caused by US export laws.
For the reason, you can obtain the libcrypt encryption additional library from here. Usually linuxthreads
The thread-attached 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
Australia:
Ftp://mirror.aarnet.edu.au/pub/linux/metalab/system/daemons/init
* GNU Bash (command interpreter package)
Site: ftp://ftp.gnu.org/gnu/bash
Australia 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 in the/dev directory on the target system. lilo needs them to implement the underlying required disk access to write 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 the most important thing is that we need a file system to place all these things.
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