Linux Startup troubleshooting

Source: Internet
Author: User

Not only does linux support other operating systems, but we need to understand the system structure and the files and programs involved in the startup process if we want to troubleshoot system startup faults.

1. Linux operating system composition (roughly divided into three levels ):



Tasks that can be completed by the kernel: memory management, scheduling tasks, driver hardware, network functions, security, and file systems

Linux Startup Process:

Power-on --> cmos --> post (power-on Self-Test) --> grub

2. The system boot guide process (for example ):



If the system uses hard disk boot, the first sector of each hard disk's front-end is MBR (512 Byte). MBR is divided into three parts: the first 446Byte is bootloader (Boot Loader ), 64 Byte partition table in the middle, the last 2 Byte magic

The bootloader in MBR guides the first stage of system startup, and the grub menu guides the second stage of system startup (grub configuration ).

Grub menu Configuration:


When the second phase of boot is complete, the grub menu will prompt us to select the operating system,


After selecting the operating system, the system will load the kernel,


After the kernel is loaded, it starts to run the first process-init in the system. in linux, init is the prerequisite for all processes.


When the init process is run, the/etc/inittab configuration file is called to specify the default system entry level. The system calls/etc/rc at any level. d/rc. the sysinit script initializes the system. When the system enters a certain level, it executes/etc/rc. d/rc system will enter the corresponding directory {etc/rc0.d/etc/rc1.d/etc/rc2.d/etc/rc3.d/etc/rc4.d/etc/rc5.d/etc/rc6.d /}, at the end of the execution, the system will execute/etc/rc. d/rc. local (also known as the boot script), and finally log on based on the provided terminal.

So far, the entire process of system boot is complete.


Troubleshooting: faults in linux systems generally occur in the first or second phases of system guidance. The cause of the first phase of the fault is that the 446Byte bootloader In the MBR has a problem. If there is a problem, the grub menu cannot be seen. In the second stage, there is a problem with the configuration file and description file of the grub menu, there is no way to select the operating system.


Next we will simulate the first-stage fault:

First, use the dd if =/dev/zero of =/dev/sda bs = 446 count = 1 command to overwrite the first 446 bytes of the hard disk and overwrite the 446-byte bootloader In the MBR.


After the reboot, the system boot failed.


In this case, we can use the boot disc to boot the system into the emergency mode (rescue)


After entering the emergency mode, the following screen appears and select the appropriate action:

Click OK. The following page is displayed:


At this point, we need to re-build the first stage, first execute grub to enter the Mode


Then, use root (hd0, 0) to specify the boot partition of a disk, and then use setup (hd0) to reconstruct the first phase of the hard disk.


Then, use the crtl + c key combination to exit grub mode and execute exit twice in a row. The system will automatically guide you. If the wizard succeeds, the following logon interface will appear.


Fault Simulation in the second stage:

In the second stage, many configuration and description files are generated in/boot/grub/. What happens if the grub. conf file under/boot/grub/is lost? Now we will delete the grub. conf file in this directory and restart the system.

The following page is displayed:

The grub mode indicates that the first stage of guidance is normal and the problem occurs in the second stage.


Now, we need to use commands to guide the system startup:


Then, use boot to start the boot, and the following logon interface will appear:


Go to the system and use grub-install -- root-directory = // dev/sda to recreate the second stage.


Because the files related to the second stage are all in the/boot/grub/directory, we enter this directory to check whether the files are missing.


If the file referred to by the link does not exist, we need to create the file (grub. conf) as follows:


Then restart. If the following interface Appears normally, the boot is normal:


Now I want to simulate a more serious second-stage boot. If all the files under my/boot/grub/are lost, what will happen now? What should we do?

First, I delete all the files in the/boot/grub/directory and restart the system to display the following interface:


In this case, we need to enter the cmos mode and change the boot item to the CD boot:


Press F10 to save the changes. The following page is displayed:


Then, go to rescue emergency mode and perform the following operations:

Click OK. The following page is displayed:


Then, use chroot to change the root directory to/mnt/sysimage, use ls to view the content in the/boot/grub/directory, and then use grub-install to recreate the second stage:


Check the/boot/grub/directory again:


At this time, because we have set the CD boot in cmos, we have to remove the CD if we want to use the hard disk boot. Here we take out the CD and execute exit twice in a row. The system will automatically boot, the following page is displayed:

The grub mode indicates that the first stage of guidance is normal and the problem occurs in the second stage.

Now, we need to use commands to guide the system startup:


Then, use boot to start the boot, and the following logon interface will appear:


Go to the system and use grub-install -- root-directory = // dev/sda to recreate the second stage.


Because the files related to the second stage are all in the/boot/grub/directory, we enter this directory to check whether the files are missing.


If the file referred to by the link does not exist, we need to create the file (grub. conf) as follows:


Then restart. If the following interface Appears normally, the boot is normal:


This article from the "night wind" blog, please be sure to keep this source http://jiangkun08.blog.51cto.com/6266992/1262482


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.