2. Install grub

Source: Internet
Author: User
First download the grubsource code from the ftp://alpha.gnu.org/pub/gnu/grub, get to the file grub-0.5.96.1.tar.gz, and then:

# Tar-xvzf grub-0.5.96.1.tar.gz

This command places the unwrapped files and directories in a directory named grub-0.5.96.1. Run the following command:

# Cd grub-0.5.96.1

#./Configure

If you want to customize grub to include popular file systems and support for NICs, or delete NICs you do not need, run the following command:

#./Configure -- Help

This command outputs all command options. Now you can use the-enable and-Disable options to add or

Delete the support for a specific Nic. (Note: grub supports Network startup)

To start the compilation process, enter the following command:

# Make

# Make install

Now you are ready to install grub.

2.1Install in the Main Boot Area

Save grub-related files in directories such as/boot/grub. By default, all grub files are installed in/usr/share/GRUB/i386-pc (or in the/usr/local/share/GRUB/i386-pc directory, this only depends on the settings of shell variables .) . Create a directory named/boot/grub and copy the following files to this directory: stage1 stage2 * stage1 5. At the same time, copy grub (possibly in the/usr/sbin or/usr/local/sbin directory) to the/boot/GRUB directory.

# Cd/boot/GRUB

#./GRUB

This command detects hardware devices based on bios settings and generates some output information. This takes a long time.

The tab key can be used to list possible commands. In other cases, the tab lists the devices or file names. The following prompt appears:

Grub> (grub> setup (hd0, 4)

Now, suppose you have installed Linux in the first partition of the first hard disk or/dev/hda1. Remember the naming rule of grub and change the name above to (hd0, 0 ). Type the following command:

Grub> install (hd0, 0)/boot/GRUB/stage1 (hd0) (hd0, 0)/boot/GRUB/stage2

P (hd0, 0)/boot/GRUB/menu. conf

Analyze the details of this command.

Install:A built-in command that tells grub to install (hd0, 0)/boot/GRUB/stage1 to the Master Boot Record of hd0;

(Hd0, 0)/boot/GRUB/stage2:The location of the grub stage2 image.

P and subsequent options (hd0, 0)/boot/GRUB/menu. conf: Set the configuration file for the menu display.

Note:If grub has been installed and you want to reinstall it on the primary Boot Sector, simply run the makebootable command.

 

2.2Install on a floppy disk

Method 1:

Install stage1To a floppy disk:Insert a formatted floppy disk

# Cd/boot/GRUB

# Dd If = stage1 of =/dev/fd0 BS = 512 COUNT = 1

The command details are as follows:

If = input file

For example, stage1

Of = output path

For example, floppy disk (not all floppy disks in each machine are/dev/fd0, which can be viewed by fdisk-l)

BS = number of bytes read or written

Here is 512 bytes

Count = number of times the previous operation was executed

Install stage2To floppy disk:

# Dd If = stage2 of =/dev/fd0 BS = 512 seek = 1

The steps here are the same as those in stage1, except for the seek option. The seek option skips a "BS ". For example, in the above command, the BS value is 512, so that seek = 1 means that the first 512 bytes of the floppy disk will be skipped, starting from 513 bytes. This will prevent the first step from overwriting the first 512 bytes of stage1.

Method 2:

Insert an empty disk into the 1.44 MB drive. Enter:

# Mke2fs/dev/fd0

After creating an ext2 file system, you must install the file system:

# Mount/dev/fd0/mnt/floppy

Now, you need to create some directories and copy some key files (these files have been installed before grub was installed) to the 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

Run "Grub" from the root user. This program is actually a semi-functional version of the grub boot loader. Although Linux is started and running, you can still run grub and execute some tasks, in addition, the interface is exactly the same as that seen when you use the grub boot disk or install grub to the hard disk MBR (that is, the grub console.

At the grub> prompt, enter:

Grub> root (fd0)

Grub> setup (fd0)

Grub> quit

 

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.