CentOS 6 mistakenly deleted boot partition how to restore recovery

Source: Internet
Author: User
Tags ssh centos ssh secure shell

CentOS 6 mistakenly deleted boot partition how to restore recovery

In the CentOS 6 system, is it possible to recover a deleted boot partition if the boot partition is removed because of carelessness or error? In fact, it is possible, the following with small series to understand the next bar.

1. First use CENTOS6 mirroring into the Linux rescue rescue mode.

2. Start the sshd service, view the IP address that eth0 obtains, and then connect with SSH Secure shell.

SSH Secure Shell 3.2.9 (build 283)

Copyright (c) 2000-2003 SSH Communications Security corp-http://www.ssh.com/

This copy of the SSH Secure Shell is a non-commercial version.

This version does does not include a PKI and a PKCS #11 functionality.

[Root@localhost ~]# cd/boot/Enter/boot partition

[root@localhost boot]# LS//View the contents of the boot partition

config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gz

Grub system.map-2.6.32-71.el6.i686

Initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686

[Root@localhost boot]# CD ... Back to Upper Directory

[root@localhost/]# rm-rf/boot/*//Delete all contents of/boot partition

[Root@localhost/]# ls/boot//View/boot partition content is empty

[Root@localhost/]# mount/dev/sr0/mnt//Mount cdrom device to/mnt directory

Mount:block Device/dev/sr0 is write-protected, mounting read-only

[Root@localhost/]# rpm-ivh/mnt/packages/kernel-2.6.32-71.el6.i686.rpm--root=/--force//installation CD kernel package

Preparing ... ########################################### [100%]

1:kernel ########################################### [100%]

[Root@localhost/]# ls/boot//view/boot partition contents

config-2.6.32-71.el6.i686 system.map-2.6.32-71.el6.i686

Initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686

Symvers-2.6.32-71.el6.i686.gz

[Root@localhost/]# mkdir/boot/grub//creates a new grub directory in the/boot directory

[Root@localhost/]# touch/boot/grub/grub.conf//Create a new grub.conf configuration file

[Root@localhost/]# cp-rf/usr/share/grub/i386-pc/*/boot/grub///Copy all/usr/share/grub/i386-pc contents to/boot/grub.

[Root@localhost/]# ls/boot//view/boot partition contents

config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gz

Grub system.map-2.6.32-71.el6.i686

Initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686

[Root@localhost/]# ls/boot/grub///view/boot/grub directory contents

E2fs_stage1_5 iso9660_stage1_5 stage1 vstafs_stage1_5

Fat_stage1_5 jfs_stage1_5 Stage2 xfs_stage1_5

Ffs_stage1_5 minix_stage1_5 Stage2_eltorito

grub.conf reiserfs_stage1_5 ufs2_stage1_5

[Root@localhost/]# fdisk-l//view partitions

disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk IDENTIFIER:0X000B1DB4

Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 102400 linux//This is the/boot boot partition

Partition 1 does not end on cylinder boundary.

/dev/sda2 144 1048576 Linux Swap/solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3 144 2611 19819520 Linux//This is/root partition

[Root@localhost/]# mount//View all mount partitions

/dev/sda3 on/type ext4 (rw)//root partition

/DEV/SDA1 on/boot type EXT4 (rw)//boot partition to SDA1

Devpts on/dev/pts type devpts (rw)

Tmpfs ON/DEV/SHM type TMPFS (rw)

Proc On/proc type proc (rw)

Sysfs On/sys type SYSFS (rw)

/dev/sr0 on/mnt type iso9660 (RO)

[root@localhost/]# grub//Boot Grub

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

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

[Minimal bash-like line editing is supported. For the "the", TAB

Lists possible command completions. Anywhere Else TAB lists the possible

Completions of a device/filename.]

Grub Root (hd0,0)///First find/grub/stage1 view/boot partition as (hd0,0)

Root (hd0,0)/set/boot partition to/DEV/SDA1

FileSystem type is EXT2FS, partition type 0x83

Grub "Setup (hd0)//Reinstall GRUB

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 are embedded.

Succeeded

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

Done.

Grub "quit//exit

3. Re-reboot boot system into grub interface test

4. Find Find/grub/stage1 and then find/boot partition as (hd0,0), specify KERNEL,INITRD, boot boot system successful.

5. The system starts successfully, then enters the system to write the/boot/grub/grub.conf file again.

6.[root@localhost/]# vi/boot/grub/grub.conf configuration file is as follows:

Finally fill in the contents of grub.conf file

Default=0//Default menu is the first

timeout=6//wait time is 6 seconds

Title Mylinux//start header for Mylinux

Root (hd0,0)//boot partition is/DEV/SDA1

kernel/vmlinuz-2.6.32-71.el6.i686 ro Root=/dev/sda3 rhgb quiet//kernel location in read-only mode mount/dev/sda3 root partition rhgb quiet for quiet mode does not display kernel information.

initrd/initramfs-2.6.32-71.el6.i686.img//load INITRD mirrors.

7. Finally enter the Linux rescue to rebuild a grub

8. The final start interface is as follows

It's CentOS 6. The method of recovering the deleted boot partition is described, the steps are somewhat long, and if you feel you can reload the system, you can also restore the boot partition.

Related Article

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.