GRUB instructions (2)

Source: Internet
Author: User
Article Title: GRUB instructions (2 ). 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.
Note:
  
In some file system and file system configurations, a 1.5-step file may be required to connect the differences between the basic boot program and the second boot program.
  
For example, if the bootstrap loader file in step 2 is located in a partition of the file system that is not accessible by the bootstrap loader in step 2, you may need to instruct Step 1 to boot the loader and load additional commands from step 2 to read the file of step 2. For more information, see the GRUB information page.
  
The bootstrap method mentioned above is called direct loading. This method uses commands for directly loading the operating system, without any intermediate code between the boot loader and the main operating system file (such as the kernel. However, the boot process adopted by different operating systems may be slightly different from the one mentioned above. For example, Microsoft's DOS and Windows operating systems tend to completely overwrite the Master Boot Record during installation, rather than merging the configuration of the current Master Boot Record. This will destroy all information stored by other operating systems in the Master Boot Record, such as Red Hat Linux. Microsoft operating systems and some other proprietary operating systems are started using a bootstrap method called chain loading. In this method, the primary Boot Record simply points to the first sector of the partition where the operating system is located.
  
GRUB supports direct and chained loading. GRUB can be used in almost all operating systems, most popular file systems, and almost all hard disks that can be identified by the system BIOS.
  
GRUB features
  
GRUB has many features, making GRUB more advantageous than other available boot loaders. The following lists some important features:
· GRUB provides a real command line-based environment on x86 machines that is prior to the Operating System (pre-OS. It provides maximum adaptability for loading operating systems or collecting system information with definite options. Many non-x86 architectures are already using the operating system environment? For many years, it provides control over how the system is guided from a command line. When LILO or other x86 Boot Loader uses some command features, GRUB already contains many of these features.
· GRUB supports Logical Block Addressing (LBA. LBA places the address translation work used to find files on the drive into the drive hardware, which is used in many IDES and all SCSI hard disks. Before using LBA, the hard drive encountered a 1024 cylindrical limit, that is, the BIOS could not find the file after the 1024 cylindrical (such as a boot loader or Kernel File ). As long as the system BIOS supports the LBA mode (most of them), LBA allows GRUB to go beyond the 1024 cylinder limit and boot the operating system.
· GRUB configuration can be read at every system boot. This avoids a primary Boot Record every time you change the boot options. Most boot loaders cannot read configuration files very frequently and use them to set boot options. For example, you must change a LILO configuration file and run a command to rewrite the new configuration data back to the system's primary Boot Record. This method is more dangerous than the method used by GRUB, because a primary Boot Record with misconfiguration will make the system unable to boot. In GRUB, if the configuration file is incorrectly configured and guided, it is simply converted to a default command line, allowing you to manually enter commands to run the operating system. Apart from the first, second, or menu configuration file location of the update system boot, The Master Boot Record will not be touched, and this rarely happens.
  
Note:
  
When the GRUB configuration file changes, there is no need to restart GRUB. All changes can be detected automatically. If GRUB is restarted, it is returned to the GRUB shell in command line mode.
  
Install GRUB
  
If GRUB is not installed during Red Hat Linux installation, the following describes how to install it and set it as the default boot loader.
  
NOTE: If LILO has been installed and is the current system boot loader, it is not necessary to delete it to use GRUB. After GRUB is installed, it is used as the default boot loader.
  
First, obtain the latest available GRUB package. You can also use the GRUB package on the Red Hat Linux installation CD.
  
Next, run the command/sbin/grub-install at the shell prompt, where GRUB will be installed. For example:/sbin/grub-install/dev/hda
  
Finally, reboot the system. The GRUB graphic boot menu appears. Ii. GRUB terminology
  
Before using GRUB, one of the most important tasks is to understand how the program references devices, such as system hard drive and partition. This information is very important for configuring GRUB to implement multi-OS boot.
  
Device Name
  
The first hard drive of the system is called (hd0) by GRUB ). The first partition on it is called (hd0, 0), and the first partition on the second hard drive is called (hd1, 4 ). When GRUB is used, the file system Naming Convention is as follows:
  
(,)
In device naming, parentheses and commas are important. Indicates whether a hard disk (hd) or a floppy disk (fd) is specified.
  
Is the device number determined according to the system BIOS, starting from 0. The basic IDE hard disk is marked as 0, and the second IDE hard disk is marked as 1. This sorting is basically equivalent to the ordering of devices with letters in the Linux kernel, but changes a in hda to 0, B in hdb to 1, and so on.
  
Note: The naming system for GRUB is from 0, not 1. This is often the most common mistake that GRUB beginners often make.
The ID of a partition on a hard disk. Similarly, the partition number starts from 0. Although most partitions can be specified by numbers, if the system uses BSD partitions, they are still specified by letters, such as a or c.
  
When naming devices and partitions, GRUB uses the following rules:
  
· The system uses an IDE or SCSI hard disk. All hard disks start with hd. Floppy Disk starts with fd.
· When the entire hard disk is specified without considering its partition, simply remove the comma and Partition Number. This is important when you tell GRUB to configure a primary Boot Sector for a specific hard disk. For example, (hd0) specifies the first device and (hd3) specifies the fourth device.
· If a system has multiple drivers, it is important to know the drive sequence determined by the BIOS. If the system only has an IDE or SCSI drive, it is quite simple. But if there is a mix of multiple drives, this can be confusing.
  
File Name
  
When you enter commands including files in GRUB, for example, to use a menu list in multiple operating systems, the file name must be specified directly after the device and partition. The format of an absolute file name is as follows:
  
(,)/Path/to/file
  
Most of the time, you can specify a file by adding a file name to the directory path on the partition. This method is straightforward.
  
In addition, we can also specify a file that does not appear in the file system to GRUB, such as the chain pilot loader in the first several slices of a partition. To specify these files, you need to provide a block list to tell the location of the GRUB file in the partition one by one. When a file is composed of several different blocks, a special method is required to write the block list. The position of each file segment is described by the offset of a block and the number of blocks starting from the offset point. These fragments are organized in a comma-delimited order.
  
Consider the following block list:
  
0 + 50,100 + 25,200 + 1
  
The above Block List tells GRUB to use a file starting from the first partition. It uses 0th to 49th blocks, 99th to 124 blocks, and 199th blocks.
  
It is useful to know how to write a block list when you use GRUB to mount an operating system such as Microsoft Windows that uses chained loading. If the number starts from 0th, the offset of the block can be omitted. As an example, when the chain mount file is in the first partition of the first hard disk, you can use the following name:
  
(Hd0, 0) + 1
  
The following is a chainloader command with a block list name. It is given in the GRUB command line after the correct device and partition are set as the root.
  
Chainloader + 1
GRUB root file system
  
Some users are often confused about the usage of the root filesystem term in GRUB. GRUB's root file system has nothing to do with Linux's root file system. Remember this.
  
The GRUB root file system is used for the root partition of a specific device. GRUB uses this information to mount the device and load files from it.
  
In Red Hat Linux, once GRUB loads its own root partition containing the Linux kernel, the kernel command can run the kernel file location as an option. Once the Linux kernel is booted, it sets its own root file system. At this time, the root file system is used by most people to contact Linux. The original GRUB root file system and its mounting are removed, and they exist only in guiding kernel files.
  
For more information about root and kernel commands, refer to the command section below.
  
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.