Http://hi.baidu.com/realxfliu/blog/item/f6fe14e96463b83fb90e2d35.html
1. Use command lines to guide the Linux operating system
There is no difficulty in guiding the operating system process through the command line; it is nothing more than manually inputting the command to the back of the grub> prompt; in this process, the tab key command completion function is very important. If you do not know which commands are available, enter help;
1) Go to grub's command line mode grub>
If grub appearsGrub>It indicates that you do not have/etc/GRUB/menu. lst. You need to write a menu to select which system to access. If you have a GRUB menu, you can pressCTRL + cThe combination key enters the command line mode of grub, andGrub>Prompt;
grub>
2) get help for grub
If youGrub>Enter help at the end of the prompt to get all the grub command prompts;
grub> help
blocklist FILE boot
cat FILE chainloader [--force] FILE
clear color NORMAL [HIGHLIGHT]
configfile FILE device DRIVE DEVICE
displayapm displaymem
find FILENAME geometry DRIVE [CYLINDER HEAD SECTOR [
halt [--no-apm] help [--all] [PATTERN ...]
hide PARTITION initrd FILE [ARG ...]
kernel [--no-mem-option] [--type=TYPE] makeactive
map TO_DRIVE FROM_DRIVE md5crypt
module FILE [ARG ...] modulenounzip FILE [ARG ...]
pager [FLAG] partnew PART TYPE START LEN
parttype PART TYPE quit
reboot root [DEVICE [HDBIAS]]
rootnoverify [DEVICE [HDBIAS]] serial [--unit=UNIT] [--port=PORT] [--
setkey [TO_KEY FROM_KEY] setup [--prefix=DIR] [--stage2=STAGE2_
terminal [--dumb] [--no-echo] [--no-ed terminfo [--name=NAME --cursor-address
testvbe MODE unhide PARTITION
uppermem KBYTES vbeprobe [MODE]
If you need help with a certain command, enter a space behind the help and then enter the command, for example;
grub>help kernel
3) CAT usage;
The cat command is used to view the file content. Sometimes we do not know the Linux/boot partition and the location of the/root partition. We need to check the/etc/fstab content to find out, we need to use CAT (HD [0-n], Y)/etc/fstab to obtain the content. Be sure to use the tab command to complete the function;
Grub> CAT (press the tab key to display hd0 or hd1;
Grub> CAT (hd0, note: Enter hd0, and then press the tab key. partitions and the like are displayed;
Grub> CAT (hd0, 6)
Possible partitions are:
Partition num: 0, filesystem type unknown, partition type 0x7
Partition num: 4, filesystem type is fat, partition type 0xb
Partition num: 5, filesystem type is reiserfs, partition type 0x83
Partition num: 6, filesystem type is ext2fs, partition type 0x83
Partition num: 7, filesystem type unknown, partition type 0x83
Partition num: 8, filesystem type is reiserfs, partition type 0x83
Partition num: 9, filesystem type unknown, partition type 0x82
Grub> CAT (hd0, 6)/etc/fstab Note: for example, I want to check the content of (hd0, 6)/etc/fstab;
Label = // ext3 defaults 1 1
/Dev/devpts/dev/PTS devpts gid = 5, mode = 620 0 0
/Dev/SHM tmpfs defaults 0 0
/Dev/proc defaults 0 0
/Dev/sys sysfs defaults 0 0
Label = SWAP-hda1 swap defaults 0 0
/Dev/HDC/Media/cdrecorder auto pamconsole, exec, noauto,
Managed 0 0
Some may say that I don't know which partition Linux is installed in. You can always judge one attempt based on the file system; as long as you can cat out of/etc/fstab, it will be convenient for future guidance;
Check the content in/etc/fstab, mainly including Linux/partition and whether/boot is an independent partition. If there is no line similar to/boot, verify that/boot and Linux/are in the same hard disk partition. For example, label =/is very important in the above example. It indicates that the Linux system is in the partition labeled label =;
If your Linux system/boot and/are not in the same partition, CAT (HD [A-N], Y) may find something similar to the following;
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
4) run the root (HD [0-n, Y) command to specify the partition where/boot is located;
In fact, this root (HD [0, N], Y) can be omitted. If it is omitted, We need to specify it in the kerenl command. We have already said (HD [0-n], y) usage of the hard disk partition representation method; it is mainly used to specify the partition where/boot is located;
For example, we confirm/boot and (hd0, 6), so we can input root (hd0, 6)
grub> root (hd0,6)
If you find something wrong, you can try again;
5) The kernel command is used to specify the Linux kernel and the partition where/is located;
The kernel command may be a bit scary for beginners. I don't know which partition the kernel is in and what is the full name of the kernel file name. Do not forget the tab key command completion application;
If the/boot partition is specified through root (HD [0-n], Y), The syntax is as follows:
If/boot and Linux/are in the same partition, it should be in the following format;
Kernel/boot/vmlinuz press the tab key here to complete the kernel, and you will see the full kernel name Ro root =/dev/HD [A-Z] x
If/boot has its own independent partitions, it should be;
Kernel/vmlinuz press the tab key here to complete the kernel, and you will see the full name of the kernel Ro root =/dev/HD [A-Z] x
Here, root =/dev/HD [A-Z] X is the partition where the Linux/root is located. If you do not know which partition is located, use a tab to calculate it, try one by one; or use CAT (HD [0-n], Y)/etc/fstab to obtain the partition or partition label of Linux;
Grub> kernel/boot/press the tab key here to list the files in/boot;
Possible files are: grub initrd-2.6.11-1.1369_FC4.img system. Map-2.6.11-1.1369
_ FC4 config-2.6.11-1.1369_FC4 vmlinuz-2.6.11-1.1369_FC4 grubbak memtest86 +-1.55
. 1 xen-Syms xen.gz
Grub & gt; kernel/boot/vmlinuz-2.6.11-1.1369_FC4 Ro root = label =/
[Linux-bzimage, setup = 0x1e00, size = 0x18e473]
Note:Root = label =/is the label of the file system of the Linux/partition. If you know the specific partition of Linux, use root =/dev/HD [A-Z] X to specify the operation. For example, the following row is acceptable;
grub> kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/hda7
You can also delete the specified root (HD [0-n], Y) of the partition where/boot is located, and directly specify the partition where/boot is located in the kernel; so it is in the following syntax;
If it is a partition at the same root of/boot and Linux;
kernel (hd[0-n],y)/boot/vmlinuz ro root=/dev/hd[a-z]X
For example:
grub>kernel
If the root of/boot and Linux is not in a partition, yes;
kernel (hd[0-n],y)/vmlinuz ro root=/dev/hd[a-z]X
grub> kernel (hd0,6)/boot/vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/hda7
[Linux-bzImage, setup=0x1e00, size=0x18e473]
Or the following input is based on the content of CAT/etc/fstab;
grub> kernel (hd0,6)/boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/
[Linux-bzImage, setup=0x1e00, size=0x18e473]
6) The initrd command line is used to specify the initrd file;
Grub> initrd/boot/initrd tab here to complete;
Grub> initrd/boot/initrd-2.6.11-1.1369_FC4.img
[Linux-initrd @ 0x2e1000, 0x10e685 bytes]
If/boot is an independent partition, it should look like the following syntax; for example, the following;
Grub> initrd/initrd tab here to complete;
Grub> initrd/initrd-2.6.11-1.1369_FC4.img
[Linux-initrd @ 0x2e1000, 0x10e685 bytes]
7) boot system;
grub>boot
2. Use the grub command to guide windows;
In fact, we will write menu. lst. Apart from the title in menu. lst, there are all commands. If we start Windows, just enter the command;
For example, if the windows partition is in (hd0, 0), after we start the system, press Ctrl + C to enter the grub command mode.
grub> rootnoverify (hd0,0)
grub> chainloader +1
grub> boot
8) run the following command to repair GRUB:
Some good method on the Internet: http://blog.csdn.net/zhangqi187/article/details/6408762
In addition, if a similar environment is installed, you can refer to other machines to directly re-create a/boot/GRUB/grub. conf file, which should be noted in
[Root @ fs13 ~] # Cat/boot/GRUB/menu. lst
# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# Notice: you do not have a/boot partition. This means that
# All kernel and initrd paths are relative to/, eg.
# Root (hd0, 3)
# Kernel/boot/vmlinuz-version Ro root =/dev/sda4
# Initrd/boot/initrd-version.img
# Boot =/dev/SDA
Default = 0
Timeout = 0
Splashimage
= (Hd0, 3 )/Boot/GRUB/splash.xpm.gz
Hiddenmenu
Title fedora (3.2.11)
Root (hd0, 3)
Kernel/boot/vmlinuz-3.2.11 Ro root = UUID = 9f0c2d3e-65aa-4df7-adfc-2b89b89603b4 rhgb quiet
Initrd/boot/initrd-3.2.11.img
Title fedora (2.6.27.5-117. fc10.x86 _ 64)
Root (hd0, 3)
Kernel/boot/vmlinuz-2.6.27.5-117.fc10.x86_64 Ro root = UUID = 9f0c2d3e-65aa-4df7-adfc-2b89b89603b4
Rhgb quiet
Initrd/boot/initrd-2.6.27.5-117.fc10.x86_64.img
: (Hd0, 3) corresponds to the partition where boot is located on my own machine. This is determined by your machine. There are methods available on the Internet. In addition, root = UUID, you can see in the/etc/fstab file that nothing else has been done. After you get it done again, it will be OK.