2024年10月CentOS 6删除的boot分区如何还原

发布时间:

  ⑴在CentOS 系统中,因为不小心或操作失误导致boot分区被删除,遇到这种情况是否能够恢复被删除的boot分区呢?其实是可以的,下面随小编一起来了解下吧。

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

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

  ⑷SSH Secure Shell .. (Build

  ⑸Copyright (c - SSH munications Security Corp -

  ⑹This copy of SSH Secure Shell is a non-mercial version.

  ⑺This version does not include PKI and PKCS # functionality.

  ⑻[rootlocalhost ~]# cd /boot //进入/boot分区

  ⑼[rootlocalhost boot]# ls //查看boot分区的内容

  ⑽config-..-.el.i symvers-..-.el.i.gz

  ⑾grub System.map-..-.el.i

  ⑿initramfs-..-.el.i.img vmlinuz-..-.el.i

  ⒀[rootlocalhost boot]# cd 。。//返回上层目录

  ⒁[rootlocalhost /]# rm -rf /boot/*//删除/boot分区所有内容

  ⒂[rootlocalhost /]# ls /boot//查看/boot分区内容为空

  ⒃[rootlocalhost /]# mount /dev/sr /mnt//挂载cdrom设备到/mnt目录下

  ⒄mount: block device /dev/sr is write-protected, mounting read-only

  ⒅[rootlocalhost /]# rpm -ivh /mnt/Packages/kernel-..-.el.i.rpm --root=/ --force //安装光盘的kernel软件包

  ⒆Preparing.。。 ########################################### [%]

  ⒇:kernel ########################################### [%]

  ⒈[rootlocalhost /]# ls /boot //查看/boot分区内容

  ⒉config-..-.el.i System.map-..-.el.i

  ⒊initramfs-..-.el.i.img vmlinuz-..-.el.i

  ⒋symvers-..-.el.i.gz

  ⒌[rootlocalhost /]# mkdir /boot/grub//在/boot目录新建一个grub目录

  ⒍[rootlocalhost /]# touch /boot/grub/grub.conf//新建一个grub.conf配置文件

  ⒎[rootlocalhost /]# cp -rf /usr/share/grub/i-pc/* /boot/grub/ //把/usr/share/grub/i-pc的所有内容拷贝到/boot/grub中。

  ⒏[rootlocalhost /]# ls /boot//查看/boot分区内容

  ⒐config-..-.el.i symvers-..-.el.i.gz

  ⒑grub System.map-..-.el.i

  ⒒initramfs-..-.el.i.img vmlinuz-..-.el.i

  ⒓[rootlocalhost /]# ls /boot/grub/ //查看/boot/grub目录内容

  ⒔efs_stage_ iso_stage_ stage vstafs_stage_

  ⒕fat_stage_ jfs_stage_ stage xfs_stage_

  ⒖ffs_stage_ minix_stage_ stage_eltorito

  ⒗grub.conf reiserfs_stage_ ufs_stage_

  ⒘[rootlocalhost /]# fdisk -l //查看分区

  ⒙Disk /dev/sda: . GB, bytes

  ⒚ heads, sectors/track, cylinders

  ⒛Units = cylinders of * = bytes

  ①Sector size (logical/physical: bytes / bytes

  ②I/O size (minimum/optimal: bytes / bytes

  ③Disk identifier: xbdb

  ④Device Boot Start End Blocks Id System

  ⑤/dev/sda * Linux//这个为/boot启动分区

  ⑥Partition does not end on cylinder boundary.

  ⑦/dev/sda Linux swap / Solaris

  ⑧Partition does not end on cylinder boundary.

  ⑨/dev/sda Linux //这个为/根分区

  ⑩[rootlocalhost /]# mount//查看所有挂载分区

  Ⅰ/dev/sda on / type ext (rw//根分区

  Ⅱ/dev/sda on /boot type ext (rw//boot分区为sda

  Ⅲ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/sr on /mnt type iso (ro

  Ⅷ[rootlocalhost /]# grub//启动grub

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

  ⅩGNU GRUB version . (K lower / K upper memory

  ㈠[ Minimal BASH-like line editing is supported. For the first word, TAB

  ㈡lists possible mand pletions. Anywhere else TAB lists the possible

  ㈢pletions of a device/filename.]

  ㈣grub》 root (hd, //首先find /grub/stage查看/boot分区为(hd,

  ㈤root (hd,//设置/boot分区为/dev/sda

  ㈥Filesystem type is extfs, partition type x

  ㈦grub》 setup (hd//重新安装grub

  ㈧setup (hd

  ㈨Checking if “/boot/grub/stage” exists.。。 no

  ㈩Checking if “/grub/stage” exists.。。 yes

  Checking if “/grub/stage” exists.。。 yes

  Checking if “/grub/efs_stage_” exists.。。 yes

  Running “embed /grub/efs_stage_ (hd”。。。 sectors are embedded.

  sueeded

  Running “install /grub/stage (hd (hd+ p (hd,/grub/stage /grub/grub.conf”。。。 sueeded

  grub》 quit//退出