CentOS 6误删除的boot分区该如何还原恢复

   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 - http://www.ssh.com/

  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.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 。。//返回上层目录

  [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.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//在/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.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/ //查看/boot/grub目录内容

  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 //查看分区

  Disk /dev/sda: 21.5 GB, 21474836480 bytes

  255 heads, 63 sectors/track, 2610 cylinders

  Units = cylinders of 16065 * 512 = 8225280 bytes

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

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

  Disk 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 / Solaris

  Partition 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分区为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//启动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 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/sda1

  Filesystem type is ext2fs, partition type 0x83

  grub》 setup (hd0)//重新安装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)”。。。 26 sectors are embedded.

  succeeded

  Running “install /grub/stage1 (hd0) (hd0)1+26 p (hd0,0)/grub/stage2 /grub/grub.conf”。。。 succeeded

  Done.

  grub》 quit//退出

  3.重新reboot启动系统进入grub界面测试


  4.查找find /grub/stage1然后找到/boot分区为(hd0,0),指定kernel,initrd, boot启动系统成功。


  5.系统启动成功,然后进入系统重新写/boot/grub/grub.conf文件。


  6.[root@localhost /]# vi /boot/grub/grub.conf配置文件如下:

  最后填写grub.conf文件内容

  default=0 //默认菜单为第一个

  timeout=6//等待时间为6秒

  title mylinux //启动标题为mylinux

  root (hd0,0) //boot所在分区为/dev/sda1

  kernel /vmlinuz-2.6.32-71.el6.i686 ro root=/dev/sda3 rhgb quiet//kernel所在位置以只读模式挂载/dev/sda3根分区rhgb quiet为安静模式不显示内核信息。

  initrd /initramfs-2.6.32-71.el6.i686.img//加载initrd镜像。

  7.最后进入linux rescue重建一个grub


  8.最后启动界面如下


  上面就是CentOS 6恢复被删除boot分区的方法介绍了,步骤有些长,如果觉得麻烦的话可以重装系统,同样能恢复boot分区。

时间: 2024-07-29 19:12:31

CentOS 6误删除的boot分区该如何还原恢复的相关文章

centos 6如何恢复被删除了的boot分区

Centos6系统/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 - http://www.ssh.com

centos磁盘安装与磁盘分区方案详解

前几天自己研究了下几个linux系统,还是觉着centos要好一些.相对稳定点,起码桌面系统还是比 ubuntu 强 安装centos并不难,安装方法多得是,像硬盘安装,U盘安装,最简单方便得当然是光盘安装,而且刻录一张管盘仅仅需要10分钟,比硬盘安装和U盘安装需要仔细研究大量得说明文档省事得多. 我得是windos7 和 centos 双系统安装.之前有个windows7的系统.后来我又把最后的一个磁盘 G盘删除了,用来安装 CentOS.  我给centos 留了20+G得硬盘空间,如果是新

源码-如何在安卓boot分区目录下添加文件?

问题描述 如何在安卓boot分区目录下添加文件? 我现在按照一个教程做安卓的verified boot,其中有一步是要在boot分区根目录下添加一个文件, 原文 "include it in the root of your boot image under the verity_key filename", 安卓aosp官方的原文 "add an RSA-2048 key to the /boot partition at /verity_key" 这里具体不知道

u盘-centos7安装在分区时/boot分区只能分配3M

问题描述 centos7安装在分区时/boot分区只能分配3M centos7U盘安装选择手动分区时,在分配/boot分区时 显示为sda3但是大小限定为3M无法修改,增加其他分区时没有任何问题.

win7旗舰版磁盘分区以及磁盘分区表还原恢复方法

Ghost win7旗舰版磁盘分区以及磁盘分区表还原恢复方法由Windows7系统之家率先分享给大家! 分区表是将大表的数据分成称为分区的许多小的子集.倘若硬盘丢失了分区表,数据就无法按顺序读取和写入,导致无法操作.如果硬盘分区表被破坏或删除,windows7系统将无法识别硬盘.遇到该问题怎么还原磁盘分区呢?方法如下所示,提供给大家参考使用. 硬盘分区表一般在硬盘的初始磁面0磁面.如果不小心K掉了磁盘分区表可以通过分区工具来进行win7磁盘分区还原. 在windows之家的系统ISO镜像里有一项

centos下如何挂载ntfs分区文件里的centos镜像文件

在centos下挂载ntfs分区想必大家都比较熟悉了吧,这就是利用我们的ntfs-3g 安装方法   1     yum install fuse ntfs-3g -y 注:fuse为小内核,ntfs-3g是我的需要的,-y表示同意安装,没有-y  的话也没有影响,只不过安装的时候他会提示你是否同意,以及安装的路径等. 安装方法2.   ntfs-3g下载页面:http://www.tuxera.com/community/ntfs-3g-download/ 安装步骤: wget http://

centos系统三套硬盘分区方案

在计算机上安装Linux系统,对硬盘进行分区是一个非常重要的步骤,下面介绍几个分区方案. (1)方案1/ :建议大小在5GB以上.swap:即交换分区,建议大小是物理内存的1~2倍. (2)方案2/boot:用来存放与Linux系统启动有关的程序,比如启动引导装载程序等,建议大小为100MB./ :Linux系统的根目录,所有的目录都挂在这个目录下面,建议大小为5GB以上./home:存放普通用户的数据,是普通用户的宿主目录,建议大小为剩下的空间.swap:实现虚拟内存,建议大小是物理内存的1~

linux CentOS/redhat 6.5 LVM分区如何使用

  1, 介绍 LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分 LVM 区管理的灵活性.前面谈到,LVM是在磁盘分区和文件系统之间添加的一个逻辑层,来为文件系统屏蔽下层磁盘分区布局,提供一个抽象的盘卷,在盘卷上建立文件系统.物理卷(physical volume)物理卷就是指硬盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但

CentOS 6.8 增加swap分区大小

1. 查看当前分区情况 [root@bogon ORACLE]# free -m              total       used       free     shared    buffers     cached Mem:          1861       1763         98         30        162         73 -/+ buffers/cache:       1526        334 Swap:         2047