Self-made small linux system

Source: Internet
Author: User
Tags network function
Self-made small linux system boot process boot self-check: Program postMBR boot: the mbr master boot records on the hard disk are 4-46 bytes (the first phase of the grub boot program to read the kernel), Partition Table (64 bytes), id indicates magic (2 bytes) GRUB menu: in the hard disk/boot/g... self-made small linux system

Linux boot process


Boot self-check: Program post

MBR boot: the mbr master boot records on the hard disk are 446 bytes (the first phase of the grub boot program reads the kernel), the partition table (64 bytes), and the id indicates magic (2 bytes)
 
GRUB Menu: in the hard disk,/boot/grub is the second stage of grub, boot to the hard disk, select the operating system to attach
 
Kernel loading: loads the kernel of the operating system and runs the init process.
 
Run the init process: an inittab is required.

Initialization script rc. sysinit for configuration files of various levels in Inittab

Rc. sysinit script: (initialization script)
(Function: Set the host name, enable the network function, set the clock, and set the keyboard)
 
Select a level and send a number to the rc script to enter/etc/rc0.d/*/etc/rc1.d/*/etc/rc2.d/*/etc/rc3.d/*/etc/rc4.d /* run the script in/etc/rc5.d/*/etc/rc6.d, kill startup with s in order with k.
 
Run the boot script/etc/rc. d/rc. local.

Start some terminals through the mingetty process.
 
Build a self-made linux small system through the host machine (I will use vm here)
* Create a new hard disk, attach the hard disk to the complete host machine, partition the hard disk, and sort out the corresponding kernel files and application files from the complete host machine, move the hard disk to a virtual machine without a hard disk for testing when all required preparations are complete.
* Create a partition for the new hard disk: create three primary partitions: sdb1: 100 m sdb2: 1g sdb3: 500 m
After the primary partition is created, change the sdb3 type to 82, that is, swap partition.
(The disk size of each partition is 20 GB)


* Format the disk mkfs-t ext3/dev/sdb1 mkfs-t ext3/dev/sdb2
/Dev/sdb1 as the boot partition/dev/sdb2 as the root partition
* Attach a disk


* Build MBR: build grub. The first stage is in the mbr, and the second stage is in the hard disk (automatically locate/mnt/boot, direct to/dev/sdb, rather than a partition)

* Automatically create grub after finding the boot directory

* Grub lacks a menu to create the grub. conf file (which contains the kernel file and some drivers and some default boot items for startup)
* Copy the kernel of the host machine before creating the menu.

* Because the host machine and the new hard disk are different, the information in the initrd-2.6.18-164.e15.img of the driver will also be different, so we should first change the information of this file.
* The init file in the expanded file will be executed during startup. you should change the internal information of the file.

* Because the swap partition in the new hard disk is not formatted and cannot be applied, comment out line 87 and repackage the file after the change, copy the packaged file to/mnt/boot /.

* After the previous stages, write a grub menu

* The next step is the init process: create the required directory under the new hard disk sysroot directory and copy the configuration content of each directory and the library to be used.

* Write inittab:
* Copy the line 21 si: sysinit:/etc/rc. d/rc. sysint in the host machine/etc/inittab to/mnt/sysroot/etc/inittab.
* No rc. Sysinit exists in the new rc. d, so we need to create it ourselves. rc. sysinit is a shell script.
* To run the shell file, add the bash configuration.

* To facilitate adding the database to each command file, write a cp. sh

After importing the basic command link library, you can enter the system for simple operations.


* Implement the init 0 init 6 application by modifying the content in the/mnt/sysroot/etc/inittab file






* Init 6


* Add the background image/mnt/boot/grub. conf on the startup interface.
Image size: 640*480 14-digit format xmp.gz
Install yum source modify/etc/yum. repos. d/rhel-debuginfo.repo

 
After the installation is complete, run gimp on the GUI to modify the image.


* Added the network function.
Module:

* Eth0 is just an alias and is actually called pcnet.
* Pcnet32
* Mii is dependent on pcnet32
* Modinfo: view the module details
* Uninstall the Rmmod module.
* Modprobe name and module (the complete path must be added for inmod)
* Create a module file in the new hard disk and copy the network module.
* Since pcnet32 depends on mii, you need to copy the mii.
* Call module
 
* Copy the pcnet32.ko and mii. Ko modules to be used, and edit rc. sysinit to call the module without the Nic address.
* Network functions have been implemented
* Implement ftp: * Install the ftp service
* Add the vsftpd command

* Copy the files in vsftpd of the host machine to the corresponding location of the new hard disk, and create ftp/pub under the corresponding var directory.

* After ftp is installed, an ftp user is formed to log on to ftp. you need to copy the ftp account.

* A nsswhich mechanism is required for login name and id, and the nesswitch. conf file is required for the mechanism. The conf file depends on several link libraries. here we only copy the link libraries

* Ftp requires a log directory, so either log creation or disabling
Go to/mnt/sysroot/etc/vsftd/vsftpd. conf and disable the sentence related to log 39 and log 56.
* Disable the userlist line. * manually create a/mnt/sysroot/etc/usr/share/empty directory. * implement ftp

 
Simple functions can be implemented. if you need more functions, you have to study them slowly !!!
 
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: 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.