Repair of grub menu damage in two systems

Source: Internet
Author: User
The repair method for the grub menu damage of the dual system is to merge the edisk and the F disk this afternoon. after restarting the computer, it is found that it cannot enter the system, either vista or fedora, which is extremely depressing. After google, the following grub command is used to solve the problem: 1: grub & gt; root (hd0, 0) 2: grub & gt; make... the repair method for the grub menu damage of the dual system is to merge the edisk and the F disk this afternoon. after restarting the computer, it is found that it cannot enter the system, either vista or fedora, which is extremely depressing. Google: 1: grub> root (hd0, 0) 2: grub> makeactive // can be added without adding 3: grub> chainloader + 1 4: grub> boot www.2cto.com suddenly felt that grub was very powerful and had the urge to study it, so google again. The Grub mentioned here is different from the Grub for DOS mentioned above. the Grub mentioned above has nothing to do with the first sector of the disk. that is to say, if you delete the grub directory in disk C, it will not affect your system startup. The Grub I will talk about below will write some code to the first sector of the disk, that is, it will be written to the master boot record MBR. Www.2cto.com
1 Grub code is divided into two parts: one part is written to the master boot record MBR of the first sector, and the other part is located in a fixed position on the disk.
2 Grub working process. After the computer starts, BOIS first performs self-check and other work. then BOIS loads the first sector (512 bytes) of the disk to a certain place in the memory, and then jumps to this place to execute the code, this code is the part of the above-mentioned Grub written into MBR. this code contains the location information of the second part of Grub on the disk. this code loads the second part based on this information, the second part is the core of Grub, and the second part reads/boot/grub. conf configuration file, and then
The user interface is displayed based on this configuration file. the menu options you see are like this. of course, you can press the keys 'C' to enter the command line interface.
3 As mentioned above, the information of each operating system on your machine is written into the configuration file grub. conf. if your configuration file is incorrect, grub certainly cannot find the OS you want to start. you need to start it manually at this time. For example, if you format a disk (or another reason) in Windows, the beautiful grub interface disappears after the machine is restarted, leaving only a strange prompt "grub>, you can use commands to start your operating system.
Start Windows: 1: grub> root (hd0, 0) 2: grub> chainloader + 1 3: grub> boot start Fedora Core2 from the command line (assuming mounted on/dev/hda7): 1: grub> kernel (hd0, 6) /boot/vmlinuz-2.6.5-1.385.img root =/dev/hda7 2: grub> initrd (hd0, 6)/boot/initrd-2.6.5-1.385.img 3: grub> boot or: 1: root (hd0, 6) 2: kernel/vmlinuz-2.6.26.5-28.fc8 ro root =/dev/VolGroup00/LogVol00 rhgb quiet 3: initrd/initrd-2.6.26.5-28.fc8.img 4: boot note: vmlinu for different systems Z and initrd are different. please fill in according to the actual system. The following describes the commands one by one.
1st-line command: specify the partition where/boot is located.
If you do not know where your/boot partition is, it doesn't matter. first enter root (hd0, and then press the Tab key. it will display possible partitions, then, determine the/boot partition based on the partition type. So the Tab key is a very useful key in linux. Specifying the/boot partition here is not required. if it is omitted here, it should be specified in the kernel and initrd, namely: kernel (hd0, 2)/vmlinuz-2.6 ...... and initrd (hd0, 2)/initrd-2.6 ......
"Hd0, 2" refers to the third partition of the first hard disk, which is a primary partition. There are two partition representation methods in linux: one is pure digital representation like "hd0, 2", which starts with "hd0, 0, it indicates the first partition of the first hard disk, and the second hard disk is HD1. Another type is hda1, which also indicates the first partition of the first hard disk, and the second hard disk is hdb. The two representations are used in different scenarios. the pure numeric notation is generally used to specify/boot partitions in grub. The second method is the notation used in daily use and hard disk mounting. For primary partition and extended partition, here is a little bit: Extended partition is from hdx5, hdx, 4, where x represents the hard disk number. To learn more about linux's partition notation, Google it.
2nd-line command: specify the kernel image and root partition.
Enter the kernel/vmlinuz and press the Tab key to complete the full kernel image name. after completing the kernel, you can see that my fedora kernel image is a vmlinuz-2.6.26.5-28.fc8. If there is more than one kernel, it will be displayed for you to choose from (this case has been encountered, from 8 to 9, my boot menu has two images ). In addition, my/boot partition is not in the root partition, but an independent partition. if the/boot partition is not an independent partition, but in the root partition, write as follows: kernel/boot/vmlinuz-2.6.26.5-28.fc8 ro root =/dev/VolGroup00/LogVol00 rhgb quiet, the following initrd should be written as: initrd/boot/initrd-2.6.26.5-28.fc8.img. The part after the image is used to specify the root partition, which must be manually entered. Ro means read only, root =/dev/VolGroup00/LogVol00 indicates the root partition location, rhgb indicates the graphical startup process, and quiet means not to display the startup information. In practice, I found that the part after the kernel image is not necessary. that is to say, even if this part is not input, the root partition is not specified, and the graphic startup process is not specified, the startup information is not omitted and can be correctly started. Do I have to specify a root partition? is it related to my system being a single kernel?
This line of command should be understood more. First, in vmlinuz, vm refers to vritual memery, and linuz refers to the compressed kernel image. Also, the root in this command line does not mean the root in the first command line. The root in the first command line refers to the boot partition of the system, that is, the/boot partition. the root in the second command line refers to the root partition of the system, that is, the/partition. To fully understand the differences between the two, it involves the linux file system and directory structure. it is one of the key concepts in linux. I will find time to write something about it, let's talk about my understanding of it. "Root =" The Following "/dev/VolGroup00/LogVol00" is the location of the root partition. does it look strange? Because my root partition is not a common hard disk partition, but a logical volume, the term is LVM (logical volume manager ). This is also a very important thing in linux. LVM should be understood based on the linux hard disk partition and directory structure, so we won't talk about it here, otherwise it will get farther and farther away from the subject.
3rd-line command: specify initrd. img
Initrd is initial ramdisk, which literally initializes a RAM disk. It is actually a temporary file system and is bound with the kernel. It is generally used to load required system files, drivers, and storage devices. it is immediately released after the system is started. It is said that it is a permanent system without other storage devices. I don't know much about it, nor can I write more. In short, initrd. img is a temporary file system bound with the kernel to load required system files.
4th-line command: start the system. Enter boot and press enter to start the system.
After the system is started, think about the manual start process. if you know grub, it is not complicated to manually start the system. The Start menu is like a script written based on the content we manually enter. This "script" does not require manual input every time you start the system. Therefore, this "script" is very useful. let's write it manually.
If you understand the linux directory structure, you will know that the boot menu is in the grub folder under the boot folder of the root partition. The grub folder also contains menu. lst, which is the link file of grub. conf. You may have a question: isn't your/boot partition an independent partition, not in the root partition? In fact, this is one of the differences between linux and windows. it is related to the root partition through mounting, which involves the file system and directory structure. Find and open the grub folder and create a grub. conf folder. you need the root permission!
How to write grub. conf? Similar to the command entered above. Below is the content of grub. conf of fedora in my virtual machine:

Note text is added with the # sign, which is ignored at startup. The core part is as follows:
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/grub/splash.xpm.gz
# Hiddenmenu title Fedora (2.6.26.5-28. fc8)
Root (hd0, 0)
Kernel/vmlinuz-2.6.26.5-28.fc8 ro root =/dev/VolGroup00/LogVol00 rhgb quiet
Initrd/initrd-2.6.26.5-28.fc8.img
The first line indicates the default system. 0 indicates that the first system is started by default in the order in grub. if it is changed to 1, the second system is started by default. And so on. The second line, timeout, indicates that the menu wait time is 5 seconds. You can set the time to wait for the menu. The third line is the splashimage item, indicating the background image displayed at startup. If you do not want the image to be displayed, you can add the # sign in front to ignore it. Row 4: hiddenmenu, indicating to hide the selected menu, and adding the # sign indicates not to hide the selected menu. If you have installed a dual system and do not want it to appear in the selection menu, you can remove the # sign in front of it. The fifth line, title item. select the system title displayed on the menu. The following does not need to be explained...
Write another boot menu like grub. conf. Note that the/boot partition in my computer is (hd0, 2), and the others are completely copied. Put it in/boot/grub, and you can start fedora normally. However, I installed xp and fedora on my computer. although I can start fedora normally under the boot menu, I still need to manually enter xp. You also need to add a part at the end of the startup menu:
Title windows xp
Rootnoverify (hd0, 0) # in my computer, the XP system is placed in the first partition.
Chainloader + 1
If you want the XP system to start by default, change the default item to 1. The boot menu of this part of xp uses a chain loader, and you don't have to care what it means. just copy it.
Now a new menu is ready!
This diary is barely written. On the one hand, I am not particularly familiar with grub and cannot perform more in-depth mining. on the other hand, this diary involves many knowledge about linux file systems, directory structures, and hard disk partitions. I want to talk about this point of knowledge, otherwise it will be difficult to read, and I cannot talk too much, otherwise it will deviate from the subject. However, in any case, starting fedora with the command line is okay... starting Debian from the command line is similar to starting Fedora Core2.
Note: If you adjust the partition size through the partition software, the ghost knows what the result will be. I have never tried it. Theoretically, you have finished it, because the address information in the first part of Grub about the second part is invalid, and the Grub core cannot be loaded!
4. you can use the same method to start the system in the future. if you feel uncomfortable and want a menu, modify your/boot/grub. conf file. Now the machine is running.
Related Article

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.