Self-made small Linux under the CentOS 6 system

Source: Internet
Author: User
Tags parent directory

Build a small Linux process based on CentOS 6:

First we need to know the starting process of the CentOS 6 system for post (power On Self Test)-->bios (System Select Boot device sequencing, the default order is CD, USB flash drive, hard disk)-->bootloader (System boot program, using GRUB loader)-- >kernel (Initialize kernel)-->/sbin/init (run init program).

First, a new hard drive is required to assemble a startup program that starts the Linux system and its configuration files, including the Grub program and its library files, the copy kernel files and the RAMDisk files, the/bin/bash, and the library files.

The next step is to detail the implementation of the individual steps:

Creating a new hard drive in a CentOS 6 system that can be used does not need to be too large, 20GB, it is recommended to add the hard drive at the virtual machine to avoid the operation of the Echo '---' >/sys/class/scsi_host/host2/scan command during the hot swap process. Then for the newly added hard disk partition (sd[a-z]{1,2,3}) and create the file system First partition mount/boot to boot the system, the second partition is used as the swap partition, the third partition is rooted, so the first third partition is mounted on/mnt/boot and/mnt/sysroot.

After installing the Ygrub program, use Grub-install--root-directory=/mnt (note where the location is/mnt because it needs to be on the Boot parent directory)/dev/sd*.

Next, copy the kernel file and the RAMDisk file to the boot partition/mnt/boot of the target system and create the directory hierarchy in/mnt/sysroot {bin,root,dev,lib,lib64,var,sur,proc,sys,mnt , Tmp,etc,sbin}. Then copy the/bin/bash and its shared library files to the corresponding directory under/mnt/sysroot (see the Shared library available commands LDd view, a total of four library files). Finally, the Sync command is executed several times to ensure that the in-memory cache or buffered data is saved to disk. At this time our homemade Linux system is ready.

Next, create a new virtual machine to use the hard disk you just operated as the hard disk of the new virtual machine (the purpose is to choose to start the hard disk when the system chooses to boot the device), after you have prepared the new virtual machine, suspend the host system (if it is not suspended, a hardware resource conflict is displayed when you start the new VM, and you ), start the new virtual machine, enter the GRUB command line interface, and type the command:

Root (hd0,0): Specifies the disk, specifying the partition as the root device of the GRUB program

Kernel/vmlinz ro Root=/dev/sda3 selinux=0 init=/bin/bash single: Sets the absolute path and kernel parameters of the kernel file

Initrd/initramfs.img:ramdisk file path

Boot: Boot

At this time we made the small liunx has run, but the most basic Linux system, many commands do not need to install themselves.


Self-made small Linux under the CentOS 6 system

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.