Reinstall Grub under Linux

Source: Internet
Author: User

Introduction

This guide will show you how to reinstall Grub with an arch-mounted disc if you have lost grub for some reason.

Note
    • In this tutorial, I will use sda1 as my root udev type references. If you use 0.7.1 's previous installation CD, you should change the Udev references to DEVFS references. If you do not understand, see technical_terms#hard_drives.
    • Also, note that this guide is for users who use IDE drives instead of SCSI or SATA drives, so if you are trying on non-IDE hardware, replace the appropriate place with the SCSI and SATA names.
Start the installation CD

First you need an installation CD . Any kind of installation CD can, of course, using the latest discs will be easier than the old ones.

Start the disc as usual ( do not use root= option) and then proceed to the next step.

Mount your current installation

Now you need to mount your current installed system. The general operation process is as follows:

    • Note: You must be aware of which partition and file system is appropriate. This example I will use sda1 as the root partition,ext3 as the file system, you can change according to your personal settings.
Cd/mount-t ext3   /dev/sda1/mnt          #如果你使用pre -0.7.1 cd,sda1 is/dev/discs/disc0/part1mount-t proc   proc      /mnt/procmount-t sysfs  sys       /mnt/sysmount-o bind/   dev      /mnt/dev chroot/mnt/bin/bash

You are now logged in as root into your current installed system as if you had just started the login. Go on to the next step!

re-install Grub

Edit /boot/grub/menu.lst Make sure everything is fine. Once you are absolutely sure that menu.lst is correct, run the following command:

Grub-install/dev/sda

If you do the steps before, this command should be executed successfully. (if not, note before the message) that's it, get it done! Exit Chroot and restart:

Cd/umount-aexitcd/umount-areboot
Error

If you encounter a bug that says the file/boot/grub/stage1 not read correctly, it is possible to indicate that your fstab/mtab is incorrect for some reason and needs to be corrected. These two files are /etc/mtab and /etc/fstabrespectively. Edit them, make sure they point to the correct partition, and then rerun Grub-install.

If you encounter a bug that says Sed:can ' t read/boot/grub/device.map:no such file or directory, This means that you need to use the Grub-install with the--recheck parameter.

Grub-install--RECHECK/DEV/SDA

Hopefully this will cover all the situations you might encounter. If you encounter other errors, restart and then step back and perform the steps above.

I hope this guide will be of some help to you! - Shadowhand

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.