Ubuntu - grubrescue master boot fix

  
        

People who have used Windows and Ubuntu dual systems for a long time may encounter reinstalling a system or adding a partition to cause a system reboot:

GRUB loadingerror:unknow filesystemgrub rescue>

Please indicate the source: http://blog.csdn.net/jscese/article/details/36865449

I. Concept

BIOS:"Basic Input Output System", Chinese name It is "basic input and output system". In fact, it is a set of programs that are solidified onto a ROM chip on the motherboard of the computer. It stores the most important basic input and output programs, system setting information, self-test program after booting, and system self-starting program. Its main function is to provide the lowest level of hardware setup and control for the computer.

MBR: “Master Boot Record” The physical sector of the hard disk, also called the master boot record! Because the BIOS is too small to host the running program, after the bios detects a hard disk, the contents of the 0 cylinder, 0 head, and 1 sector of the hard disk are simply judged, and then go to the specified position in the memory, and then jump. To this position, start running from this location, the size is 512 bytes, which mainly stores the boot program and the partition table of the hard disk.

GRUB: & ldquo;GRand Unified Bootloade” Multiple operating system boot manager, which can be used to boot into other systems after running this GRUB, including window and linux

From the literal meaning, they should be able to understand their flow, roughly:

PC first boot to the BIOS, then detect the MBR of the hard disk, the content of the MBR sector (that is, GRUB written on it) Load the memory to run, and then achieve the new jump start by running the results obtained by GRUB!

II.Ubuntu grub2 fix

When the PC is installed with windows and then installed ubuntu or only one ubuntu system, the grub2 bootloader that comes with the ubuntu system is written on the MBR. Then the main boot program for booting is grub2! (ububub uses grub2 since 9.10)

and grub2 is divided into two parts, some of which are written to MBR, some of which exist with ubuntu's /boot/grub directory. under.

And grub rescue> is the grub program that does not work properly on behalf of the MBR part, start grub rescue mode, because the /boot/grub part cannot be found.

The available commands under grub rescue:

set, ls, insmod, root, prefix (set the startup path)

First, all the partitions are viewed through ls and will be listed:

(hd0), (hd0, msdos8), (hd0, msdos7), (hd0, msdos6), (hd0, msdos5), (hd0, msdos3), (hd0, msdos1)

Need to find the ubuntu installation partition, through ls (hd0, msdos*) /boot until it does not appear: error: unknown filesystem

If you know where to start installing ubuntu, such as sda7 then here is msdos7, if It is to add partitions in the place before the ubuntu hard disk space, then move the ubuntu partition serial number backwards! Become msdos8

After setting, set the one-time startup parameters by the following command:

grub rescue>setroot=(hd0,msdos8)grub rescue>set prefix=(hd0,msdos8)/grubgrub Rescue>insmod /grub/normal.modgrub rescue>normal will appear in the boot interface in boot/grub! 

If /boot/grub is not corrupted, you can enter the ubuntu system. If the part of grub boot ubuntu is damaged, you need to manually boot:

Enter the grub command line:

 Grub> root (hd0,8) ## Specify partitiongrub> kernel /boot/vmlinuz-2.6.18- containing vmlinuz-2.6.18-274.7.1.el5 and initrd-2.6.18-274.7.1.el5.img 274.7.1.el5 ro root=/dev/sda8 ## root= is to specify the partition containing /sbin/init, that is, the mount/partition (by Linux) grub> initrd /boot/initrd-2.6.18- 274.7.1.el5.img ## It is said that this can omit grub> boot

After correctly entering ubuntu, you need to update the grub part of MBR to adapt to the new partition:

Terminal input: < Br>

sudo update-grub2sudo grub-install/dev/sda updated to /boot/grub/grub.cfg! Then install grub to the MBR

of the main hard disk. I have encountered such an unsuccessful installation. In the GRUB2 manual, there is another way to reinstall grub2 to MBR. Record it:

This solution is installed. The chroot command is used to access the file of the damaged system. Once the chroot command is executed, the LiveCD will treat the /(root) of the corrupted system as what it is currently using. The instructions executed in the chroot environment affect the file system of the compromised system, not the LiveCD. 1. Boot into the LiveCD desktop (Ubuntu 9.10 or later). Note that this LiveCD must be the same version you want to fix now - either 32-bit or 64-bit (otherwise chroot will fail). 2. Open the terminal - application, affiliate application, terminal. 3. Confirm your standard system partition - (option is lowercase "L") sudo fdisk -l If you are not sure, execute df -Th to find the correct disk capacity and ext3 or ext4 format. 4. Mount your standard system partition with the correct partition: sda1, sdb5, and so on. Sudo mount /dev/sdXX /mnt #example: sudo mount /dev/sda1 /mnt5. If you have a separate /boot partition: sdYY is the location of the /boot partition (eg sdb3) sudo mount /dev/sdYY /mnt /boot6. Mount the important virtual file system: sudo mount --bind /dev /mnt/devsudo mount --bind /dev/pts /mnt/dev/ptssudo mount --bind /proc /mnt/procsudo mount --bind /sys /mnt/sys7. Chroot to your standard system device: sudo chroot /mnt8. If /boot/grub/grub.cfg is not present on your system or its contents are incorrect, use the following command to rebuild update-grub9. Reinstall GRUB 2 : Replace with the correct device - sda, sdb, and so on. Do not specify a partition number. Grub-install /dev/sdX10. Verify the installation (use the correct device, such as sda. Do not specify partition): sudo grub-install --recheck /dev/sdX11. Exit chroot: press CTRL-D12 on the keyboard. Uninstall Virtual File system: sudo umount /mnt/dev/ptssudo umount /mnt/devsudo umount /mnt/procsudo umount /mnt/sys If you have mounted a separate /boot partition: sudo umount /mnt/boot13. Uninstall LiveCD /usr Directory: sudo umount /mnt/usr14. Uninstall the last device: sudo umount /mnt15. Reboot. Sudo reboot
						
Copyright © Windows knowledge All Rights Reserved