GRUB and Linux (version 2), grublinux

Source: Internet
Author: User

GRUB and Linux (version 2), grublinux
GRUB configuration Parsing

The configuration file is saved in/boot/grub. conf [/boot partition should be separated]

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

 

1. grub. conf file Analysis


Default # Start the system by default

Timeout # default wait time, in seconds

Splashimage # defines the GRUB startup background image

# (Hd0, 0) # specify the partition where/boot is located-> the first hard disk, the first partition

Hiddenmenu # Hide a menu

Title CentOS (2.6.32-358. el6.i686) # Name of the menu item, whose content can be modified

Root (hd0, 0) # defines the root device of GRUB, that is, the partition where the kernel is located, that is, the/boot Directory, which represents the partition where all startup devices are located.

Kernel/vmlinuz-2.6.32-358.el6.i686 ro root = UU... # define the location of the kernel, note: Here/does not represent the root partition, but indicates the/boot directory

Initrd/initramfs-2.6.32-358.el6.i686.img # load the image file. For more information, see <CentOS 6. X Startup Process> This blog

 

Single-user mode Application

Case: the root password is missing, and the system suffers an abnormal power failure.

1. When the system starts, Press Esc to enter the GRUB menu

GRUB 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 interface to cancel any modifications made to the current item.

 

2. Click a line in the kernel, press e to edit the startup level, and add the corresponding startup and running level at the end of the line, for example, 1 or s. Press enter and press B to enter the single-user mode.

Passwd root # change the root password

# Other settings can be made, such as file system repair after power failure.

 

Set GRUB Password

Step 1: Set and copy the ciphertext

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

 

Method 2. Use the md5crypt command on the GRUB interactive command line interface

 


Step 2: modify the configuration file/boot/grub. conf

Add: password -- md5 $1 $ EszU60 $ Mc2BwxeWUH/8q3iqbRknz0 # -- md5 indicates that it is encrypted with md5. [It is best to write the password in global mode, for example]

 

After restart


OK, all done!



GRUB repair

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

 

Solution:

Grub> cat/grub. conf # An error is found.

 

Manual guide to Linux:

Grub> root (hd0, 0)

Grub> kernel/vmlinuz-2.6.18-14 ro root = LABEL =/3 # if an error occurs at this time, pay attention to the prompt

Grub> initrd/initrd-2.6.18-14.img

Grub> boot # Use the Tab command to complete

 


Linux ultimate Repair Mode

Case: The/etc/inittab file is damaged, lost, or otherwise seriously damaged, causing the system to be unable to start

 

Repair Process

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

 

[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.


After entering the system as prompted:

4. Type chroot/mnt/sysimage # change the root Partition

5. Fix the problem according to the preceding prompt.

6. Repair completed, exit, reboot, and complete!

 

Note:

No matter how serious the Linux system is damaged, you can access the restoration environment of the CD Linux system to repair it. For example, if important files are deleted, the root and GRUB passwords are all forgotten, and almost all errors occur. At this time, although Linux is running on a CD, you can modify the data on the existing system.


How to fix Grub after windows is reinstalled on both linux and windows systems

Go to the next grldr and place it on the WINDOWS system disk.
Edit the BOOT file on the WINDOWS System Disk
Add c: \ grldr = "grub"
Start, go to grub
Input kernel (hd0, view by tap)/boot/v press TAP ro root = label =/vga = 78 splash = sient resume =/dev/sda3
Start linux
Input stup (hd0, 0)
Quit
Grub-install/dev/hda

How to fix the grub boot menu in linux?

Use the DOS boot disk to find the grub file.
Modify the grub. conf file. Where
"Default = n" (n is a number) is the default item selected in the grub boot menu. n starts from 0. 0 indicates the first item, 1 indicates the second item, and so on.
"Timeout = x" (x is a number) is the timeout time, and the Unit is wonderful. That is, after the boot menu is displayed, if you do not select within x seconds, grub starts the default item.
"Splashimage = xxxxxx", which is the background image of the boot menu. Ignore it first.
The following example describes other common items:
Title Red Hat 8.0
Root (hd1, 6)
Kernel/boot/vmlinuz-2.4.18-14 ro root =/dev/hdb7
Initrd/boot/initrd-2.4.18-14.img
"Red Hat 8.0" is the name displayed in the Startup Menu list.
Root (hdx, y) is used to specify the location of your boot partition. If you are not divided into boot partitions (in this example, boot partitions are not divided), you can point to the root partition, hdx is the hard disk of linux, hd0 is the first hard disk, hd1 is the second disk, and so on. Y is the partition location, starting from 0, that is, it is equal to the partition number minus one. For example, if the partition you want to point to is hdx7, then y is 6. If it is hdx1, y is 0. Note that there must be a space behind root.
Kernel/boot/vmlinuz-2.4.18-14, where "/boot/vmlinuz-2.4.18-14" is the path to the kernel you want to use, if you have compiled the core, change it to the path of your new kernel.
Ro does not need to worry about it. There is no mistake in writing it.
Root =/dev/hdxx specifies the root partition. In this example, It is hdb7, so root =/dev/hdb7
The initrd xxxxxxxxxxxxx line does not work either. Currently, I still don't know what it is used.
The above is linux, and the following is windows
Title windows 98
Rootnoverify (hd0, 0)
Chainloader + 1
Title xxxxxxx does not need to be explained.
Rootnoverify (hdx, y) is used to specify the partition where windows is located. x and y are the same as above. Note that there are spaces after rootnoverify.
Just copy chainloader + 1 and pay attention to spaces.

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.