DIY Centos Lite version

Source: Internet
Author: User

We all know that the linux system has extremely powerful functions, but sometimes the functions are not necessarily what we want, in some cases, we want a simple system that consumes less resources and runs some basic functions and commands. At this time, we need to manually create a streamlined linux system.

As shown in: We have A host to be installed (host B) and A fully functional host (host A). First, we need to remove the hard disk of the host to be installed and put it on host, then, host A puts the kernel, driver, process, library file, and other necessary system items on an empty hard disk to make the system hard disk, finally, put the hard disk on host B and start it directly.

Next we will simulate this experiment on a virtual machine:

1. Create an empty hard disk on the host

2. Open host A for hard disk partitioning

(1) Use fdisk/dev/adb to partition an empty hard disk. The partition size is 100 MB for the primary partition (as the boot partition) and 2 for the primary partition (as the root partition) 1G (root partition cannot be too small) and primary partition 3 (as a virtual partition) 500 M

(2) identify partitions

(3) format the first and second partitions respectively.

(4) create two mount points and mount the first two partitions of the new hard disk to the two mount points respectively.

3. Create the first and second phases of grub boot program boot for the new Hard Disk

(1) Create the second phase of grub boot program boot, as shown below. The DIR parameter is either/mnt/dev/adb

As shown in, the grub menu is generated under the boot directory and displayed in the grub directory. there are no other description files and description files in the conf configuration file. here we need to note that the configuration file needs to be created manually.

(2) create the first stage of grub boot

Enter grub, and then create

4. Copy the kernel

5. Copy the driver

(1) create A temporary workspace in the home directory, and extract the driver of Host A to this directory.

Some important directories or files under the temp directory, such as bin (place library files) and init (information about init program calls ). Next let's take a look at the init file. We need to make corresponding adjustments according to the actual situation.

(2) repackage the files in the temp directory into a file and deliver them to the boot partition of the new hard disk.

6. Switch to the/mnt/boot/grub directory and create the grub. conf file. The file content is as follows:

7. Create a file system under the root partition of the new hard disk (the necessary directory is built below, which can be set according to the actual situation)

8. Copy the executable program and the library files it depends on

(1) Here we first copy the init executable program and the dependent Library

First, check the specific location of the executable file and then copy it.

View the library file and copy it.

As shown in, all directories with/lib must be copied.

(2) Copy bash, ls, and cat respectively based on the above method.

9. Configure the inittab File

(1) switch to the/mnt/sysroot/etc directory and create an inittab file.

(2) Open the/etc/inittab File

(3) because too many features are not required, in the inittab file, we only leave 0, 6 levels and initialized files, that is, lines 21, 23, and 29.

10. Configure the initialization file rc. sysinit in the/mnt/sysroot/rc. d directory.

11. Run the sync command multiple times to synchronize all the parameters to the new disk to be written.

12. Add a VM (host B) and remove the hard disk from the VM. Add the hard disk we just created to this host.

13. Pause host A, start host B, and enter the system. We try to complete several executable programs added. ls can be done, but shutdown and restart commands cannot.

(1) Check the inittab file in the/mnt/sysroot/etc directory. If you want to enter level 0, it depends on the script named rc, the rc Script requires the corresponding commands, and the corresponding commands need the support of the corresponding library files. It is too difficult for us to copy these copies. What should we do? Let's explain them here.

(2) As shown in, run the sysshutdown and sysreboot scripts respectively for shutdown and restart.

Create the shutdown script and restart script respectively, and copy the executable program and library files to the corresponding directory.

Change the script permission to executable.

(3) After synchronization, pause host A and host B, and then shut down and restart the command.

14. Of course, we also want to have the Host Name of the machine and basic network functions. Here we will implement them one by one.

(1) Disable host B and start host. Copy the executable programs named ping, hostonly, and ifconfig and the dependent library files to the corresponding directory.

(2) edit the Initialization Configuration File/mnt/sysroot/etc/rc. d/rc. sysinit

As shown in, to make the script take effect, we also need A file named network. We copy the file on host A to host B's hard disk, and then make changes.

(3) pause host A after synchronization, enable host B, and test it.

15. To implement network functions, Kernel support is required first, but only the most common drivers are in the kernel, while others are made into kernel modules. Of course, the NIC is no exception.

(1) view Nic Parameters

(2) view PCnet modules

(3) view the details of the PCnet module and mii module respectively, from which you can see the module path

(4) create a directory for storing the driver on the hard disk of host B, and copy the driver to it.

(5) driver loading requires the support of corresponding tools. Here we use insmod to copy the executable programs and library files to the corresponding directory of the new hard disk.

(6) to reference the corresponding module during initialization, edit the initialization file/mnt/sysroot/etc/rc. d/rc. sysinit.

(7) after synchronization, pause host A and enable host B for verification.

Now, a simple linux system has been created successfully. Of course, you can add applications and modify scripts as needed.

This article is from the "xiaoxiaozhou" blog, please be sure to keep this source

Related Article

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: 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.