Simulate grub corruption and loss

Source: Internet
Author: User

PS: Red font is an important part, look carefully


The purpose of this experiment: in the work, will inevitably encounter grub damage, now to simulate the grub damage repair process.

One, the first stage repair MBR sector fault;

1. We use an order to simulate the first 446 bytes of the MBR by overriding the previous method .

[[email protected] ~]# dd If=/dev/zero OF=/DEV/SDA bs=446 count=1

if= file name: Enter a file name, default to standard input. The source file is specified.

of= file name: Output file name, default is standard output. That is, the specified destination file.

Ibs=bytes: Reads a bytes byte at a time, which specifies a block size of bytes bytes.

Bs=bytes: Set the read-in/output block size to bytes file at the same time.

Count=blocks: Copies only blocks blocks, the block size equals the number of bytes specified by IBS.

[[Email protected] ~]# Init 6 #重启完后进不了系统

2. Mount the system CD and enter rescue mode;

①. Enter the BIOS, locate the boot option, and adjust the CD-ROM to the first system entry;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ tpb0m3hjkmx5u4zplbty5mi84c3plsgd.fz5svxgp0i!/o/dbaexoedpwaa&ek=1&kp=1&pt=0&bo=dwleaxcc3gedacu! &su=189948641&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:631px;height:478px; "/>

②. Select Rescue installed system to enter rescue mode;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ pxni1vozhjikxx8bzmsrqivknczyguhzbvm8j.0ckze!/o/dfjuvebfjqaa&ek=1&kp=1&pt=0&bo=0gh2anib9gadacu! &su=152540529&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:466px;height:246px; "/>

③. Select the language. By default, press the TAB key to move to the OK option;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ aedfgqe9y66jol16x5k1ocwyf7soxg.zmzbvdczmths!/o/dhzjt.eipwaa&ek=1&kp=1&pt=0&bo=xwe6av8bogedacu! &su=19508721&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:351px;height:314px; "/>

④. Select the keyboard, by default, press the TAB key to move to the OK option;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/v10q22pw1ksj6l/slgm2eh3z9* auixg39.4y4hm3fbyhpkcigk3imq*xjm!/o/dknlj.arjqaa&ek=1&kp=1&pt=0&bo=wqemavkbjgedacu!&su= 1108321857&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:345px;height:294px; "/>

⑤. Because we put in the local disc, so here also keep the default, press the TAB key to move to the OK option;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ gfh0.3ws61ifedtqlonvrgqnzmyd2n2xzhevkfbeyva!/o/dk*okuapjqaa&ek=1&kp=1&pt=0&bo=vahralwb6wadacu! &su=120839345&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:444px;height:235px; "/>

⑥. According to their actual needs whether the network, I choose No, press the TAB key to move to the OK option;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/v10q22pw1ksj6l/yhfbgsuu.r5cw.vfrbdcfrl* puqbvh9xihhlm5bgeni!/o/dg31uueipwaa&ek=1&kp=1&pt=0&bo=yggzagibswadacu!&su=1257454849& Sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:top; width:354px;height:179px; "/>

⑦. Select default to mount the rescue environment to/mnt/sysimage by default, and press the TAB key to move to the OK option;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ v2hdampkeqoy8adk1r358df9mxpjcya3sg6gfr6hqz4!/o/dc8rt.a*jqaa&ek=1&kp=1&pt=0&bo=jqjzasucwqedacu! &su=130439841&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:549px;height:345px; "/>

⑧. Select Enter mode, here I choose Shell mode, press the TAB key to move the OK option;

650) this.width=650; "alt=" Picture "src=" http://a3.qpic.cn/psb?/V10q22PW1KsJ6L/ deqdpc2qrxkv9p4h9ovwrucvwr8hizgjm4jlftpb06q!/b/dcr*wuegpqaa&ek=1&kp=1&pt=0&bo=lgebaqaaaaadakg! &su=033573217&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:406px;height:283px; "/>

⑨. Enter the root environment to install grub;

bash-4.1# chroot/mnt/sysimage #进入到root环境

sh-4.1# GRUB-INSTALL/DEV/SDA #安装grub到第一块硬盘

sh-4.1# exit

⑩. Eject the disc, restart the operating system, you can enter the system;

bash-4.1# reboot #重启操作系统

650) this.width=650; "alt=" Picture "src=" http://a2.qpic.cn/psb?/v10q22pw1ksj6l/xgmem1husnsnzab* 2royzzn9irdq56pbol63txzpp0i!/b/djxjvebcjqaa&ek=1&kp=1&pt=0&bo=agklaaaaaaadak4!&su= 0224825601&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:514px;height:139px; "/>



Two, the second stage simulation/etc/grub.conf lost;

1. Delete the grub.conf configuration file;

[Email protected] ~]# rm-rf/boot/grub/grub.conf #删除grub. conf configuration file

Question: Many people will ask what does not delete/etc/grub.conf, after I guess/boot/grub/grub.conf do soft connection to/ect/grub.conf, so say delete/etc/grub.conf after the system will go to/boot/ Find grub.conf file under Grub directory;

[email protected] ~]# Init 6 #重启操作系统

2. After booting, unable to enter the system, will prompt grub> words;

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ fvrmqal86dm8bu0d3otn9z04713jawgvvtp7qzjmkb0!/o/dokkioadjqaa&ek=1&kp=1&pt=0&bo=vwkmal8cjaadacu! &su=1160649393&sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none ; vertical-align:top;width:703px;height:140px; "/>

3. Set GRUB root device as the Linux kernel partition, because my/boot partition is installed in the first partition of the first block, so set to (hd0,0), note that there is no IDC hard disk and SCSI hard disk;

Suppose you do not know the location of the/boot partition containing the boot file such as the kernel file, you can try it by typing "root hd0" and then pressing the TAB key, where the 0x83 are all partitions that are/root partitions, (0x82 's swap partition, Then you don't have to try it.

650) this.width=650; "alt=" Picture "src=" http://a1.qpic.cn/psb?/v10q22pw1ksj6l/bwzqcfuk2xfai*yd. sw3ai04vixfuv.jrzlnzrylqgg!/b/dbcrieaxjqaa&ek=1&kp=1&pt=0&bo=1wklaqaaaaadaho!&su=024904625 &sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align: top;width:727px;height:395px; "/>

grub> Root (hd0,1)

4. After the completion of the kernel file, you also need to set the kernel load permission to read-only RO, and specify the location of the root partition settings file through "root=";

grub> kernel/vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/sda2

5. Load the kernel image file

grub> initrd/initramfs-2.6.32-358.el6.x86_64.img #可以按tab键补全

6. Boot System

grub> Boot

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ cio2e4knv0vc2siestyzmyse6vtlzsnzbtr9pnco40w!/o/djuqxoekpwaa&ek=1&kp=1&pt=0&bo=2aiwadgcmaedacu! &su=1132858001&sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none ; vertical-align:top;width:728px;height:304px; "/>

Explanation: The selected partition is not correct, power off continues. Repeat the above actions.

grub> Root (hd0,1)

grub> kernel/vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/volgroup-lv_root #因为我的是LVM卷.

grub> initrd/initramfs-2.6.32-358.el6.x86_64.img #可以按tab键补全

grub> Boot

7. Write the grub.conf file, or you will enter the grub> mode next time;

[Email protected] ~]# vim/boot/grub/grub.conf #编辑grub. conf Configuration file

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ vmy4lckheabhwjocyzccawxvbe1hzprpzqdoj0fesuk!/o/dhzst.ewpwaa&ek=1&kp=1&pt=0&bo=lwexapcbfwidacu! &su=178313441&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:407px;height:535px; "/>

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ is4vgvfxf1o3sjpbbniucwhgjoiwxbq3aqppq*y*34i!/o/dgqcweewpwaa&ek=1&kp=1&pt=0&bo=1wkoanccjgadacu! &su=1163873841&sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none ; vertical-align:top;width:727px;height:142px; "/>

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/v10q22pw1ksj6l/s7vauwm*odujatq* o0nro7olaaty1q0hicrjvnjksm4!/o/dlp1wobvjqaa&ek=1&kp=1&pt=0&bo=ygkyacocmaedacu!&su= 151625121&sce=0-12-12&rf=2-9 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; vertical-align:top;width:714px;height:408px; "/>

[Email protected] ~]#CAT/BOOT/GRUB/GRUB.COF
Default=0 #默认启动第一个引导
Timeout=5 #在菜单到启动系统停留时间, 5 seconds.
Title kernel-2.6.32 #启动项目名称
Root (hd0,1) #boot所在位置
kernel/vmlinuz-2.6.32-358.el6.x86_64 ro root=/uuid= "51e646df-c73b-4d07-a639-ba010bc02e4d" TYPE= "Ext4" #内核版本及目标位置
Initrd/initramfs-2.6.32-358.el6.x86_64.img #加载内核文件路径

[[Email protected] ~]# Init 6 #重启系统

650) this.width=650; "alt=" Picture "src=" http://r.photo.store.qq.com/psb?/V10q22PW1KsJ6L/ nay87m4foouwkq5iqg.wzreb3bazs2uetiual14ta2o!/o/dabmt.evpwaa&ek=1&kp=1&pt=0&bo=uqj2abkcdgedacu! &su=1258647729&sce=0-12-12&rf=2-9 "style=" Margin:0px;padding:0px;border-width:0px;border-style:none ; vertical-align:top;width:697px;height:374px; "/>


This article is from the Chen. "Blog, be sure to keep this provenance http://chenxiaojian.blog.51cto.com/9345444/1619924

Simulate grub corruption and loss

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.