Linux command: Grub file in detail and grub repair, system common failure repair

Source: Internet
Author: User
Tags crypt parent directory uuid

First simulate grub corruption, DD If=/dev/zero OF=/DEV/SDA count=1 bs=400

Grub boot corruption, but does not restart at this time, you can reinstall grub directly to restore GRUB:

The first method:

1. First enter grub into GRUB command line

[[email protected] networking]# Grub

Probing devices to guess BIOS drives. This could take a long time.

GNU GRUB version 0.97 (640K lower/3072k Upper memory)

[Minimal Bash-like line editing is supported. For the first word, TAB

Lists possible command completions. Anywhere Else TAB lists the possible

Completions of a device/filename.]

Grub>root (hd0,0) to define the partition where the kernel resides

Root (hd0,0)

Filesystem type is EXT2FS, partition type 0x83

grub> Setup (hd0) directly with Setup, Setup (hd0) is installed directly on the hd0 first boot drive

Setup (hd0)

Checking if "/boot/grub/stage1" exists ... no

Checking if "/grub/stage1" exists ... yes

Checking if "/grub/stage2" exists ... yes

Checking if "/grub/e2fs_stage1_5" exists ... yes

Running "Embed/grub/e2fs_stage1_5 (hd0)" ... Sectors is embedded.

Succeeded

Running "Install/grub/stage1 (hd0) (hd0) 1+27 P (hd0,0)/grub/stage2/grub/grub.conf" ... succeeded

Done.

Grub> quit and quit .

Quit

The second method:

#grub-install--root-directory=/path/to/boot Parent Directory/DEV/SDA Specifies the parent directory of/boot and the current hard drive device



1, cat/etc/grub.conf the configuration file when the/boot/grub link file:

# grub.conf generated by Anaconda

#

# Note that you don't have the to rerun grub after making changes to the This file

# notice:you has a/boot partition. This means

# all kernel and INITRD paths is relative to/boot/, eg.

# root (hd0,0)

# kernel/vmlinuz-version RO root=/dev/sda2

# initrd/initrd-[generic-]version.img

#boot =/DEV/SDA

Default=0 # Sets the title number of the default startup, starting at 0 and sorting from top to bottom.

Timeout=5 # waits for the user to select the timeout length, in seconds

Splashimage= (hd0,0)/grub/linux.xpm.gz # grub Background Image

Hiddenmenu # hidden Menu

Password--md5 $1$7yzf4/$Bo. 1rg8dzncimfomud6ed0 # makes it necessary to enter maintenance mode with a password

Title CentOS (2.6.32-431.el6.i686) # kernel header or operating system name, string, can be freely modified

Root (hd0,0) # kernel files are located on the device, for grub, all types of hard drives are HD;

the format is (hd#,n); hd#, #表示第几个磁盘, the last 0 indicates the partition of the corresponding disk

kernel/vmlinuz-2.6.32-431.el6.i686 ro root=uuid=47b74772-4295-493a-8aa6-8fc85ae0807d Rd_NO_LUKS KEYBOARDTYPE=pc Keytable=us rd_no_md Crashkernel=auto lang=zh_cn. UTF-8 RD_NO_LVM rd_no_dm rhgb quiet # Kernel file path/boot directory, and parameters passed to the kernel

Initrd/initramfs-2.6.32-431.el6.i686.img # RAMDisk file path in/boot directory


Encrypt to Grub: Grub-md5-crypt generates an encrypted string


[Email protected] ~]# Grub-md5-crypt

Password:

Retype Password:

$1$5vig4/$xqmsVS. 9l2m99szyacfeb/ Copy the encrypted string

Then modify the grub.conf file, vim/boot/grub/grub.conf

# grub.conf generated by Anaconda

#

# Note that you don't have the to rerun grub after making changes to the This file

# notice:you has a/boot partition. This means

# all kernel and INITRD paths is relative to/boot/, eg.

# root (hd0,0)

# kernel/vmlinuz-version RO root=/dev/sda2

# initrd/initrd-[generic-]version.img

#boot =/DEV/SDA

Default=0

Timeout=6

Splashimage= (hd0,0)/grub/splash.xpm.gz

Hiddenmenu

password--md5 $1$5vig4/$xqmsVS. 9l2m99szyacfeb/Add an encrypted password

Title My CentOS6.5 (2.6.32-431.el6.i686)

Root (hd0,0)

kernel/vmlinuz-2.6.32-431.el6.i686 ro root=uuid=47b74772-4295-493a-8aa6-8fc85ae0807d rd_NO _LUKS KEYBOARDTYPE=pc KEY Table=us rd_no_md Crashkernel=auto lang=zh_cn. UTF-8 RD_NO_LVM RD_NO_DM RH GB Quiet

Initrd/initramfs-2.6.32-431.el6.i686.img


2, the pure character interface resolution adjustment:

grep "Config_framebuffer_console"/boot/config-2.6.32-279.e16.i686

Query whether the kernel supports resolution modification

Modify the grub.conf configuration file to achieve the adjustment resolution

Vim/boot/grub/grub.conf

Default=0

....

Kernel/... quiet vga=791 This string is a command to modify the resolution


3. System Repair Mode

1, power on by E or P key into the selection kernel and then press E quiet 1 and then press the B key, you can enter the single-user maintenance mode

2. Common bug fixes in single-user mode

1), root password reset

2), modify the system default operating level Vim/etc/inittab


4. Disc Repair mode

First boot from CD, select rescue installed system repair, go to the repair interface:

bash-4.1# important system files are missing, causing the system to fail to boot, the disc repair steps are as follows:

Suppose the system file is missing the/etc/inittab file

bash-4.1# chroot/mnt/sysimage temporarily set the disc root directory to the system root directory

# Cd/root

# rpm-qf/etc/inittab query under/etc/inittab file belongs to that installation package

# Mkdir/mnt/cdrom set up mount point

# Mount/dev/sr0/mnt/cdrom Mount Disc

bash-4.1#rpm2cpio/mnt/cdrom/packages/initscripts-8.45.3-l.i386.rpm |

Cpio-idv./etc/inittab Extract the Inittab file to the current directory .

BASH-4.1#CP./etc/inittab/etc/inittab Copy the Inittab file to the specified location


5. Linux Security

User password-->grub password-->bios Encryption--Lock it up

There are different unlocking methods for various types of security:

user password is lost, reset by single user mode, grub password can be reset by disc Repair mode

The BIOS password can be removed by dialing out the motherboard battery, locked up and the lock is removed by direct violence.


* when booting into the grub interface but there is no menu, only the workaround for the grub> prompt is left:

grub>cat/boot/grub/grub.conf Viewing parameters for grub.conf configuration files

Grub>root (hd0,0)

GRUB>KERNL (hd0,0)/vmlinuz-2.6.32-431.el6.i686

GRUB>INITRD (hd0,0)/initramfs-2.6.32-431.el6.i686.img

Grub>boot Restart





This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1880342

Linux command: Grub file in detail and grub repair, system common failure repair

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.