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://s4.51cto.com/wyfs02/M00/7E/88/wKioL1cDoInCsDbBAAA2pumlWso381.png "title=" Grub command line interface. png "alt=" Wkiol1cdoincsdbbaaa2pumlwso381.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/8B/wKiom1cDn-_iJ5InAABKwuTw-sg827.png "title=" Command Window Cmd.png "alt=" Wkiom1cdn-_ij5inaabkwutw-sg827.png "/>
Grub command-line interface:
Help: Get assistance list
Help KEYWORD: More information
Find (hd#,#)/path/to/somefile: Finding Files
root (hd#,#)
kernel/path/to/kernel_file: Set the kernel file used in this boot, and add many cmdline parameters which the kernel supports.
Example: Init=/path/to/init, selinux=0
initrd/path/to/initramfs_file: Set the RAMDisk to provide additional files for the selected kernel;
Boot : booting the 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/88/wKioL1cDoOfw9jfhAAZb1R6BgMM023.gif "title=" download. gif "alt=" Wkiol1cdoofw9jfhaazb1r6bgmm023.gif "/>
Grub configuration file
Configuration file:/boot/grub/grub.conf
Configuration items:
default=#: Sets the default Start menu item, the menu item (title) number starting from 0;
timeout=#: Specifies the length of time the menu item waits for an option to be selected;
splashimage= indicates the menu background picture path (hd#,#)/path/to/xpm_pic_file)
hiddenmenu: Hide menu;
password [–md5] STRING: Menu Editor authentication;
Title Title : Define the menu item "title", can appear multiple times;
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 may take a long time.
/dev/mapper/vg_centos6-lv_root does not have 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://s2.51cto.com/wyfs02/M01/7E/88/wKioL1cDoSiT73xYAANZ-SKbn-Q406.gif "title=" Single user. gif "alt=" Wkiol1cdosit73xyaanz-skbn-q406.gif "/>
Rescue mode
Grub Repair
1. Simulated damage: (Back up before destruction)
if=/dev/sda of=/root/mbr.bak count=1 bs=512
if=/dev/zero of=/dev/sda count=1 bs=200
2. Enter Rescue mode
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7E/8B/wKiom1cDoLqQgn33AAZ7L6xCErQ037.png "title=" Rescue Mode method 1.png "alt=" Wkiom1cdolqqgn33aaz7l6xcerq037.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
# grub-install --root-directory=/ /dev/sda
# exit
# reboot
8. Remove the disc before restarting
Graphic:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/8B/wKiom1cDoOSz-gL_AAUFNyL1MZM269.gif "title=" Grub menu. gif "alt=" Wkiom1cdoosz-gl_aaufnyl1mzm269.gif "/>
This article is from the "University Bully" blog, please be sure to keep this source http://xinzong.blog.51cto.com/10018904/1760625
Linux GRUB Legacy