Linux study NOTE _ 5_Linux boot process parsing _ 3_GRUB configuration and Linux system repair

Source: Internet
Author: User
1. the GRUB configuration file is saved in the bootgrubgrubconf soft link and saved in the etcgrubconf1 and grubconf files. default defines the default startup system.

1. GRUB configuration

The configuration file is saved in/boot/grub. conf.

The soft link is saved in/etc/grub. conf.

1. grub. conf file analysis

Default defines the default startup system.

[It is impossible to install multiple systems in real server applications]

Timeout defines the default wait time

Splashimage defines the GRUB startup background image

Hiddenmenu hides the menu. if it is deleted, the automatic reciprocal setting is not used.

(Hd0, 0) --/partition of the boot --/

Hda sda // indicates the hard disk

Hd0 sd0 // hard disk representation in GRUB

, 0 // indicates the first partition in the hard disk

, 1

, 2

Title CentOS (...) // Define the name of the menu item ,... Content can be changed

Root (hd0, 0) // root defines the root device of GRUB, that is, the partition where the kernel is located.

Kernel defines the location of the kernel file // Note: The/here does not represent a root partition, but a table

The initrd command loads the image file // Display/boot directory

2. instance analysis

Example 1: enter the single-user mode

(1) press Esc to enter the GRUB operation interface

Function key:

E: edit the current menu item // edit

C: enter the command line mode of GRUB // command

B: start the current menu item // boot

D: delete the current row // delete

Esc: return to the GRUB startup menu to cancel any modifications made to the current single item.

(2) click a line in the kernel and press e to edit the startup level.

(3) add the corresponding startup and running levels at the end of the line, such as: 1

(4) press enter to enter single-user mode.

(5) passwd root can change the root password after continuous confirmation

(6) You can also make other settings, such as file system repair after an exception or power failure.

Example 2: set a password for GRUB

(1) generate the ciphertext: [grub needs to be installed]

1. use the grub-md5-crypt command that comes with GRUB

# Grub-md5-crypt

Password:

$1 $ EszU60 $ Mc2BwxeWUH/8q3iqbRknz0

2. use the md5crypt command on the GRUB interactive command line interface

# Grub

Grub> md5crypt

Password:

$1 $ EszU60 $ Mc2BwxeWUH/8q3iqbRknz0

[The same plaintext password, the MD5 ciphertext password obtained each time it is encrypted, is also different !]

(2) modify the configuration file

Add: password -- md5 $1 $ EszU60 $ Mc2BwxeWUH/8q3iqbRknz0

-- Md5 indicates that md5 encryption is used.

[Add it to the global variable! Such as under hiddenmenu .]

3. GRUB repair

After the instance is started, go to the grub interface, but there is no menu. there is only one grub> prompt. solution:

Grub> cat/grub. conf (View parameters)

Grub> root (hd0, 6)

Grub> kernel (hd0, 6)/vmlinuz-2.6.18-14 ro root = LABEL =/

Grub> initrd (hd0, 6)/initrd-2.6.18-14.img

Grub> boot

[You can use the Tab key to complete the command]

4. Linux system repair mode

Online scenario: the/etc/inittab file is damaged or deleted, but first, the/etc/inittab file has been replaced.

Repair process

1. Place the installation disk in the optical drive, restart the machine, and set the system as the optical drive boot in the BIOS.

[If it is in a virtual machine, first confirm that the CD is loaded with the Linux installation image]

[F2 enters BIOS]

[2. after the installation interface is displayed, Press [F5] to enter the linuxrescue mode description]

2. input at the boot prompt:

Linux rescue

3. press enter to enter repair mode.

[In this case, no matter how serious the Linux system is damaged, you can go to the restoration environment of the CD Linux system to fix it. for example, if an important file is deleted, the root and GRUB passwords are all forgotten ...]

[In this case, Linux is running on the CD, but data on the existing system can be modified]

4. type chroot/mnt/sysimage // change the root partition

5. fix the problem according to the preceding prompt.

[This changes the data on the local system !]

6. the repair is complete. exit and reboot!

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.