Start and fix grub in rescue mode

Source: Internet
Author: User
Today, I encountered a grub repair problem again, and I have encountered it once before. I installed Ubuntu 10.04 and Windows 7. The default system startup Item is ubuntu. Because the first time ubuntu was installed, only 15 GB (for those who have been using Linux For A Long Time) o... very small), So I deleted the partition with Ubuntu directly in windows ~~ Now .. Unfortunately, Windows cannot be started ~~ Grub won't be repaired, and it doesn't matter if you find something online .. At that time, I was speechless and asked for help from other children's shoes. Use winpe to fix grub. I don't know what to ask for, so I have repaired it ~~ Continue playing ~ This time I want to install the meego system, so I have to partition windows again. As a result, the Windows partition fragments are incompatible with LINUX partition fragments ~~ Enter the black box again ~~ All commands are "Unknown command" except ls ~~ List partition (hd0), (hd0, 8), and so on ~~ (Of course, 'this is because I didn't know it at the time, and the grub rescue and grub commands are not the same ).. However ~~~ This time .. I decided to solve the problem by myself .. Find a perfect solution on the Internet ~~ But the result is .. Still not .. In fact, the solution for children's shoes is right, but it is not suitable for me. In addition, for the cainiao whose knowledge of grub commands is 0, I don't know what it means to press the commands he gave .... But fortunately, some seniors have previously provided some detailed PDF of grub basic tutorials, so I just learned how to start and fix grub in rescue mode, of course, you can also use the CD that you installed the system to repair grub. Here, I just want to explain how to start and fix grub in rescue mode ~~ Good luck ~~ The topic is as follows: (I am not talking about Doha.) due to partition issues, the grub rescue mode is automatically started and the following content is displayed:
    Error: Unknown filesystemgrub rescue>
Generally, as long as the grub core file is still in the partition, we can switch from rescue mode to normal mode, and then run the command to enter the system. In rescue mode, only one command is available (I think the most confusing is why the Help Command is available in wood? Why? I don't know ?) :
    Set --- set variable value (same as grub2 command) ls --- list all current devices. E. g :( hd0) (hd0, 1) (hd0, 8) (hd0, 7) and so on can have parameters: ls/list the files in the current root partition ls (hd0, 1)/List (hd0, 1) partition root directory file insmod --- load module normal --- enter normal mode (only when the module is correctly loaded can enter normal mode)
Because the SEARCH Command is available in rescue mode, we use the LS command to check the partition where the grub2 file is located.
    E. g: grub rescue> ls (hd0)/error: Unknown filesystem/* you can use this command to traverse all the devices displayed by ls one by one until the listed directory files, it indicates that grub2's core file is partitioned here */
I read a lot of posts. Well, I found that grub2 core (core. IMG) files are all in (hd0, 8) Partitions. I don't know if it is a coincidence (I am going to investigate this). Anyway, my files are also in (hd0, 8) this partition/* OK. for a small record, I used to partition windows and broke grub. This time the device list contains (hd0, 8) * Well, yes (hd0, 6) it seems a coincidence */
    Ls (hd0, 8) // * view (hd0, 8) the root directory of the partition. Check whether the root directory contains wood boot/folder */LS (hd0, 8) /boot // * view the/boot/directory file of this partition. The grub/folder */LS (hd0, 8) is displayed) /boot/gurb // * view the files in the/boot/GRUB/directory of this partition. files in mod format include. imgfile */
After determining where the grub2 core file is located, we will start the conversion:
    Grub rescue> set (Press ENTER)/* view the current start partition and path of grub */prefix = (hd0, 8)/GRUB/* determine the pre-start path */root = hd0, 8/* determine the boot partition */GRUB rescue> set root = hd0, 8/* set the grub boot partition */GRUB rescue> set prefix = (hd0, 8)/boot/GRUB
    /* Set the grub startup path */GRUB rescue> set (Press ENTER)/* check whether the grub settings are consistent with the actual partition path */root = hd0, 8/* determine the boot partition */prefix = (hd0, 8)/boot/GRUB/* determine the boot path */GRUB rescue> insmod/boot/GRUB/normal. MOD/* when checking the partition/boot/GRUB/directory file, check whether there is normal. MOD file. If there is a wooden file, the command will prompt that the file cannot be found */GRUB
    Rescue> normal/* load normal module */
/* After the above operations are successful, we will enter the normal mode to see the familiar grub Start Menu */normally, when we enter the grub Start Menu, you can directly choose to enter the system. Then update and recreate grub. However, some people may encounter this situation. Although the boot selection menu appears in normal mode, the system still cannot be entered because of the lack of Linux commands for loading the kernel, you cannot access the system directly from the menu. (Please go directly to the following operations, because I am a little confused ~ If you are eager to Solve the Problem) another situation is that you have updated the kernel, so there will be many boot items with different kernels like my boot menu, because my current version is Ubuntu 10.04 + win7, the default system startup Item is Ubuntu, so if I want to enter win7, I have to skip several kernel boot items, so it is more troublesome ~~~ Hand pain ~~ O (zookeeper) O... my solution is to comment out other ut kernel boot items in/boot/GRUB/grub. cfg. However, the problem is that once you update grub, other kernel images will be searched again, resulting in the so-long startup item selection menu. Some senior said that he could use commands to remove the old kernel image. However, I am still looking for this image. Wait until you know, and make up again ~~ Okay, let's go back to the normal mode to load the Linux kernel module. I want to load the specified kernel image for the old kernel image I mentioned above. Then you can use the following operations. If you cannot directly access the system, continue with the following operations: after entering the normal mode, a menu of familiar system startup items appears. Press C to enter the command line and then load the LINUX module.
    Normal grub> insomd/boot/GRUB/Linux. modnormal grub> set root = hd0, 8/* confirm normal start partition */normal grub> Linux/boot/vmlinuz-* root =/dev/sda8 (note: * Is a wildcard. You can use the tab key to view the specific kernel version image)
    /* Load the kernel and determine the/(Root) Partition */normal grub> initrd/boot/initrd. IMG-* (same as above)/* load initrd. IMG */normal grub> boot
After boot starts the system, open the terminal and execute the command to repair grub (it is recommended to log on as the root user or directly switch to the root user for convenience)
    Root @ Wuyun :~ # Update-grub/* update and reconstruct the grub. cfg grub configuration file */root @ Wuyun :~ # Grub-install/dev/SDA/* recreate grub to the first hard disk MBR */
Note: 1. the command grub-install/dev/SDA is to mount grub to the MBR of the first hard disk. If you want to mount the mbr of the second hard disk, change SDA to SDB, and the third and fourth are SDC and SDD, respectively. As for how to mount grub to the MBR of the hard disk, it depends on your actual situation. It mainly depends on which hard disk you want to set as the boot disk, the hard disk MBR to which the grub is mounted. 2. the partition code example (hd0, 8) can be used independently without brackets. The path must be enclosed with brackets. 3. since I didn't use/boot to separate partitions when installing Ubuntu 10.04, I just finished one/partition. If you use/boot to separate partitions, you should modify the path: prefix = (hd0, 8)/grubinsmod/GRUB/normal. modroot =/dev/sda8 also needs to modify the partition number with the partition. ubuntu grub rescue dual-system reinstallation windows causes grub2 to be rewritten and repaired
Grub4dos0.4.4 add grub4dos boot on the Windows startup Item (if you don't want to talk about it much, check the stick), restart it, select grub, and enter it in the command line (remove/boot from the separate partition of/BOOT)
Code: grub> Find -- Set-root/boot/GRUB/core. imggrub> kernel/boot/GRUB/core. imggrub> boot: Go to the grub2 menu, and then run the code: sudo grub-install/dev/sd? Ubuntu grub rescue method 2 after entering livecd repair reference: Sudo-imount your root partition/mntmount your/boot partition/mnt/boot # If yes # mount your other partitions, if yes # recreate the mbrgrub-install -- root-directory =/mnt/dev/SDA from grub to SDA

2: Ubuntu grub rescue cannot be started properly due to the uuid change in the root partition. It can only be repaired in grub rescue mode.

Grub rescue> set grub rescue> prefix = (HD ?,?) /GRUB grub rescue> root = HD ?,? Grub rescue> set root = HD ?,? Grub rescue> set prefix = (HD ?,?) /Boot/GRUB grub rescue> set grub rescue> root = HD ?,? Grub rescue> prefix = (HD ?,?) /Boot/GRUB grub rescue> insmod/boot/GRUB/normal. moD grub rescue> normal now you can call up/boot/GRUB/grub. CFG, change the uuid to grub> insmod/boot/GRUB/Linux under the command line. moD grub> set root = HD ?,? Grub> Linux/boot/vmlinuz-*** root =/dev/sd ?? Grub> initrd/boot/initrg. IMG-**** enter the system HD ?,? Is the partition where the grub file is located, SDA? Yes/partition.

3: repair when grub module and configuration file grub. cfg are damaged and cannot be started

Run livcd to start the trial reference: Sudo-imount your root partition/mntmount your/boot partition/mnt/boot # If yes # mount your other partitions, if yes # recreate grub to SDA's mbrgrub-install -- root-directory =/mnt/dev/SDA # recreate grub. volume mount -- bind/proc/mnt/proc Mount -- bind/dev/mnt/dev Mount -- bind/sys/mnt/sys chroot/mnt Update-grub umount/mnt/sys umount/ MNT/dev umount/mnt/proc

OK ~~ Now we have already made it. Enjoy your OS ~!

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.