GRUB installation, configuration and use summary

zhaozj2021-02-16  107

(1) Install the GRUB when installing Linux.

When installing RedHat Linux, you will be prompted to install the boot program. If you select GRUB as the boot program, it is recommended to install the GRUB to

The hard disk's guiding sector Mbr.grub can also boot other operating systems, such as FreeBSD, NetBSD, OpenBSD,

GNU Hurd and DOS, as well as Windows 95, 98, NT, 2000, XP.

(2) GRUB configuration

Once GRUB is selected as the boot program, let's take a look at its configuration.

/boot/grub/grub.conf is a GRUB generating a boot selection menu and setting some options. Below is my GRU

B.conf:

# ========== example start ==========

# Grub.conf generated by Anaconda

#

# Note That You Do Not Have to Run Grub After Making Changes To this file

# NOTICE: You Have A / Boot Partition. This Means That

# All kernel and ionrd 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 = 10

SplashImage = (HD0, 6) /grub/splash.xpm.gz

# -> redhat linux 8.0 <-

Title Red Hat Linux (2.4.18-14)

Root (HD0, 6)

Kernel /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 option explanation:

The notes started with "#".

I have two operating systems here, which are Red Hat Linux and Microsoft Windows XP.

Among them, Timeout identifies the default waiting time, I set it to 10 seconds, more than 10 seconds users have not made a choice, they will

Move the default operating system (I am default it is Redhat Linux 8.0)

The default operating system is controlled by the default, and the number after Default indicates that the first is the default, here

0 Represents the first, 1 represents the second. So if you want to modify the default operating system, modify the number after Default

.

Title one is the name of the setting operating system, and GRUB does not support Chinese (a little regret).

SplashImage, a background image specified in a GRUB interface, interested friends can modify the background of the GRUB!

Root (HD0, 6) identifies from the first hard disk, the seventh partition to start the search guidance kernel. Note that the root and lin here

The UX's root partition is different. This root is non-Houble Root. The hard disk identification method of grub is a bit different from Linux. In Linu

The first primary partition in X is HDA1, the second primary partition is HDA1, and the first logical partition is HDA5, and it is in GRUB.

(HDX, Y) is identified, such as the first primary partition (HD0, 0) The first logical partition is (HD0, 1), so that the root is behind, the partition identifier of your / boot here.

Know where the kernel is, but also specifically pointed out which file is a kernel file, which is the work of Kernel.

Kernel /Vmlinuz-2.2.18-14 Ro root = label = /. Description / Boot/Vmlinuz-2.2.18-14 is

Loaded kernel. The following are the parameters passing to the kernel. RO is readonly meaning. Note that I here's kernel

The front path is "/" because my Boot is divided into a zone, if you don't have a separate partition for the boot, then the kernel

The front path is "/ boot".

Initrd is used to initially Linux Image, and set the corresponding parameters

Let's take a look at the definition of Windows.

Here, I added an item to boot WindowsXP. To do this, GRUB uses "chain loader" (CH

AINLOADER. Chain loader is loaded into WinXP its own boot loader in the boot record of partition (HD0, 0)

And guide it. This is why this technology is called chain load - it created a slave boot loader to

Another chain. This chain load technology can be used to guide any version of DOS or Windows. If you are counting

CHAINLOADER will guide the NtLoader of the guidance to Win's NTLOADER

To boot.

(3) Production of GRUB startup

To make a boot disk, you need to perform some simple steps. First, create an EXT2 file system on a new floppy disk. Course

After the installation, copy some of the GRUB files to the file system, and finally run the "GRUB" program, it will

Responsible for setting the boot sector of the floppy disk.

Insert an empty disk into a 1.44MB floppy drive, enter:

# MKE2FS / DEV / FD0

After you create an EXT2 file system, you need to install the file system:

# mount / dev / fd0 / mnt / floppy

Now you need to create some directories and put some key files (these files have been installed when you install GRUB)

Copy to 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

There is another step to get the available boot disk.

In Linux Bash, run "grub" from the root user, this program is very interesting and worth noting because it actually

The semi-functional version of the GRUB boot loader. Although Linux has been started and is running, you can still ship

Row GRUB and perform some tasks, and its interface with the GRUB boot disk or install GRUB to the hard disk MBR

The interface (ie, the GRUB console) as seen is exactly the same.

At the GRUB> prompt, enter:

GRUB> root (fd0)

GRUB> Setup (FD0)

GRUB> quit

Now, the guide disk is completed.

(4) Restore GRUB destroyed by Windows.

If you use GRUB to boot Linux and Windows, when Windows is reinstalled, it will destroy the GRUB in the MBR.

At this time, you need to restore GRUB.

1. Put the first place of the Linux installation CD to the CD-ROM drive, then restart the machine, and use the system in bois to lead the system.

guide.

2. After the installation interface comes out, press the [F4] button, which is Linux Rescue mode. 3. A series of keyboards and several simple formulations, [Continue] afterwards. . . This process, I don't say, ratio

Simple.

4. Then there will be such a prompt:

SH #

5. We can operate GRUB. Enter GRUB:

SH # grub

This prompt will appear:

GRUB>

We can enter: in such a character, enter:

Grub> root (hdx, y)

GRUB> Setup (HD0)

If success, there will be a successful ...

Here X, if it is a disk, it is 0, if you install Linux root partition on the second hard disk, that x

It is 1; Y, it is the root partition where the Linux system is located. Setup (HD0) is the m of writing GRUB to the hard disk

BR on the Br.

(5). With NTLoader to guide Linux.

If you don't choose to install GRUB when you install Linux, don't have to worry, now let's take a look at how to install Linux.

Install GRUB. And use Windows NTLoader to boot Linux.

1. Install GRUB

I use GRUB is a GRUB installation package belt with RedHat8.0: 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, you can use GRUBs used by default, 1, 2 steps

Province.

2. Establish a GRUB environment

CP / USR / Share / GRUB / I386-PC / * / Boot / GRUB

3. Generate a GRUB configuration file /BOOT /GRUB /MENU.CONF

Follow the grub.conf described above to generate a profile.

Note, here my Linux is in / dev / hda4, so menu.conf is (HD0, 3),

You may not be the same, you can't completely "painted scoop"! The partition position in the third step in INSTALL should also be

Your system is consistent.

3. Install GRUB to Linux partition boot

Install the GRUB's Stage1 to the Boot sector (HD0, 3) of / dev / hda4. The process is as follows:

/ sbin / grub (running GRUB)

GRUB> Install (HD0, 3) / Boot / Grub / Stage1 D (HD0, 3) / Boot / Grub / Stage2 P

(HD0, 3) /BOOT /GRUB / MeNU.conf

(Note that "GRUB>" is a prompt of GRUB, and the content is written on one line.)

4. Get the Boot information of GRUB

The process is as follows:

DD IF = / dev / hda4 of = / grub.lnx BS = 512 count = 1

This gives the GRUB boot information, as long as it is loaded with NT Loader.

5. Grub.lnx you get to get on the root directory of Windows C drive

You can make GRUB.LNX on the floppy disk first, then start Windows, copy to C: /; the situation allows you can directly in Li

NUX copies to C:. My C disk (ie equipment / dev / hda1) is FAT32, which can be directly removed from Linux.

as follows:

Mount -t vfat / dev / hda1 / mnt / c

Cp /grub.lnx / mnt / c

Umount / MNT / C

6. Modify the Boot.ini of NT Loader

Join one line: c: /grub.lnx= "redhat linux - grub"

The content of Boot.ini 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"

OK. You can load Linux with NT Loader, in fact, the above process is basically the same as NT Loader loading LILO.

Its basic thinking is to load LILO or GRUB boot area (grub.lnx) with NT Loader, where the key is L

Obtaining ILO or GRUB guiding area.

(6) Interactive function with GRUB

GRUB has powerful interaction. Learn to make you benefit!

1. What should I do if I do not display menu?

When booting, enter the grub interface but no menu, only one grub> prompt, how to start? Don't worry, look at:

Grub> cat (hd0, 6) /boot/grub/grub.conf (for 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

OK! Start it! There are some numbers to be changed according to your actual situation.

The above method can also be used to test the newly compiled kernel.

2. Enter a single user mode.

Sometimes I accidentally forget the root user password, I can only enter the single user mode to reset the root password. The method is as follows:

When booting into the GRUB interface, press C to enter the command line mode, then follow the method above, just after the third step

Add Single parameters.

转载请注明原文地址:https://www.9cbs.com/read-10197.html

New Post(0)