CentOS 6 boot分区被删除了恢复总结

CentOS 6系统/boot分区被删除了,但是又不想重新安装系统,下面介绍一种快速的方法恢复boot分区。

1.首先利用centos6镜像进入linux rescue救援模式。

2.启动sshd服务,查看eth0获取的ip地址,然后用ssh secure shell 连接。

SSH Secure Shell 3.2.9 (Build 283)Copyright (c) 2000-2003 SSH Communications Security Corp –

This copy of SSH Secure Shell is a non-commercial version.This version does not include PKI and PKCS #11 functionality.

[root@localhost ~]# cd /boot //进入/boot分区

[root@localhost boot]# ls //查看boot分区的内容config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gzgrub System.map-2.6.32-71.el6.i686initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686

[root@localhost boot]# cd ..//返回上层目录

[root@localhost /]# rm -rf /boot/*//删除/boot分区所有内容

[root@localhost /]# ls /boot//查看/boot分区内容为空

[root@localhost /]# mount /dev/sr0 /mnt//挂载cdrom设备到/mnt目录下

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 //安装光盘的kernel软件包Preparing… ########################################### [100%] 1:kernel ########################################### [100%]

[root@localhost /]# ls /boot //查看/boot分区内容

config-2.6.32-71.el6.i686 System.map-2.6.32-71.el6.i686initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686symvers-2.6.32-71.el6.i686.gz

[root@localhost /]# mkdir /boot/grub//在/boot目录新建一个grub目录

[root@localhost /]# touch /boot/grub/grub.conf//新建一个grub.conf配置文件

[root@localhost /]# cp -rf /usr/share/grub/i386-pc/* /boot/grub/ //把/usr/share/grub/i386-pc的所有内容拷贝到/boot/grub中。

[root@localhost /]# ls /boot//查看/boot分区内容config-2.6.32-71.el6.i686 symvers-2.6.32-71.el6.i686.gzgrub System.map-2.6.32-71.el6.i686initramfs-2.6.32-71.el6.i686.img vmlinuz-2.6.32-71.el6.i686

[root@localhost /]# ls /boot/grub/ //查看/boot/grub目录内容e2fs_stage1_5 iso9660_stage1_5 stage1 vstafs_stage1_5fat_stage1_5 jfs_stage1_5 stage2 xfs_stage1_5ffs_stage1_5 minix_stage1_5 stage2_eltoritogrub.conf reiserfs_stage1_5 ufs2_stage1_5

[root@localhost /]# fdisk -l //查看分区

Disk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000b1db4

Device Boot Start End Blocks Id System/dev/sda1 * 1 13 102400 83 Linux//这个为/boot启动分区Partition 1 does not end on cylinder boundary./dev/sda2 13 144 1048576 82 Linux swap / SolarisPartition 2 does not end on cylinder boundary./dev/sda3 144 2611 19819520 83 Linux //这个为/根分区

[root@localhost /]# mount//查看所有挂载分区/dev/sda3 on / type ext4 (rw)//根分区/dev/sda1 on /boot type ext4 (rw)//boot分区为sda1devpts 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//启动grubProbing 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 first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.]grub> root (hd0,0) //首先find /grub/stage1查看/boot分区为(hd0,0)root (hd0,0)//设置/boot分区为/dev/sda1Filesystem type is ext2fs, partition type 0x83grub> setup (hd0)//重新安装grubsetup (hd0)Checking if “/boot/grub/stage1” exists… noChecking if “/grub/stage1” exists… yesChecking if “/grub/stage2” exists… yesChecking if “/grub/e2fs_stage1_5” exists… yesRunning “embed /grub/e2fs_stage1_5 (hd0)”… 26 sectors are embedded.succeededRunning “install /grub/stage1 (hd0) (hd0)1+26 p (hd0,0)/grub/stage2 /grub/grub.conf”… succeededDone.grub> quit//退出

,与那些新人和旧人们共同经历吧!

CentOS 6 boot分区被删除了恢复总结

相关文章:

你感兴趣的文章:

标签云: