Grub command to guide Linux

Source: Internet
Author: User

I'm curious about the Linux system and want to play on the machine. I spent one night busy yesterday and finally installed Linux. But it was a little too early. I thought it was as simple as entering Linux. I didn't think it was as easy as popping up a pilot command (grub) To Let me guide, I saw it numb. Not at all. There is no way I can't help it. I just shut down and went to bed. At noon today, I went online to check information. Familiarize yourself with the relevant commands. However, it is quite difficult. I tried it several times but it still didn't work. I did not get it. I was about to give up. I didn't think of inspiration in the afternoon. Just press a few commands.

This installation has taught me a lot. The following describes how to guide Linux under grub;

The procedure is as follows;

A enters the grub command mode.

B. Get familiar with some grub commands.

C. Get familiar with Cat commands.

D root command to specify the partition where/boot is located

E kernel command to specify the Linux kernel and partition

F use the initrd command to specify the initrd File

G boot System

Cat command 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 (hd0 or hd1 is displayed by pressing the tab key;
grub> CAT (hd0, note: Enter hd0, and then press the tab key;
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 (hd0, 6) enter the/etc/fstab content in this way.

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

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 ext3 defaults 1 2

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;

Eg:

Grub> root (hd0, 0)

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 & gt; kernel (hd0, 0)/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, 0)/boot/vmlinuz-2.6.11-1.1369_FC4 Ro root = label =/
[Linux-bzimage, setup = 0x1e00, size = 0x18e473]


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]


Boot System;

Grub> boot The following is a command on my machine:

Grub> CAT (hd0, 0)/etc/fstab
# This file is edited by fstab-sync-see 'man fstab-sync' for details
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

Grub> root (hd0, 0)
Filesystem type is ext2fs, partition type 0x83

Grub> kernel/boot/Click tab to complete the list of all/boot files;
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
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]

Grub> initrd/boot/Click tab here to complete
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> initrd/boot/initrd-2.6.11-1.1369_FC4.imgNote: Enter the full name of the intrd file name;
[Linux-initrd @ 0x2e1000, 0x10e685 bytes]

Grub> bootThere are so many of the above, you have to learn more

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.