Linux system startup process (3) One of the system fault repair

Source: Internet
Author: User

Linux system startup process (3) One of the system fault repair

in the use of Linux may cause a variety of reasons for the machine can not start, so there should be a response to these problems should be a measure to restore the system to let this work. Here are a few examples to illustrate each.

Case one:

destroys Grub's bootloader, and the first 446 bytes of disk storage for Grub's stage1 phase one.

#使用dd命令将前446字节的bootloader数据填充为0

[email protected] ~]# dd If=/dev/zero OF=/DEV/SDA bs=446 count=11+0 Records in1+0 records out446 bytes (446 B) copied, 0. 00247303 S, kb/s

#使用hexdump命令来查看磁盘前 + bytes

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/6A/wKiom1ffbCizrFfmAAAXbgV_toQ755.png "title=" Hexdump View Bootloader.png "alt=" Wkiom1ffbcizrffmaaaxbgv_toq755.png "/>

Note: Found that the first 446 bytes have been cleared, then restart the system will not process grub boot, it will not be able to enter the first phase of stage1. Enter the repair below.

#插入对应的linux version of the disc, boot from CD:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/6A/wKiom1ffbJ3glwd-AAAKHmHThOc530.png "title=" Booting from CD blos.png "alt=" Wkiom1ffbj3glwd-aaakhmhthoc530.png "/>

#按回车进入linux光盘系统引导菜单界面, select Rescue Mode rescue installed system  

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/67/wKioL1ffbEWgTnD9AAN_C7-CaNg999.png "title=" Rescue Rescue mode option. png "alt=" Wkiol1ffbewgtnd9aan_c7-cang999.png "/>

#选择完成后按回车进入救援模式, wait for the system to start, enter the language selection:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/6A/wKiom1ffbOvQWB8KAAARq8wawrQ945.png "title=" Select language. png "alt=" Wkiom1ffbovqwb8kaaarq8wawrq945.png "/>

Note: For command and character compatibility, it is best to select English, choose the right to enter directly or the following OK button to enter the line.

#然后进入键位部署界面.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/67/wKioL1ffbMaRDjZCAAAMvZy7TUs949.png "title=" Keyed deployment. png "alt=" Wkiol1ffbmardjzcaaamvzy7tus949.png "/>

Resolution: Here to choose their familiar configuration of the keys, most of the US American layout.

#选择后会出现是否设置网络, here for local, all options No is not set.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/6A/wKiom1ffbPniuE8zAAAIPg3Lwvg612.png "title=" Whether to set the network. png "alt=" wkiom1ffbpniue8zaaaipg3lwvg612.png "/>

#选择后进入真正的救援识别界面

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/67/wKioL1ffbRKDoD16AAAh8FoyvQs181.png "title=" Rescue1.png "alt=" Wkiol1ffbrkdod16aaah8foyvqs181.png "/>

parsing: The above information indicates that if you check the system on this machine and its internal partition table structure, and will mount the root partition to/mnt/sysimage as read-only, then prompt press continue to mount and continue. Continue here:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/87/67/wKioL1ffbSXyyhSrAAAR95bz1iE153.png "title=" Rescue2.png "alt=" Wkiol1ffbsxyyhsraaar95bz1ie153.png "/>

parsing: Because only the first 446 bytes of the broken ring, all can still recognize that there is a hard disk on this machine is the operating system. And will be prompted again to mount to the/mnt/sysimage directory. To return to the original system, you can use the chroot command to switch to the real root filesystem, command: Chrroot/mnt/sysimage, the following carriage will enter the next interface:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/6A/wKiom1ffbTqCMPqvAAAHQ6ZPjJM782.png "title=" Rescue3.png "alt=" Wkiom1ffbtqcmpqvaaahq6zpjjm782.png "/>

Description: Here is a description of a system that has been checked and mounted to the/mnt/sysimage directory.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/87/6A/wKiom1ffbUzAZ0qNAAAIFUJHtAA540.png "title=" Rescue4.png "alt=" Wkiom1ffbuzaz0qnaaaifujhtaa540.png "/>

Parse: Directly select shell option to enter the shell process provided by rescue mode.

#进入shell后, you can use the DF command to view the current file system mount situation:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/87/67/wKioL1ffbVqTEB1lAAAbr8q4Cz4240.png "title=" DF view partition. png "alt=" Wkiol1ffbvqteb1laaabr8q4cz4240.png "/>

Note: The partition of this disk is mounted to the/mnt/sysimage directory, as in the above hint.

Below is I install grub, which is a new installation using the Grub-install tool.

#安装之前 and finally want to switch to the real root

chroot/mnt/sysimage/

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/87/67/wKioL1ffbW_jggK8AAAK4KkuFZ0973.png "title=" Chroot switch to True root. png "alt=" Wkiol1ffbw_jggk8aaak4kkufz0973.png "/>

Note: This is found here Bash has turned into SH, and the view directory file is also the original system file .

#使用grub-install Command New GRUB Installation

Grub-install/dev/sda

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/6A/wKiom1ffbX_zdP0JAAAQPjNJ128869.png "title=" Install Grub.png "alt=" Wkiom1ffbx_zdp0jaaaqpjnj128869.png "/>

tip: If you suddenly get stuck without a message, don't use CTRL + Z send a stop signal, be sure to wait until this message appears to indicate that the installation was successful. otherwise naught.

#再次使用hexdump查看 whether the first 446 bytes of the/DEV/SDA disk have been fixed:

HEXDUMP-C-N 446-v/dev/sda

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/67/wKioL1ffbY7RI7m4AABTYZMTU4A973.png "title=" Hexdump See Bootloader.png "alt=" Wkiol1ffby7ri7m4aabtyzmtu4a973.png "/> again

#于是退出当前sh返回救援模式shell

Exit

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/87/6A/wKiom1ffbanSbIQrAAAB7k-jmCM793.png "title=" Exit current Sh.png "alt=" Wkiom1ffbansbiqraaab7k-jmcm793.png "/>

#此时直接输入reboot重启即可

Reboot

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/87/67/wKioL1ffbbiwyrUVAAAJnszOhCc085.png "title=" Reboot restart. png "alt=" Wkiol1ffbbiwyruvaaajnszohcc085.png "/>

Case TWO:

only destroys its stage1.5 and grub1.5 boot sections and restores

# also uses the dd command, which clears the data after the preceding bytes.

[[email protected] ~]# dd If=/dev/zero of=/dev/sda bs=512 count=2 seek=1 2+0 Records in2+0 Records out1024 bytes (1.0 kB) Copied, 0.00986278 S, 104 kb/s

# Use the hexdump command here to see the status of the first 1024 bytes of the current /dev/sda

[Email protected] ~]# hexdump-c-n 1024-s 512-v/DEV/SDA

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/6A/wKiom1ffbg-QQnMJAAAhLy2nDYs031.png "title=" After 512 bytes stage1_5.png "alt=" Wkiom1ffbg-qqnmjaaahly2ndys031.png "/>

parsing:The Grub tool also provides an interactive installation tool, however, this tool can only install stage1 and the first stage, but if the second stage file does not exist or the corresponding backup file is destroyed, then this the Grub command cannot be repaired, as the following validates this assertion.

#查看当 backup files under the/boot/grub/directory

[Email protected] ~]# ls/boot/grub/device.map fat_stage1_5 grub.conf jfs_stage1_5 minix_stage1_5 splash.xpm.gz Stage2 vstafs_stage1_5e2fs_stage1_5 ffs_stage1_5 iso9660_stage1_5 menu.lst reiserfs_stage1_5 stage1 Ufs2_sta Ge1_5 xfs_stage1_5

#移动所有1.5-stage Backup to move elsewhere

[Email protected] ~]# mv/boot/grub/*1_5/testdir/

#此时使用grub命令进入交互式安装

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/87/67/wKioL1ffbiyjks93AAA1D_mlQuA208.png "title=" Grub Interactive installation failed. png "alt=" Wkiol1ffbiyjks93aaa1d_mlqua208.png "/>

Parsing: Because the second stage of the file is not found, and the second stage of the disk is also emptied, all here, although the installation, but also only reinstall the first phase, and the second phase is not installed, the following view verification:

#查看/boot/grub whether a 1.5-stage backup file is currently generated

[Email protected] ~]# ls/boot/grub/device.map grub.conf menu.lst splash.xpm.gz stage1 stage2

Note: There is no backup file generated here, see if the second phase of the data in the disk is fixed.

#使用hexdump命令来查看磁盘第二阶段数据

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/6A/wKiom1ffbkWxYZ-vAABbNIGh180900.png "title=" Again after 512 bytes stage1_5.png "alt=" wkiom1ffbkwxyz-vaabbnigh180900.png "/> parsing: It has been verified that if 1.5 of the equipped files do not exist, The Grub Interactive installation is not able to generate 1.5-stage backup files, and restores only the first 446 bytes of bootloader and phase one.

#这时可以使用救援模式或者在重启系统前使用grub-install command for a full installation of grub

#直接进行完全安装

[Email protected] ~]# Grub-install--root-directory=//dev/sdainstallation finished. No Error reported. This was the contents of the device map//boot/grub/device.map.check if this was correct or not. If any of the lines is incorrect,fix it and re-run the script ' Grub-install '. # This device map is generated by Anaconda (hd0)/DEV/SDA

#再次查看gurb备份文件是否已经重新生成

[Email protected] ~]# ls/boot/grub/device.map fat_stage1_5 grub.conf jfs_stage1_5 minix_stage1_5 splash.xpm.gz Stage2 vstafs_stage1_5 e2fs_stage1_5 ffs_stage1_5 iso9660_stage1_5 menu.lst reiserfs_stage1_5 stage1 UFS2 _stage1_5 xfs_stage1_5

#使用hexdump命令查看1. Whether the 5 phase has been regenerated

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/87/67/wKioL1ffbn3gYdyxAADXoLwd6jc507.png "title=" After 512 bytes Stage1_5 is restored. png "alt=" Wkiol1ffbn3gydyxaadxolwd6jc507.png "/>

This article from "Meng Tian pa-it garbage Collection Station" blog, reproduced please contact the author!

Linux system startup process (3) One of the system fault 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.