GRUB Guide for Linux system management

Source: Internet
Author: User
This article was originally written by myself, and some of the content was extracted to linuxsir.org. due to my limited level, some places may not be very accurate. I hope you can communicate with each other and give me some advice. **************************************** * Body ********************************... this article was originally written by myself, and some of the content was extracted to linuxsir.org. due to my limited level, some places may not be very accurate. I hope you can communicate with each other and give me some advice. **************************************** * Body ************************************** *** What is GRUB?Gnu grub is a multi-operating system startup manager. Gnu grub is derived from GRUB (GRand uniied Bootloader. GRUB was initially designed and applied by Erich Stefan Boleyn. The system boot guide manager is the first program to run after the computer is started. it is used to load and transmit control to the operating system kernel, once the kernel is mounted, the task of the system boot manager exits, and other components of the system boot, such as the system initialization and startup process, are completely controlled by the kernel; GRUB configuration file in LinuxThe configuration file of grub is located in/boot/grub. conf. its content is as follows. # 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, 0)
# Kernel/vmlinuz-version ro root =/dev/VolGroup00/LogVol00
# Initrd-version.img/initrd
# Boot =/dev/sda
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/grub/splash.xpm.gz
Hiddenmenu
Title Red Hat Enterprise Linux Server (2.6.18-164. el5)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18-164.el5 ro root =/dev/VolGroup00/LogVol00 rhgb quiet
Initrd/initrd-2.6.18-164.el5.img # The comments line will not explain more. Default = 0 // The default started kernel or the default started operating system. 0 indicates the first kernel or operating system, the first title is 0, the second is 1, in turn) timeout = 5 // Default timeout time, which is defined as 5 seconds. if not selected, by default, the first kernel or the first operating system splashimage = (hd0, 0)/grub/splash.xpm.gz // specifies the grub background image, the first program that must be run to run the system. Therefore, the file system that comes with the system has not been mounted. Fortunately, grub can directly access disk files, the hard disks recognized by grub are not the same as those of linux systems. grub believes that all disks are hd, while the system does not. So here is (hd0, 0), the first 0 represents the first hard disk, and the second 0 represents the first partition. To reference a disk device, enclose it in parentheses. Hiddenmenu // hide the grub menu. if this item exists, we cannot see the grub menu, but only the grub background image, then a please any key to enter the menu is displayed, and Booting is under it. In ... This way. You can press any key to go to the grub menu. If there are multiple kernels, we can choose which one to start. It is the English content under the grub menu. I believe you can understand it as well. I won't say much about it. By editing the grub menu, we can directly enter single-user mode and change the password. If you forget your password, try this method. Title Red Hat Enterprise Linux Server (2.6.18-164. el5) // This is the title, which is the content displayed on the Grub menu. the kernel following the title keyword can be written at will. to facilitate identification, we recommend that you write a text description of the operating system or kernel. Root (hd0, 0) // Set hd0, 0 as the root directory for convenient access. set the start point for file access. The root set here is the root of grub. Kernel/vmlinuz-2.6.18-164.el5 ro root =/dev/VolGroup00/LogVol00 rhgb quiet // specify the kernel file, followed by the root behind the kernel, where the root directory of the operating system is. rhgb is a redhat tool that displays various output information, including hardware initialization. quit indicates silent mode and no output information. when the system is started, it gets stuck and the redhat is displayed because the output information of the rhgb applet is not displayed. initrd/initrd-2.6.18-164.el5.img // you can think of this as a driver, the system just boot, Grub first start, to mount the file system, it is necessary to read the driver from the file system, if the driver is okay in the kernel, if it is not in the kernel, then not ...... Therefore, this can be considered as a driver. In fact, he is a tiny linux system, which only contains the driver and no other files. You can run the command ". gz" first, decompress it, and then use cpio to decompress it. The directory structure is the same as that of your linux system, except that there are no files and only drivers. As mentioned earlier, you can change the password here, which is very insecure. That is to say, if someone else can access our physical server, he can directly change the password of our system. Therefore, we can add a password to grub. it can be implemented using the keyword password followed by the password, but such a password is plaintext and insecure, so we can use password -- md5 to encrypt it through grub's md5 encryption tool, and then write it to the end of password -- md5. Grub md5 encryption tool is a grub-md5-crypt, directly use this command, output password, and then generate a MD5 encrypted value, written to the key word after the md5 encryption grub can be achieved. The encryption effect varies depending on the write location. we can write a title to encrypt the specified kernel or operating system. when this kernel or system is started, the user is required to enter the grub password. When compiling the grub menu, you need to enter the password when writing it out of all the titles. at this time, press p to enter the password, and then press e to edit the password. Install GRUB manuallyYou can install grub in two ways. Next I will go to the detailed introduction. if some points are not accurate, I hope you can advise that TKS can first use the grub-install command for installation, the specific method is grub-install -- root-directory =/to which directory to install/the device to be installed example: I will use a virtual machine to demonstrate how to add a new disk, then partition and format (this operation is not demonstrated), mount the file, and then run the command to install the file, as shown in figure Note: The Mount point must be the boot directory, but it may not be/mnt. However, the last mounted directory name is "boot". otherwise, problems may occur. During installation, -- root-directory = must not be specified to the boot directory. you must specify the directory where the boot is located, because grub will find the boot directory during installation. if it cannot be found, an error is reported. After we mount the disk to boot, we can think that the name of the disk is boot. Therefore, it will write bootloader into the disk to guide the system, if we specify boot during installation, we will write the content of bootloader to the file instead of the hard disk MBR. Remember. I did not make this mistake many times.After the installation is complete, create a new virtual machine. when creating a disk, use an existing disk, find the disk that we have installed grub, and then use it. After the machine is started, you will be pleasantly surprised to find that the grub prompt appears. The second method (a bit of trouble): first copy all the files in/usr/share/grub/i386-redhat/to the grub Directory. note: the same as above, be sure to mount it to the boot directory. no matter where the boot directory is and start grub installation, run the grubroot (hd2, 0) command directly) it indicates that grub is to be installed on the third hard disk in the third partition. setup (hd2) specifies the device to be installed. the device is the second hard disk. after the installation is complete, the quit command will exit, as for images, I will not be able to. it is absolutely acceptable. This article is from "why ?? Ghost blog

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.