System and Kernel repair are you really going to do that?

Source: Internet
Author: User

One, boot under the configuration file description

Icon:

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/87/30/wKiom1fWvB6hV1ucAAAeBCPGa6Q752.png "title="%) [YCN $~) bz3b%duy0e{4) i.png "alt=" Wkiom1fwvb6hv1ucaaaebcpga6q752.png "/>


Description

1) config-version-release #配置文件

2) Vmlinuz-version-release #虚拟内核核心文件

3) Initramfs-version-release #辅助伪文件系统

4) Grub #主引导配置目录


Demonstrate:

Fix Initramfs file after deleting Initramfs

1) Enter ESC in rescue mode when the system restarts.

2) cutting root, use the MKINITRD command to generate the initramfs-version-release.img configuration file

Chroot/mnt/sysimage

/boot/initramfs-' uname-r '. img ' uname-r '

Exit reboot


Icon:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/87/30/wKiom1fWvpiiFEV0AAAnM8Auceo054.png "title=" 3py$ 3owu}58tg3@7 (ojsu~w.png "alt=" Wkiom1fwvpiifev0aaanm8auceo054.png "/>



II,/boot/grub/ grub.conf configuration file and its boot menu, selected boot kernel encryption  

# 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/sda2#          initrd /initrd-[generic-] Version.img#boot=/dev/sdadefault=0timeout=5splashimage= (hd0,0)/grub/splash.xpm.gzhiddenmenutitle centos  6  (2.6.32-642.el6.x86_64) root  (hd0,0) kernel /vmlinuz-2.6.32-642.el6.x86_64 ro  Root=uuid=240533cf-b37F-4460-974f-702bab867da5 nomodeset rd_no_luks  keyboardtype=pc keytable=us rd_no _md crashkernel=auto lang=zh_cn. Utf-8 rd_no_lvm rd_no_dm rhgb quietinitrd /initramfs-2.6.32-642.el6.x86_64.img

Default=0 #默认启动的菜单项, default number is 0

Timeout=3 #启动系统后菜单项等待选择超时时间

Splashimage= (hd0,0)/grub/splash.xpm.gz #菜单图片

Hiddenmenue #影藏菜单

Password--md5 string #启动菜单选项时的密码      

Title #菜单标题

Root (hd0,0) #grub查找stage2及其kernel内核文件所在设备分区, root for Grub

Kernel/vmlinuz-version-release ro root=/dev/sda2 #启动的内核

Initrd/initramfs-version-relase.img #辅助的伪文件系统ramfs文件为其加速

Password--md5 string #启动选定内核时需输入的密码


Icon:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/30/wKiom1fWw3HityDWAABqiLo5HMo092.png "title=" w8$ ( B5e}ku}f2[i (yhlpyrk.png "alt=" Wkiom1fww3hitydwaabqilo5hmo092.png "/>

The Start menu option and its single-user mode are required to enter the password:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/2E/wKioL1fWxVbjnMeyAAAWyJU3awE875.png "title="}[ Pwg0v_4k[%qnh_ge13[_v.png "alt=" Wkiol1fwxvbjnmeyaaawyju3awe875.png "/>



Experimental one: Destruction of Stage1 and stage1_5 repair methods and analysis of the explanation:

Stage1 Destruction

DD If=/dev/zero OF=/DEV/SDA bs=1 count=446 #前446字节为boot Loader

stage1.5 Destruction

DD If=/dev/zero OF=/DEV/SDA bs=512 count=2 seek=1


Repair method:

Grub-install/dev/sda


Experiment two: Delete the boot directory and its repair

1) Delete the/boot directory and Repair

Rm-rf/boot

2) CD-ROM boot, enter rescue mode, install kernel kernel package

rpm-ivh/mnt/sysimage/mnt/cdrom/packages/kernel-version-release.rpm--root=/mnt/sysimage--force|--replacepkgs

3) Install grub and manually restore the/boot/grub/grub.conf configuration file

Chroot/mnt/sysimage

Grub-install/dev/sda

Vim/boot/grub/grub.conf

Default=0

Timeout=3

Title=alrenlinux

Root (hd0,0)

Kernel/vmlinuz-version-release Root=/dev/sda2

Initrd/initrd-version-release


Icon:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/31/wKioL1fXdU-Tm4TIAABQUl3e4ls828.png "title=" U ({@ 169a$ (vtkhyl]{ttu$j.png "alt=" Wkiol1fxdu-tm4tiaabqul3e4ls828.png "/>



Experiment Three: Remove the/boot and/etc/fstab, restore the

1) Delete boot directory and/etc/fstab two file

Rm-rf/boot/etc/fstab

2) disc boot similar to the above steps, enter rescue rescue mode

3) Check the root,

Blkid; fdisk-l

4) Mount the root to a specified directory

Mkdir/mnt/sda2 Mount/dev/sda2/mnt/sda2

5) Mount the boot directory and its root to the/etc/fstab for automatic mount

Vi/mnt/sda2/etc/fstab

/dev/sda1/boot EXT4 Defaults 1 1

/DEV/SDA2/EXT4 Defaults 1 2

6) Restart the machine

Reboot


After the steps and the appeal fix delete the boot directory exactly as simple as described below:

1) CD-ROM boot, enter rescue mode, mount CD, install kernel

Mkdir/mnt/cdrom Mount/dev/cdrom/mnt/cdrom

rpm-ivh/mnt/cdrom/packages/kernel-version-release.rpm--replacepkgs |--force

2) fixed several stages of grub and grub configuration files, if found cannot be repaired, can be repaired using input setup in Grub

Grub-install/dev/sda

Grub>root (hd0,0)

Grub>setup (hd0)

3) Edit the grub.conf configuration file

Default=0

Timeout=3

Title Alrenlinux

Root (hd0,0)

Kernel/vmlinuz-version-release Root=/dev/sda2

Initrd/initramfs-version-release


Icon:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/34/wKioL1fXttqwCxEyAABLqtNnWRQ291.png "title=" Auwcl90x%9_2b{0o]]ky%oe.png "alt=" Wkiol1fxttqwcxeyaablqtnnwrq291.png "/>


Experiment Four:  Remove the Vmlinuz-version-release core file and its initramfs-version-release.img in the boot directory for repair.

1) Enter Rescue mode rescue

2) Mount the disc and copy the Vmlinuz into the/boot directory

3) generate the Initramfs file and use the MKINITRD command to generate

mkinitrd/boot/initramfs-' uname-r '. img ' uname-r '

4) Configure the/boot/grub/grub.conf configuration file to remove the Vmlinuz version number

5) Restart






This article from the small ear original, appeal some experiments too simple repetition no longer every step of the demonstration, practice more hands quickly become big God Bar:)








This article is from the "Small Ears" blog, please be sure to keep this source http://purify.blog.51cto.com/10572011/1852335

System and Kernel repair are you really going to do that?

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.