Fix grub2 after hard disk partition change (add a hard disk partition)

Source: Internet
Author: User

Yesterday, I divided my computer into two 63g instances. After that, I remembered that my MBR was guided from grub2. It was bad. It really didn't work. After I restarted it, I couldn't enter the operating system,

Only GRUB boot error occurs.

 

Operating system status: ubuntu9.10, Windows XP, and grub2 boot.

Temporary solution: Find a Windows installation disk. In the console repair mode, run the fixmbr command to fix MBR for Windows startup. After restarting, you can enter the familiar XP interface. The specific steps are as follows:

I have introduced it on the Internet and will not detail it in detail. If you do not remember this command, you can enter help in the console to view help.

In this case, you can use other solutions:

Unable to start, only one grub> prompt appears, you can use the following steps

Find/boot/GRUB/CORE. IMG find the corresponding boot Partition

Returned values: (hd0, 8)

Input: Root (hd0, 8)

Enter kenerl/boot/GRUB/CORE. IMG ..

After completion, boot enters the boot

(Here, I use grub to retrieve the boot menu, but because the partition changes, I can only access windows partition (hd0, 1), not Ubuntu partition (hd0, x ), because the X value changes after the partition is changed and cannot be matched, there is no way to recover from live CD)

 

After the restart, the familiar XP interface came back and finally breathed a sigh of relief. However, I remembered that my ubuntu9.10 had been installed twice (one was a direct upgrade, and many drivers were unavailable after the upgrade, this is the last time) but now I don't want to toss my hard disk, and I don't want to format it. So I found the corresponding method on the Internet and re-installed grub2. The steps are as follows:

 

1. Download ubuntu9.10. ISO and install grubdos. in the Windows startup Item, add grubdos boot to start from live CD and restart

2. After the startup, select grubdos and use Ubuntu install to boot to Ubuntu to experience the desktop. At this time, you can connect to the network and view information.

3. Open the terminal and enter the command Sudo-I (Role: Log On As root)

4. Enter sudo fdisk-l in the terminal

// List all disks. See the disk where grub2 is to be restored ~

Result:

Device boot start end blocks ID system
/Dev/sda1*1 32508 16384000 + 7 HPFs/NTFS
/Dev/sda2 32509 94100 31042368 7 HPFs/NTFS
/Dev/sda3 94101 310101 108864473 F w95 ext 'd (LBA)
/Dev/sda5 94101 162763 34606089 + 7 HPFs/NTFS
/Dev/sda6 162764 223715 30719776 + 7 HPFs/NTFS
/Dev/sda7 223715 251972 14241591 82 Linux swap/Solaris
/Dev/sda8 251972 310096 29294496 83 Linux

 

 

We can see that my original ubuntu was installed on sda8.

 

 

5. Mount the root directory partition

Sudo Mount/dev/sda8/mnt

 

Note that/dev/sda8 is the partition where your Ubuntu boot file is located and changes accordingly based on your hard disk.

 

Other supplements on the Internet:

 

// This step only mounts/boot to a different partition from the root directory.

Sudo Mount/dev/sda2/mnt/boot

 

This step does not match my machine configuration and is not executed

 

 

6. // Mount other partitions or devices (important)

Sudo Mount -- bind/dev/mnt/dev

7. // change the root directory. Here we will not explain the meaning of chroot in detail. It is a bit mysterious and easy to understand.

Sudo chroot/mnt

// Run Update-grub to update the configuration file (in fact, re-build/boot/GRUB/grub. cfg)

Update-grub

// Install grub2 to the MBR of the specified hard disk

Grub-install/dev/SDA

 


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.