How to use Live CD to fix Grub/Grub2

Source: Internet
Author: User

How to use Live CD to fix Grub/Grub2
Introduction

I usually have two or more systems installed on my computer. For example, I have installed Ubuntu, Windows 7, and Windows 8.1 on my computer. One day, Win8.1 cannot be used normally. I want to reinstall Win8.1, but Linux cannot be booted into after installation! We all know that Grub is used for guidance in Linux, so we can reinstall Grub!

Because the original Linux cannot be accessed, we create a Linux system installation disk and use "Try Ubuntu" to complete this task.

Create a Linux installation disk

I will not talk about this for the moment.

Start recovery List Disk Partitions
ubuntu@ubunt:~$ sudo fdisk -l

I have three hard disks. The output result is as follows:

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk identifier: 0x2bf44b31 Device Boot Start End Blocks Id System/dev/sda1 * 2048 209717247 104857600 7 HPFS/NTFS/exFAT/dev/sda2 209717248 419432447 104857600 7 HPFS/NTFS/exFAT/dev/sda3 419434494 1953523711 767044609 f W95 Ext'd (LBA)Partition 3 does not start on physical sector boundary./dev/sda5 419434496 629149695 104857600 7 HPFS/NTFS/exFAT/dev/sda6 629151744 838866943 104857600 7 HPFS/NTFS/exFAT/dev/sda7 838868992 1048584191 104857600 7 HPFS/NTFS/exFAT/dev/sda8 1048586240 1048975359 194560 83 Linux/dev/sda9 1048977408 1348974591 149998592 83 Linux/dev/sda10 1348976640 1548974079 99998720 83 Linux/dev/sda11 1548976128 1889515519 170269696 7 HPFS/NTFS/exFAT/dev/sda12 1889525760 1953523711 31998976 82 Linux swap / SolarisDisk /dev/sdb: 320.1 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xc4e7c4e7Disk /dev/sdb doesn't contain a valid partition tableDisk /dev/sdc: 320.1 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xafd68fba Device Boot Start End Blocks Id System/dev/sdc1 2048 209717247 104857600 7 HPFS/NTFS/exFAT/dev/sdc2 209717248 625139711 207711232 f W95 Ext'd (LBA)/dev/sdc5 209719296 625139711 207710208 7 HPFS/NTFS/exFAT

The System marked as Linux is the partition controlled by Linux.

Mount Linux partitions on Hard Disks

I knew that the partition was like this when I first installed Linux:

/boot ~200MB/ ~150GB/home ~?

So I decided:

/dev/sda8 /boot/dev/sda9 //dev/sda10 /home

As follows:

ubuntu@ubunt:~$ sudo mount /dev/sda9 /mntubuntu@ubunt:~$ sudo mount /dev/sda8 /mnt/bootubuntu@ubunt:~$ sudo mount /dev/sda10 /mnt/home

After mounting, perform the following operations (for unknown reasons ):

ubuntu@ubunt:~$ sudo mount --bind /sys /mnt/sysubuntu@ubunt:~$ sudo mount --bind /proc /mnt/procubuntu@ubunt:~$ sudo mount --bind /dev /mnt/dev
Use the Linux system on the hard disk to reinstall grub

If you are using grub2:

Ubuntu @ ubunt :~ $ Sudo chroot/mntubuntu @ ubunt:/# grub2-install/dev/sdaubuntu @ ubunt:/# grub2-mkconfig-o/boot/grub2/grub. Reboot Ubuntu @ ubunt:/# exit chroot

If not grub2:

Ubuntu @ ubunt :~ $ Sudo chroot/mntubuntu @ ubunt:/# grub-install/dev/sdaubuntu @ ubunt:/# grub-mkconfig-o/boot/grub. ubuntu @ ubunt:/# exit chroot
Exit & restart

If you want

ubuntu@ubunt:~$ sudo umount /mnt/sysubuntu@ubunt:~$ sudo umount /mnt/procubuntu@ubunt:~$ sudo umount /mnt/devubuntu@ubunt:~$ sudo umount /mnt/homeubuntu@ubunt:~$ sudo umount /mnt/bootubuntu@ubunt:~$ sudo umount /mntubuntu@ubunt:~$ sudo shutdown -r -h now

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.