Grub installation, configuration, and usage

Source: Internet
Author: User
(1) install grub during Linux installation. The installation guide will be prompted during RedHat Linux installation. Program If grub is selected as the boot program, it is recommended to install grub to the boot sector MBR. grub on the hard disk.
Other operating systems such as FreeBSD, NetBSD, OpenBSD, GNU Hurd, and DoS can also be guided, as well as Windows 95, 98, NT, 2000, and XP. (2) Once grub is selected as the boot program for grub configuration, let's take a look at its configuration. /boot/GRUB/grub. conf is a boot menu generated by grub and some options are set. below is my grub. conf: #=========== example start ============#grub. conf generated by Anaconda # note that you do not have to rerun grub after making changes to this file # notice: You have a/boot partition. this means that # All kernel and initrd paths are relative to/boot/, eg. # root (hd0, 6) # kernel/vmlinuz-version Ro root =/dev/hda10 # initrd/initrd-version.img # boot =/dev/hdadefault = 0 timeout = 10 splashimage = (hd0, 6) /GRUB/splash.xpm.gz # --> RedHat Linux 8.0 <-- title Red Hat Linux (2.4.18-14) Root (hd0, 6) kernel/vmlinuz-2.4.18-14 Ro root = label =/initrd/initrd-2.4.18-14.img # --> Microsoft Windows XP <-- title Microsoft Windows xprootnoverify (hd0, 0) chainloader + 1 #============ end of the example =========== configuration option explanation: the comment line starts. I have two operating systems, Red Hat Linux and Microsoft Windows XP. here, the timeout mark is the default wait time. I set it to 10 seconds. If you haven't made a choice for more than 10 seconds, the default Operating System will be automatically selected (my
The default value is RedHat Linux 8.0. The default Operating System is controlled by the default option. The number after the default option indicates that the first option is the default option. Here, 0 indicates the first option, 1 indicates the second one. institute
If you want to modify the default Operating System, modify the default number. title indicates the name of the operating system. Grub does not support Chinese characters (sorry ). splashimage specifies the background image of the grub interface. If you are interested, you can modify the grub background! Root (hd0, 6) identifies the boot kernel from the first hard disk and 7th partitions. Note that the root partition here is different from the root partition in Linux.
Root too! The hard disk Identification Method of grub is a little different from that of Linux. in Linux, the first primary partition is hda1, the second primary partition is hda1, and the first logical partition is
The partition is hda5, which is identified by (hdx, y) In grub. For example, the first primary partition is (hd0, 0) and the first logical partition is (hd0, 1) and so on. so here
Root is followed by the ID of the partition where your/boot is located. If you know where the kernel is, you must specify which file is the kernel file. This is the work of the kernel. Kernel/vmlinuz-2.2.18-14 Ro root = label =/. Description/boot/vmlinuz-2.2.18-14 is the kernel to be loaded. The following are all passed
Kernel parameters. RO means readonly. Note that the path before the kernel here is "/", because my boot is divided into one partition separately, if you do not
Boot is partitioned separately. The path before the kernel is "/Boot". initrd is used for the initial Linux image, and the corresponding parameters are set. Let's take a look at the definition section of windows. Here, I added an item to guide Windows XP. To complete this operation, grub uses the chainloader ). Chain Loader from Partition
(Hd0, 0. This is why this technology is called chain loading-it created
One chain from the boot loader to the other. This chain mount technology can be used to guide any version of DoS or windows. If you install
For Win98, winme, Win2k, and WINXP, chainloader directs the boot permission to win ntloader. (3) to create a boot disk for the grub boot disk, perform some simple steps. First, create an ext2 File System on the new floppy disk. Then, install it and add some grub files
Copy to the file system, and finally run the "Grub" program, which will be responsible for setting the Boot Sector of the floppy disk. Insert an empty disk into the 1.44 MB drive. Enter # mke2fs/dev/fd0 to create the ext2 file system. Then, you need to install the file system: # Mount/dev/fd0/mnt/Floppy now, you need to create some directories and copy some key files (these files have been installed before grub) to the floppy disk: # mkdir/mnt/floppy/boot/GRUB # cp/boot/GRUB/stage1/mnt/floppy/boot/GRUB # cp/boot/GRUB there is another step for/stage2/mnt/floppy/boot/grub, you can obtain available boot disks. In Linux bash, running "Grub" from the root user is very interesting and worth noting because it is actually a semi-functional GRUB boot loader.
Version. Although Linux is started and running, you can still run grub and execute some tasks, and its interface is similar to using GRUB boot disk or
The interface (that is, the grub console) displayed when you install the hard disk MBR is exactly the same. At the grub> prompt, enter grub> root (fd0) grub> setup (fd0) grub> quit. Now, the boot disk is complete. (4 ). recover grub damaged by windows. if you use grub to guide Linux and Windows, the grub in MBR will be damaged after Windows is re-installed due to a problem. In this case, you need to restore grub.1. put the first Linux installation disc into the optical drive, then restart the machine and use the optical drive to boot the system in Bois. 2. After the installation interface is installed, press the [F4] key, that is, the Linux rescue mode. 3. A series of keyboards and a few simple preparations, and then [continue... This process is simple. 4. then the prompt sh #5 appears. we can operate grub. enter GRUB: Sh # grub and a prompt will appear: grub> we can enter grub> root (hdx, Y) grub> setup (hd0) after such a character) if it succeeds, there will be a successful ...... here, if X is a disk, It is 0. If the root partition of the Linux you install is on the second hard disk, X is 1; y is where the Linux system is installed.
. Setup (hd0) is to write grub to the hard disk MBR. (5 ). use ntloader to guide Linux. if you do not choose to install grub when installing Linux, don't worry. Now let's take a look at how to install grub after installing Linux. and use Windows ntloader to guide linux.1. install grub I use grub is redhat8.0 With grub installation package: grub-0.92-7.rpm installation: rpm-IVH grub-0.92-7.rpm other installation method is the same, you only need to install grub. grub used by rh8 by default. Steps 1 and 2 can be saved. 2. create grub environment CP/usr/share/GRUB/i386-pc/*/boot/GRUB 3. generate the grub configuration file/boot/GRUB/menu. conf follows the grub. conf to generate a configuration file. note: Here, my Linux is in/dev/hda4, so menu. the conf partition locations are (hd0, 3 ), You may be different. You can't just draw a picture! The partition location in the Next Step install should also be consistent with your system. 3. install grub to LINUX partition boot and install stage1 of grub to the Boot Sector (hd0, 3) of/dev/hda4 ). the process is as follows:/sbin/GRUB (run grub) grub> install (hd0, 3)/boot/GRUB/stage1 D (hd0, 3) (hd0, 3) /boot/GRUB/stage2 P (hd0, 3)/boot/GRUB/menu. conf (Note: The above "Grub>" is the grub prompt, and the post content is written in a line .) 4. the process of obtaining GRUB boot information is as follows: dd If =/dev/hda4 of =/grub. lnx BS = 512 COUNT = 1 to get the grub boot information, as long as you use nt loader to load it. 5. set the grub. lnx can get grub in the Windows C root directory first. lnx gets a floppy disk, starts Windows, and copies it to C:; in this case, you can also directly copy it to C: in Linux. my c drive
(Device/dev/hda1) is FAT32, which can be obtained directly from Linux. mount-T vfat/dev/hda1/mnt/c cp/grub. lnx/mnt/C umount/mnt/C 6. modify the boot of NT loader. INI adds a line: C: grub. lnx = "RedHat Linux-Grub" after being added, boot. INI: [boot loader] timeout = 15 default = C: boot. lnx [operating systems] multi (0) disk (0) RDISK (0) Partition (1) windows = "Microsoft Windows XP Professional"/fastdetect [VGA mode] "/basevideo/sos c: grub. lnx = "RedHat Linux-Grub" OK. you can use nt loader to load Linux. In fact, the above process is basically the same as loading lilo with NT loader. the basic idea is to use nt Loader
To load the boot area (grub. lnx). The key is to obtain the boot zone of LILO or grub. (6) using grub's interactive function grub has powerful interactive functions. learning will benefit you a lot! 1. What should I do if grub does not display a menu? After the instance is started, the grub interface is displayed but there is no menu. There is only one grub> prompt. How can this problem be started? Run grub> CAT (hd0, 6)/boot/GRUB/grub. conf (to see the parameters) grub> root (hd0, 6) grub> kernel (hd0, 6)/vmlinuz-2.4.18-14 Ro root = label =/GRUB> initrd (hd0, 6) /initrd-2.4.18-14.imggrub> bootok! Start it! The preceding numbers must be changed based on your actual situation. the above method can also be used to test the newly compiled kernel. 2. enter the single-user mode. sometimes you accidentally forget the root user password. You can only enter the single user mode to reset the root password. the method is as follows:

Start the instance and enter the grub interface. Press C to enter the command line mode, and then follow the preceding method. The single parameter must be added later in step 3.

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.