About Grub Configuration

Source: Internet
Author: User
Article Title: about Grub configuration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   1 GRUB configuration file
The partitions in this example are as follows:
Hda 15G
Hda1 8G/red hat LINUX8.0
Hda5 7G/home
Hdc 20G
Hdc1 6.4G WinXP
Hdc5 6.4G
Hdc6 6.4G
Hdc7 6.4G
# Fdisk-l
# Disk/dev/hdc: 255 heads, 63 sectors, 2434 cylinders
Units = cylinders of 16065*512 bytes
  
Device Boot Start End Blocks Id System
/Dev/hdc1*1 894 7181023 + B Win95 FAT32
/Dev/hdc2 895 2434 12370050 f Win95 Extd (LBA)
/Dev/hdc5 895 1787 7172991 B Win95 FAT32
/Dev/hdc6 1788 2434 5196996 B Win95 FAT32
  
Disk/dev/hda: 255 heads, 63 sectors, 1867 cylinders.
Units = cylinders of 16065*512 bytes
  
Device Boot Start End Blocks Id System
/Dev/hda1*1 1020 8193118 + 83 Linux
/Dev/hda2 1021 1802 6281415 83 Linux
/Dev/hda3 1803 1867 522112 + 82 Linux swap
  
Grub. conf, which is located in;/boot/grub. conf
# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a/boot partition. This means that
# All kernel and initrd paths are relative to/, eg.
# Root (hd0, 0)
# Kernel/boot/vmlinuz-version ro root =/dev/hda1
# Initrd/boot/initrd-version.img
# Boot =/dev/hda
Default = 0
Timeout = 3
Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz
Title Red Hat Linux (2.4.18-14)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.4.18-14 ro root = LABEL =/
Initrd/boot/initrd-2.4.18-14.img
Title Microsoft Windows XP
Map (hd0) (hd1)
Map (hd1) (hd0)
Root (hd1, 0)
Chainloader (hd1, 0) + 1
Makeactive
Boot
  
   2. interpret the grub. conf file
In the future, let's look at the statements in the grub. conf file. (Note:...) What we interpret is what we interpret.
# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a/boot partition. This means that
# All kernel and initrd paths are relative to/, eg.
# Root (hd0, 0)
# Kernel/boot/vmlinuz-version ro root =/dev/hda1
# Initrd/boot/initrd-version.img
# Boot =/dev/hda (Note: The above lines starting with the symbol well "#" are commented out without any significance)
Default = 0 (Note: The default Operating System is controlled by default. Add a number n after default, indicating that it is n + 1. In GRUB, the count starts from 0, the first hard disk is hd0, and the first soft drive is fd0. Therefore, default 0 indicates that the default Operating System is Red Hat Linux (2.4.18-14). If you change it to 1, it is WinXP)
Timeout = 3 (Note: timeout indicates the default waiting time, which is 3 seconds. If you have not selected the OS for more than 3 seconds, the system will automatically select the default OS. Of course, you can change it to any time you like)
Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz (Note: Specify the position of the image file splash.xpm.gz on the machine, or splash/boot/logo/800x600x8. img)
Title Red Hat Linux (2.4.18-14) (Note: The menu item of Red Hat Linux)
Root (hd0, 0) (Note: It indicates the first partition of the first hard disk. The root here is not the same as the root in the system! Details are as follows)
Kernel/boot/vmlinuz-2.4.18-14 ro root = LABEL =/(Note: specify the location of the kernel, as described below)
Initrd/boot/initrd-2.4.18-14.img (Note: initialization)
Title Microsoft Windows XP (Note: The menu item of Microsoft Windows XP)
Map (hd0) (hd1) (Note: map is a command, details are as follows)
Map (hd1) (hd0)
Root (hd1, 0) (Note: This refers to the first partition of the second hard disk (from the hard disk)
Chainloader (hd1, 0) + 1 (Note: The chain loader loads data from one slice and then delivers the boot permission to it. Details are as follows)
Makeactive
Boot
  
(Note: In Linux, when talking about the "root" file system, it usually refers to the primary Linux partition. However, GRUB has its own root partition definition. The root partition of GRUB is the partition that saves the Linux kernel. This may be your official root file system, or not. We are talking about GRUB. You need to specify the root partition of GRUB. When you enter the root partition, GRUB will install the partition into the read-only type, so that you can install the Linux kernel from the partition. One of GRUB's "cool" features is that it can read local FAT, FFS, minix, ext2, and ReiserFS partitions. so far, you may be confused, because the hard disk/partition naming conventions used by GRUB are different from those used by Linux. In Linux, the fifth partition of the first hard disk is called "hda5 ". GRUB calls this partition "(hd0, 4 )". GRUB calculates the hard disk and partition numbers from 0. In addition, the hard disk and partition are separated by commas, and the entire expression is enclosed in brackets. Now, if you want to boot the Linux hard drive hda5, enter "root (hd0, 4 )".
Knowing where the kernel is and specifying which file is the kernel file is the work of the kernel.
Kernel/boot/vmlinuz-2.4.18-14 ro root = LABEL =/NOTE/boot/vmlinuz-2.4.18-14 is the kernel to load. The following are the parameters passed to the kernel. Root = LABEL =/is the hard disk partition representation of linux. ro indicates readonly. Initrd is used to initialize a linux image and set relevant parameters.
Command map: When you have two hard disks, an operating system that cannot be started from the second disk, such as Windows XP, you can use the map command. you can map hd0 to hd1 and hd1 to hd0. In other words, you can switch two hard disks and start the required operating system. The command format is as follows:
Grub> map (hd0) (hd1)
Grub> map (hd1) (hd0)
GRUB uses the chainloader ). The chain loader loads winxp's own Boot Loader from the boot records of the partition (hd1, 0) and then directs it. This is why this technology is called chain loading-It creates a chain from the boot loader to another. This chain mount technology can be used to guide any version of DOS or Windows.
The GRUB configuration file should be as simple as this. If you want to be more personalized, add "color light-gray/blue" to the default statement. When GRUB is started next time, let's take a look at the changes and try "color light-blue/red". Are you surprised? Fun! )
  
  
   3 configure grub
When grub is started, a configuration file named menu. lst is located in/boot/grub/. If this file cannot be found, the configuration file directly enters the command line mode without entering the menu mode.
Now, let's take a look at how to enter various operating systems after startup and how to create the menu. conf file. We start with the startup process supported by GRUB. There are two methods to complete the startup process:
· A. Local startup by calling the kernel
· B. Continuous start or transfer control to another pilot
Startup Process of Mode
1. Configure the device or tell GRUB your root file system.
2. Tell GRUB the location of your kernel image and then send the parameter to the kernel.
3. Restart and try again.
To start Linux, put the kernel in the/boot/directory with the bzImage file name.
/Dev/hda1, or (hd0, 0) in GRUB ). The startup process is as follows:
1. root (hd0, 0) [This sets the root partition]
2. kernel/boot/bzImage root =/dev/hda1 [This sets the kernel]
B-mode startup process (this mode assumes that another startup manager is installed in the current partition, such as LILO
Or NTLDR ):
1. Set the root partition but do not install it
2. Activate this partition
3. Configure the first sector of the partition to be started
4. Restart and check the effect.
We are trying to start windows Installed in/dev/hdc1 or (hd1, 0. Start windows as follows:
1. rootnoverify (hd1, 0)
2. makeactive
3. chainloader + 1 [+ 1 sets the first sector of the current root
Partition]
4. boot [transfers the control and quits GRUB]
Menu. conf file: it is used to create a menu when multiple operating systems are started. It is not difficult to create menu. conf. It uses simple English, as you can see in this section.
All menu items start with "title TITLENAME" without commas. You can set
TITLENAME.
To set the Linux Startup menu, follow these steps:
1. Set the title
2. Set the root Partition
3. Set Kernel Parameters
4. Start
A menu example:
Title Red Hat Linux (2.4.18-14)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.4.18-14 ro root = LABEL =/
Initrd/boot/initrd-2.4.18-14.img
The line with # above is a comment.
Create a menu to start Windows or DOS:
Title shortze
Rootnoverify (hd0, 0)
Makeactive
Chainloader + 1
Boot
#----
Or:
Title Microsoft Windows XP
Map (hd0) (hd1)
Map (hd1) (hd0)
Root (hd1, 0)
Chainloader (hd1, 0) + 1
Makeactive
Boot
----
Note: Both root and rootnoverify are the same. You can change rootnoverify to root. But after practice, we can see that. Sometimes, when windows is booted, the system is installed in the form of rootnoverify (hdX. Y). In this case, windows cannot start, and windows files are damaged. In this case, we need to change the rootnoverify in the windows section in grub to root.
Root means the root, which allows linux to know its location
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.