Reinstall grub in linux

Source: Internet
Author: User

This article applies to three situations

1. After using tar to restore the backup, grub has a problem and cannot be started. This is common after the partition is changed.

2. When linux is started, minimal bash-like line editing is supported cannot be started normally.

3. elf header smaller than expected and other issues occur when linux is started.

In short, a problem occurs in grub, which causes linux to fail to start normally.

Requirement: Live CD is available.

The procedure is as follows:

1. Mount/partition on your hard disk after entering live cd. my options are/dev/sda6.

Sudo mount/dev/sda6/mnt

Ii. Mount/dev/proc/sys

Sudo mount -- bind/dev/mnt/dev

Sudo mount -- bind/proc/mnt/proc

Sudo mount -- bind/sys/mnt/sys

3. This step is very important!

Are you sure you want to partition the boot partition separately?

If it is a separate partition, You need to mount the/boot partition. It is best to mount all other file systems.

Sudo mount/dev/sda1/mnt/boot

Sudo mount/dev/sda7/mnt/home

4. Change the chroot system after mounting

Chroot/mnt

Unmount the old grub

Apt-get purge grub-pc

Install the new

Apt-get install grub-pc

Grub-mkconfig

Grub-install/dev/sda

Exit

Umount/proc

Umount/dev

Umount/sys

Umount/dev/sda1

Umount/dev/sda7

Umount/dev/sda6

Reboot

This will succeed.

The most important thing is to mount the/boot partition. If your boot is partitioned separately, do not forget to mount it. Otherwise, it will not succeed!

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.