Grub installation, configuration, and use instance Rollup tutorial

Source: Internet
Author: User
Tags command line copy file system ini interface key version linux
Installing Redhat Linux prompts you to install the bootstrapper, and if you select Grub as the bootstrapper, it is recommended that you install grub to the boot sector of your hard disk Mbr.grub and boot other operating systems, such as FreeBSD, NetBSD, OpenBSD, GNU HURD, and DOS , as well as Windows 95, 98, NT, 2000, XP.

(ii) configuration of Grub

Once you have selected grub as the bootstrapper, let's take a look at its configuration. /boot/grub/grub.conf is grub produces a boot selection menu and sets some options. Here's my grub.conf:


#========== example starts with ========== # grub.conf generated by Anaconda # # Note ' You don't have to rerun grub after making Chang Es to this file # notice:you have a/boot partition. This means so # all kernel and INITRD paths are relative to/boot/, eg. # root (hd0,6) # kernel/vmlinuz-version ro root=/dev/hda10 # initrd/initrd-version.img #boot =/dev/hda default=0 timeout= Splashimage= (hd0,6)/grub/splash.xpm.gz #--> Redhat Linux 8.0 <--title Red Hat Linux (2.4.18-14) root (hd0,6) ke rnel/vmlinuz-2.4.18-14 ro root=label=/initrd/initrd-2.4.18-14.img #--> Microsoft Windows XP <--title Microsoft Windows XP rootnoverify (hd0,0) chainloader +1 #=========== example End ==========



Configuration options Explanation:

Starting with "#" is the comment line. I have two operating systems, Red Hat Linux and Microsoft Windows XP, respectively. Where the timeout identifies the default wait time, I set this to 10 seconds, more than 10 seconds before the user has made a choice, the default operating system will be automatically selected (my default here is Redhat Linux 8.0)

The default operating system is controlled by the defaults, and the number after the default indicates that the first few are the defaults, where 0 indicates that one and 1 represents the second.

So if you want to modify the default operating system, change the number of defaults. Title one is to set the name of the operating system, grub does not support Chinese (a bit regrettable). Splashimage A background image that specifies the grub interface, interested friends can modify the grub background.

The root (hd0,6) identity launches the search boot kernel from the first hard drive, the 7th partition. Note that root is not the same as the Linux root partition, and this root is also! Grub's hard drive identification method is a little different from Linux. In Linux, the first primary partition is HDA1, the second primary partition is HDA1, the first logical partition is HDA5, and in grub it is identified by (Hdx,y), such as the first primary partition (hd0,0), and so on, the first logical partition is (hd0,1).

So the root of this here is your/boot partition ID. Know where the kernel is, and also specify which file is the kernel file, this is Ke

Rnel's work. KERNEL/VMLINUZ-2.2.18-14 ro

root=label=/. Description/boot/vmlinuz-2.2.18-14 is the kernel to load. The following are the parameters that are passed to the kernel.

Ro is the meaning of readonly. Note that the path in front of my kernel here is "/", because my boot has a separate section, if you do not separate the boot, then the path in front of the kernel is "/boot". INITRD is used to initialize the Linux image and set the corresponding parameters.

Let's look at the definition section of Windows. Here, I have added an item to boot Windows XP. To complete this operation, GRUB uses a "chained loader" (Chainloader). The chain loader loads WinXP's own boot loader from the boot record of the partition (hd0,0) and then directs it. This is why this technique is called chained loading-it creates a chain from the boot loader to the other.

This chained-mount technique can be used to boot any version of DOS or Windows. If you have WIN98,WINME,WIN2K,WINXP in your computer, Chainloader will guide you through the Ntloader of win.

Three Production of Grub Boot disk

To make a boot disk, you need to perform some simple steps. First, create the Ext2 file system on the new floppy disk. Then, install it, copy some grub files to the file system, and finally run the GRUB program, which will be responsible for setting the boot sector of the floppy disk.

Insert an empty disk into the 1.44MB floppy drive and enter:

# mke2fs/dev/fd0 After you create the ext2 file system, you need to install the file system: # Mount/dev/fd0/mnt/floppy Now, you need to create some directories and copy some of the key files (files that were installed when you originally installed GRUB) to a floppy disk: # mkdir/mnt/floppy/boot # mkdir/mnt/floppy/boot/grub # cp/boot/grub/stage1/mnt/floppy/boot/grub # cp/boot/grub/stage2 /mnt/floppy/boot/grub

Another step is to get the available boot disks.

In Linux bash, running "grub" from the root user is interesting and noteworthy because it is actually a semi functional version of the Grub boot loader. Although Linux is already up and running, you can still run GRUB and perform certain tasks, and the interface is identical to the interface that you see when you use the Grub boot disk or when you install grub on the hard disk MBR (that is, the GRUB console). At the grub> prompt, enter:

grub> root (fd0) grub> setup (fd0) grub> quit

Now the boot disk is complete.

(iv) Recovery of Windows-damaged grub

If you use GRUB to boot Linux and Windows, and you destroy grub in the MBR after Windows has been reinstalled, you need to restore grub.

1. Put the first piece of the Linux installation CD into the optical drive, then restart the machine, in the Bois system light drive to boot.

2. When the installation interface comes out, press the F4 key, which is the Linux rescue mode.

3. A series of keyboard and a few simple preparation, after the "continue" the process, here do not say, relatively simple.

4. The prompt will then appear:

sh#

5. We'll be able to operate grub. Enter Grub:

Sh#grub
The prompt will appear:

Grub>

We can then type in the following characters:

Grub>root (hdx,y) grub>setup (hd0)



If successful there will be a successful ...

Here x, if it is a disk, is 0, if you install the Linux root partition on the second hard drive, that x is 1; Y, is the root partition that contains the Linux system. The Setup (hd0) is to write grub on the MBR of the hard disk.

(v) Use Ntloader to guide Linux

If you don't have the option to install grub when installing Linux, don't worry, now let's see how to install grub after installing Linux. and use Windows Ntloader to boot Linux.

1. Install Grub

The grub I used is the GRUB installation package for the Redhat8.0 belt: grub-0.92-7.rpm

Installation: Rpm-ivh grub-0.92-7.rpm

Other installation methods are the same, as long as you install grub on the line. RH8 the default grub, 1, 2 steps can be saved.

2. Setting up the GRUB environment

cp/usr/share/grub/i386-pc/*/boot/grub

3. Generate GRUB Configuration file/boot/grub/menu.conf

Follow the grub.conf described above to generate a configuration file.

Note that here my Linux is in/dev/hda4, so menu.conf those partition locations for (hd0,3),

You may not be the same, do not fully follow the "painting Scoop" Oh! The partition location in the 3rd step install below should also be consistent with your system.

Install grub to Linux partition boot

Install the Grub stage1 to the boot sector (hd0,3) of the/dev/hda4. The process is as follows:

/sbin/grub (Running grub) grub> Install (hd0,3)/boot/grub/stage1 D (hd0,3) (hd0,3)/boot/grub/stage2 P (hd0,3)/boot/grub/ Menu.conf

(Note that the "grub>" above is a grub prompt and the content is written on one line.) )

4. Get Grub's boot information

The process is as follows:

DD if=/dev/hda4 OF=/GRUB.LNX bs=512 count=1

This gets grub's boot information, as long as it is loaded with NT loader.

5. Will get the above grub.lnx to the Windows C packing directory, you can first GRUB.LNX the floppy disk, and then start Windows, copy to C:\; The situation allows you to also copy directly under Linux to C:. My c-disk (ie device/dev/hda1) is FAT32 and can be passed directly from Linux. As follows:

Mount-t vfat/dev/hda1/mnt/c cp/grub.lnx/mnt/c umount/mnt/c

6. Modify the NT loader boot.ini

Add one line to it: c:\grub.lnx= "Redhat Linux-grub"

After joining the Boot.ini content is as follows:

[boot loader] timeout=15 DEFAULT=C:\BOOT.LNX [operating systems] multi (0) disk (0) rdisk (0) partition (1) \ windows= " Microsoft Windows XP Professional "/fastdetect [VGA mode]"/basevideo/sos c:\grub.lnx= "Redhat linux-grub"



Linux can be loaded with NT loader, in fact, the above process is basically the same as using NT loader loading lilo. The basic idea is to use the NT loader to load the LILO or Grub boot area (GRUB.LNX), which is the key to the LILO or Grub boot area acquisition.



(vi) to utilize the interactive functions of grub
Grub has a powerful interaction capability. Learn will make you benefit not shallow!

1.grub does not show the menu what to do?

When the boot into the grub interface but without the menu, only a grub> prompt, how to start it? Don't worry, look at the following:

Grub>cat (hd0,6)/boot/grub/grub.conf (to see parameters) Grub>root (hd0,6) Grub>kernel (hd0,6)/vmlinuz-2.4.18-14 ro root= label=/grub>initrd (hd0,6)/initrd-2.4.18-14.img Grub>boot started! Some of the above figures should be changed according to your actual situation. The above method can also be used to test the newly compiled kernel.

2. Enter Single-user mode.

Sometimes the root password is accidentally forgotten and can only be entered in Single-user mode to reset the root password. The method is as follows: Boot into the Grub interface, press C to enter the command line mode, and then follow the above method, only in the third step to add a single parameter later.

  

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.