Linux System cropping notes

Source: Internet
Author: User

1. What is cut?

The main purpose of this article is to give the author and readers a deeper understanding of how the Linux system works, the general content is to take Linux apart from the components to assemble, and then complete a micro Linux system. Let's do it now. Please advise me where the writing is not good.

2. Principle

As we all know, the operating system start-up process is (mainly Linux):P Ost->bios->mbr-kernel-->initrd-->sbin/init,

Post,bios is not our tube, so here we start from the MBR, Linux system boot is mainly used grub this software, Grub boot system, and then start the kernel, the kernel calls INITRD to achieve the most basic operating system,

3. Next, the actual operation (all operations are implemented on the virtual machine)

3-1. First we have to create a new disk to store key programs such as GRUB and kernel (adding new disks directly to the virtual machine)

The author here has been added, do not demonstrate the process of adding, the author of the site divided into two areas, respectively, 100M main disk, and 1G of the main disk, the name of

/DEV/SDG1 and/DEV/SDG2, first create two folders under the/MNT directory:

3-2. Mount/dev/sdg1 to/mnt/boot, Mount/dev/sdg2 to/mnt/sysroot

3-3. You know, when starting the system, in addition to the hardware, the first is to have a boot program, so we install the bootloader to/mnt/boot

Use command: GRUB-INSTALL–-ROOT-DIRECTORY=/MNT/DEV/SDG1

3-4. With the boot process need to have our kernel, no kernel how to start Ah, but the boot of the kernel is also dependent on INITRD (CentOS6), so we have to copy the two files in the past, using the command:

Cp/boot/vmlinuz-2.6.32-358.el6.x86_64/mnt/boot/vmlunuz

Cp/boot/initramfs-2.6.32-358.el6.x86_64.img/mnt/boot/initramfs.img

3-5. The prototype of a simple operating system is done, but the OS operation relies on the shell, so we have to copy the Bash shell into the/dev/sgd2 directory, so we have to copy the/bin/bash and bash-dependent libraries in the past and use LDD ' Which bash ' see what are the library files that bash relies on, so I have a simple script that I don't copy manually

3-6. Next to configure the grub file, otherwise the system how to find your hardware, so next under/mnt/boot/grub to create a grub.conf configuration file, the content is as follows

3-7. Next, under the root directory, which is mounted under/mnt/sysroot, create a proc folder. You can think of this new hard drive as a startup disk for other systems, let's try it, create a new empty virtual machine without teaching it. And then add our disk, It's ready to boot.

3-8. Let's add a command to him, but it's very simple, just copy the command's directory and command all dependent libraries to the/mnt/sysroot directory. Here I use the script to complete, do not demonstrate, I copied some common commands such as: LS

3-9. The author has created several directories for this small system, of course, is added on the original host, is not more and more like a system

3-10. The system to here is almost, but we have to repair, everyone in 3-6 can see, our init=/bin/bash, this time will have classmates asked, there is no mistake, Linux systematization initialization is not all call/sbin/init, how do you call the Bin/bash, yes, in fact, what is pointed here, we now re-let him point to/sbin/init Bar, first in/mnt/sysroot under the creation of an init file, in which the following characters are added: do remember to give/sbin/init a quick Execute the permissions and change the/mnt/boot/grub/grub.conf to Init=/sbin/init

3-11. For example, execution succeeded.

3-12. Finally, we should add a network module to him, oh oh, in 3-9 steps we find the disk is still read-only, so we have to re-mount it to read and write, such as:

3-13. Finally can add the network module, Linux system is a single core, but the support of modular, so we have to add a network module for him, we need to first copy the original system of the network module to our micro-system, the Linux module is/lib/module/[ Kernel version number], we first use LSPCI or lsmod to view the network module information, and then copy to the Micro system, as follows:

Finally install the network module, using the command INSMOD [path]

OK, the whole system is installed!

Linux System cropping notes

Linux System cropping notes

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.