"What is GRUB?"
gnu GRUB (abbreviation " GRUB ") is one from the GNU Project boot loader multi-boot specification implementation, It allows users to have multiple operating systems at the same time on the computer and select the operating system that they want to run when the computer starts. Grub can be used to select different cores on the operating system partition
"Features of Grub"
1, provide the menu, and provide interactive interface; Start screen hit the e key: Enter the editing mode;
2, select the kernel or system to boot ( allow to pass the boot parameters to the kernel, select the interface can be hidden);
3, for the editing function to provide protection mechanism.
Enable kernel File Protection: Select run the specified kernel to enter the password first
Pass-through parameter protection: use the e command to enter the password first
"The composition of Grub"
[[Email protected] grub]# ll total 275-rw-r--r--. 1 root root 63 Mar 16 14:12 device.map #grub的对应设备文件,-rw-r--r--. 1 root root 13392 Mar 16 14:12 e2fs_stage1_5 #e2fs文件系统定义文件 ;-rw-r--r--. 1 root root 12632 mar 16 14:12 fat_stage1_5- Rw-r--r--.  1 ROOT ROOT  11760 MAR 16 14:12 FFS_STAGE1_5-RW------- . 1 root root 1137 may 6 20:15 grub.conf # Grub configuration file;-rw-r--r--. 1 root root 11768 mar 16 14:12 iso9660_ Stage1_5-rw-r--r--. 1 root root 13280 mar 16 14:12 jfs_stage1_ 5lrwxrwxrwx. 1 root root 11 mar 16 14:12 Menu.lst -> ./grub.conf -rw-r--r--. 1 root root 11968 mar 16 14:12 minix_stage1_5-rw-r--r-- . 1 root root 14424 mar 16 14:12 reiserfs_stage1_5-rw-r--r--. 1 root root 1341 nov 14 2010 splash.xpm.gz # Background image of the Grub interface at boot time;-rw-r--r--. 1 root root 512 mar 16 14:12 stage1 -rw-r--r--. 1 root root 126108 Mar 16 14:12 Stage2-rw-r--r--. 1 root root 12036 mar 16 14:12 ufs2_stage1_5- Rw-r--r--. 1 root root 11376 mar 16 14:12 vstafs_stage1_5- Rw-r--r--. 1 root root 13976 mar 16 14:12 xfs_stage1_5
Stage1: This is an image file to boot grub (must have). Typically, this file is a partition that is loaded into the MBR or boot sector. Since the size of the boot sector of the PC is 512 bytes, the image file must be compiled after 512 bytes. The whole work of Stage1 is to load the Stage 2 or stage 1.5 from a local disk. Due to the stage1 size, it encodes stage 2 or stage 1.5 in the form of a sub-program, so the stage1 is not able to recognize any file system
stage1_5: The subsequent sector of the MBR, which acts as a bridge between Stage1 and Stage2, that is, Stage1 loads stage1.5, then stage1.5 loads stage2. The difference between Stage1 and stage1.5 is that the former is not recognized by any file system, but the latter identifies the file system (e.g. ' e2fs_stage1_5 ' recognition ext2fs). So you can safely move the stage2 location, even after grub is installed.
stage2: used to read the grub.conf configuration file and to implement the boot function extension.
"Grub configuration file Grub.conf"
[[email protected] grub]# cat grub.conf# 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/mapper/vg_centos6-lv_root# initrd /initrd-[generic-]version.img#boot=/ dev/sdadefault=1 #选择第几个title配置的内核或系统, each title starting from 0 numbered;timeout=5 #菜单显示的超时时长; splashimage= (hd0,0)/grub/ splash.xpm.gz #指定菜单的背景图片; This picture can only beFor 14bits color, xpm format, gzip compression;hiddenmenu #隐藏菜单, press any key before timout to display the menu, otherwise the menu;title centos (3.19.6) is not displayed. #显示于菜单中的标题;root (hd0,0) #指定boot分区所在磁盘及分区kernel /vmlinuz-3.19.6 ro root=/dev/ Mapper/vg_centos6-lv_root rd_no_luks lang=en_us. Utf-8 rd_lvm_lv=vg_centos6/lv_swap rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_centos6/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet #指定内核的绝对路径, mount the root file system in read-only mode, the root partition location, and other related parameters;initrd /initramfs-3.19.6.img #指定initramfs文件的绝对路径 ;
Note:
1. In Grub all hard drives are recognized as HD and different hard drives are based on digital IDs: such as hd0 (for the first hard drive), HD1 (second hard drive), different partitions on the same hard drive, and digital identification, such as hd0,0 (first partition on the first hard drive);
2, because GRUB does not recognize the physical volume (PV), of course, root cannot be placed on the logical volume (LV), so root is generally separate partition and must be a basic disk partition.
"Grub Command Line interface"
Starting mode: start interface, knock C enter
Root (DEVICE): Specifies which partition is the partition of the system or kernel file that you want to start next
Example: Root (hd0,0)
Kernel: Specify the kernel file to run
INITRD: Specify the available RAMDisk files for the kernel to be run
Boot: Start a previously configured kernel or system
Find (DEVICE)/path/to/file finds whether the specified file is on a partition and supports command completion
Example: Find (hd0,0)/vmlinuz-2.6.32-431.el6.i686
Note: The GRUB command line interface supports command line completion, in which the system must be pre-aware of the device on which the root resides.
650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/6C/85/wKioL1VLLd-hDbKjAAF2HWjaAeI712.jpg " Title= "Grub.png" alt= "Wkiol1vlld-hdbkjaaf2hwjaaei712.jpg"/>
"Grub Protection mechanism Configuration"
Path: By modifying the grub configuration file, typically/boot/grub/grub.conf
1. Generate Password:
[[email protected] ~]# grub-md5-crypt #通过md5算法来生成密码; Password: #键入预要设置的密码; retype Password: #确认密码; $1$j99te$ c7vwrcdafb1grvqi5.e0l. #用md5算法生成的密码;
2, to protect the editing function, you need to add outside the title:password--md5 password string;
#----Slightly---#boot =/dev/sdadefault=1timeout=5splashimage= (hd0,0)/grub/splash.xpm.gzhiddenmenupassword--md5 $1$J99TE $c 7vwrcdafb1grvqi5.e0l. #设置编辑功能保护title CentOS (3.19.6) root (hd0,0) #----Slightly---
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/85/wKioL1VLMi_Bi5GkAAEe6t_aRfQ004.jpg "title=" 11.png "alt=" Wkiol1vlmi_bi5gkaaee6t_arfq004.jpg "/>
The effect is as follows: Prompt us to enter the editing interface, you must first press the ' P ' key and then type the correct password.
3, protect the use of a kernel, you need to add the kernel corresponding to the title:password--md5 password string
#----Slightly---#boot =/dev/sdadefault=1timeout=5splashimage= (hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (3.19.6) Password--md5 $1$j99te$c7vwrcdafb1grvqi5.e0l. #设置保护CentOS (3.19.6) the kernel; root (hd0,0) #----Slightly---
"How to Install Grub":
1. Using the Grub-install command
# Grub-install [--root-directory=dir] DEVICE
The path specified by--root-directory= must be the parent directory of the mount point of the partition where the kernel and INITRD files reside, and this mount point must be called the boot
For example: The/DEV/SDB1 partition on the/DEV/SDB contains kernel and initrd files, and grub is now required on the SDB.
[[Email protected] ~] #mount/dev/sdb1/mnt/boot[[email protected] ~] #grub-install--root-directory=/mnt/dev/sdb
This article is from the "Flying Snail" blog, please be sure to keep this source http://ljmsky.blog.51cto.com/2878/1643981
Linux OS boot manager-grub