Two methods for installing GRUB in Linux

Source: Internet
Author: User
GRUB installation methods we all know that there is an important Bootstrap Program & mdash; MBR during the operating system startup process. MBR is one of the most important three segments: a bootlocader (boot loader) consisting of 446 bytes and a 64-byte partition table. Two installation methods are available for MBR 44... GRUB.
We all know that there is an important boot program-MBR in the operating system startup process. MBR is one of the most important two segments consisting of three segments: a boot locader consisting of 446 bytes (boot loader) and a 64-byte partition table. The 446-byte boot locader program in MBR is very important for guiding the operating system. Linux has two types of boot locader options: LILO and GRUB. LILO is no longer needed. Currently, GRUB is primarily used for guidance. Now let's introduce GRUB.
GRUB is a two-stage guide. The first stage is called stage1, which is stored in MBR. it is mainly used to guide the execution program of stage2 in the/boot/grub/stage, mainly grub. conf file. The following describes how to install GRUB.
First, when the grub. conf file does not exist, you can manually edit it. When the system is restarted, a grub prompt interface will appear, and we do not know which disk the system is on. in this case, we can use a command to try and find out, grub> find (hd0, 0)/use the Tab key to check whether a kernel version exists. If yes, it is on this disk, and if not, find the next version. After finding it, enter root (hd0, 0) after grub>. The second step is to enter the kernel version after grub>. for example: kernel/vimlinuz-2.6.18-64.el5 ro root =/dev/vol0... quit. The third step is initrd. for example, grub> initrd/initrd is later than the kernel version. Finally, grub> boot means restarting. After it is started, create a grub. conf in/boot/grub so that our grub is successfully installed.
Method 2: When grub is destroyed. For example, if the command # dd if =/dev/zero of =/dev/sda bs = 220 count = 1 is executed, the boot locader in MBR is deleted. How can we reinstall grub? There are two methods. First, find a system disc and start the emergency rescue mode from the disc to repair grub. The second method is to install grub on a disk. The process is as follows:
The first step is to refresh a disk into one partition, about MB,
Step 2: format the partition, # mount ext3/dev/sdb1
Step 3: Create a directory. # Mkdir/mnt/boot and mount the above partition to this directory # mount/dev/sdb1/mnt/boot
Step 4: create a directory # mkdir/mnt/boot/grub
Step 5: go to the original operating system i386-redhat directory and copy all the files under the Directory. # Cd/usr/share/grub/i386-redhat
# Cp./*/mnt/boot/grub
Step 6: go back to the original directory and uninstall the cd # umount/dev/sdb1
Step 7: execute the grub command # grub will display a grub interface. Step by step.
Grub> root (hd1, 0)
Grub> setup (hd1)
Grub> quit
After these seven steps, our grub is successfully installed on a new disk. we can create a new virtual machine and use this disk. after it is started, we can see the interface guided by grub.
The above two methods are used to install grub. if there is another kernel, it will be a small Linux operating system.
This article is from the "linux learning" blog
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.