Linux GRUB
Linux GRUB
Single-user mode (password cracking)
Rescue mode
Instance
Grub Menu
Grub Command Line interface
About GRUB
GRUB Menu Composition
Grub configuration file
Grub Installation and Repair
Grub Single User and rescue mode
About GRUB
Before you know grub, you need to understand the startup process of Linux, and if you don't know about the Linux boot process before, see: http://xinzong.blog.51cto.com/10018904/1757337
The GRUB (GRand Unified Bootloader) Unified boot loader, which is the boot loader. The grub on CentOS is divided into two versions, namely:
CentOS 7 Default with GRUB2
Grub Legacy (Grub 0.1 is generally called GRUB1)
GRUB 2 (grub1.0 commonly referred to as GRUB2)
This article mainly introduces the Grub legacy.
Grub Menu composed of Grub menu
Before you introduce the menu, take a look at Grub legacy
The Grub legacy is divided into three stages:
Stage 1:MBR
The STAGE1_5:MBR after the function is to allow the bootloader in Stage1 to identify the filesystem on the Stage2 partition
Stage2: Disk partition ()/boot/grub/)
Stage2 and kernels are typically placed on a basic disk partition.
The function of Stage2:
1, provide the menu, and provide interactive interface
E: Edit mode, for editing menus
C: Command mode, interactive interface
2. Load the user-selected kernel or operating system
Allow parameters to be passed to the kernel
To hide this menu
3, for the menu provides a protection mechanism
Certification for the Edit menu
Kernel or operating system not enabled for authentication
Grub Command Line interface
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7E/81/wKiom1cCZqLjyOW8AAA2pumlWso907.png "title=" Grub command line interface. png "alt=" Wkiom1cczqljyow8aaa2pumlwso907.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7E/81/wKiom1cCZumxJk6jAABKwuTw-sg005.png "title=" Command Window Cmd.png "alt=" Wkiom1cczumxjk6jaabkwutw-sg005.png "/>
Grub command-line interface:
help : Get help list
help KEYWORD : detailed help information
find (hd#,#)/path/to/somefile : Find Files
root (hd#,#)
kernel/ Path/to/kernel_file : Set the kernel file used for this boot, and add many cmdline parameters that are supported by the kernel;
For example: Init=/path/to/init, selinux= 0
boot: boot boot selected kernel;
to start the system manually on the GRUB command line interface:
grub> Root (hd#,#)
grub> kernel/vmlinuz-version-release ro Root=/dev/device
Grub> initrd/initramfs-version-release.img
grub> Boot
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/7E/7D/wKioL1cCZ_vymuLXAAZb1R6BgMM983.gif "title=" download. gif "alt=" Wkiol1ccz_vymulxaazb1r6bgmm983.gif "/>
Grub configuration file
Configuration file:/boot/grub/grub.conf
Configuration items:
default =# : Set the default Start menu item, menu item (title) number starting from 0,
timeout=# : Specifies the length of the menu item Wait option selection,
splashimage= indicates the menu background picture path (hd#,#)/path/to/xpm_ Pic_file)
hiddenmenu: hide menu;
password [–md5] STRING: Menu edit authentication;
title title: defines the menu item "title", which can occur more than once;
Root (hd#,#):grub finds the device partition where the Stage2 and kernel files are located; "root" for grub;
kernel: booting the kernel
initrd kernel-matched Ramfs files;
password [–md5] STRING: authenticates when the selected kernel or operating system is started;
Encrypted passwords can be used:
Grub-md5-crypt command
Grub Installation and Repair
Instance
Note: –root-directory must specify the top level directory where boot is located
#mount/dev/sdb1/mnt/boot
#grub-install--root-directory=/mnt/dev/sdb2
Probing devices to guess BIOS drives. This could take a long time.
/dev/mapper/vg_centos6-lv_root does not has any corresponding BIOS drive.
# ls/mnt/boot/
Grub
# ls/mnt/boot/grub/
Device.map ffs_stage1_5 minix_stage1_5 stage2 xfs_stage1_5
E2fs_stage1_5 iso9660_stage1_5 reiserfs_stage1_5 ufs2_stage1_5
Fat_stage1_5 jfs_stage1_5 stage1 vstafs_stage1_5
# Grub
Probing devices to guess BIOS drives. This could take a long time.
GNU GRUB Version0.97(640K Lower/3072K Upper Memory)
[Minimal Bash-like line editing is supported. For the first word, TAB
Lists possibleCommandCompletions. AnywhereElseTAB Lists the possible
Completions of a device/filename.]
Grub> Root (HD1,0)
Root (HD1,0)
Filesystemtypeis EXT2FS, partitiontype 0x83
grub> Setup (HD1)
Setup (HD1)
Checkingif "/boot/grub/stage1"Exists ... no
Checkingif "/grub/stage1"Exists ... yes
Checkingif "/grub/stage2"Exists ... yes
Checkingif "/grub/e2fs_stage1_5"Exists ... yes
Running"Embed/grub/e2fs_stage1_5 (HD1)"... -Sectors is embedded.
Succeeded
Running"Install/grub/stage1 (HD1) (HD1) 1+27 P (hd1,0)/grub/stage2/grub/grub.conf"... succeeded
Done.
Grub Single user and rescue mode single user mode (password cracking)
Enter single-user mode:
(1) Edit the Grub menu (select the title to edit, then use the e command);
(2) attach after selected kernel
1, S, s or single can be;
(3) In the kernel line, type "b" command;
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7E/7D/wKioL1cCaF6zRyrkAANZ-SKbn-Q808.gif "title=" Single user. gif "alt=" Wkiol1ccaf6zryrkaanz-skbn-q808.gif "/>
Rescue mode
Grub Repair
1. Simulated damage: (Back up before destruction)
dd if=/dev/sda of=/root/mbr.bak count=1 bs=512
dd if=/dev/zero of=/dev/sda count=1 bs=200
2. Enter Rescue mode
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7E/81/wKiom1cCaLLAcuY2AAZ7L6xCErQ918.png "title=" Rescue Mode method 1.png "alt=" Wkiom1ccallacuy2aaz7l6xcerq918.png "/>
1. Insert disc into rescue mode
-Mode 1: Click Rescue Installed System
Mode 2: Press ESC to enter the command line
Enter Linux Rescue
2. Select language, keyboard type
3. Choose whether to use the language
4, whether to mount the current system with the/mnt/sysimage
Continue: Continue
5. Select OK # to use Chroot/mnt/sysimage
6. Select shell Start Shell
7. Toggle with, Fix grub
# chroot/mnt/sysimage
Span class= "hljs-comment" style= "Line-height:1.6;color:rgb (117,113,94);" ># grub-install--root-directory=//dev/sda
# exit
# reboot
8. Remove the disc before restarting
Graphic:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/81/wKiom1cCaWHzcnPNAAUFNyL1MZM506.gif "title=" Grub menu. gif "alt=" Wkiom1ccawhzcnpnaaufnyl1mzm506.gif "/>
This article is from the "University Bully" blog, please be sure to keep this source http://xinzong.blog.51cto.com/10018904/1760214
Linux GRUB Legacy