boot分区格式化后的恢复方法

本文发布时间: 2019-Mar-22
1. 当我们格式话boot分区的时候,uuid 会变化./etc/fstab里面也需要修改[root@yangcan yum.repos.d]# cat /etc/fstab## /etc/fstab# Created by anaconda on Tue Jul 31 09:29:20 2012## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=f09bad00-c211-4698-8ccf-f25df9d4181c / ext4 defaults 1 1UUID=2e3b29f6-a024-4393-b9dd-9a2b18be27ec /boot ext4 defaults 1 2UUID=9715f641-c445-4f02-ad0c-43687ab331be swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/sr0 /media/yum iso9660 defaults,loop,ro 0 0步骤说明:1. 格式化boot分区mke2fs /dev/sda12. 进入救援模式 ,在启动分区条目下,加入rescue,进入救援的设置情况 在ftp的模式下,填入你系统对应版本的文件目录进入救援模式.或者用关盘启动进入救援模式.3. 用mount 和 fdisk -l查看一下磁盘的分区情况,通道上面得知boot的分区为/dev/sda1 #findfs LABEL=/ 查找/文件系统4. 把/dev/sda1挂载到真实的系统下.#mount /dev/sda1 /mnt/sysimage/boot#chroot /mnt/sysimage 把真实的系统结构挂载到对应的伪模式下ps:如何判断你在真实系统下还是伪系统下.可以ls下/sbin /bin ,看下是否就几个条目,就可以知道你在真实系统模式还是伪模式,退出就用exit命令.5. 因为boot里面的文件全部没没有了,我们就需要知道提供那些文件的是哪个包,我们重新安装那个包,有下面的2种方法:[root@yangcan boot]# rpm -qf /boot/vmlinuz*kernel-2.6.32-220.el6.i686[root@yangcan boot]# yum provides /boot/vmlinuz*Loaded plugins: product-id, refresh-packagekit, security, subscription-managerUpdating certificate-based repositories.Repository 'cdyum' is missing name in configuration, using idkernel-2.6.32-220.el6.i686 : The Linux kernelRepo : cdyumMatched from:Filename : /boot/vmlinuz-2.6.32-220.el6.i686kernel-2.6.32-220.el6.i686 : The Linux kernelRepo : installedMatched from: Other : Provides-match: /boot/vmlinuz-2.6.32-220.el6.i686通过查询,得知是kernel内核提供,那我们通道lftp到172.24.254.254去把相对应的系统版本的内核文件下下来.也可以挂载你本地的光盘,找到kernel文件6. 在强制安装kernel文件,完成之后/boot下就有了丢失的文件了#rpm -ivh kernel-2.6.32-220.el6.i686 --force7.我们exit到伪系统,把真实系统下的grub-install复制到伪系统的/sbin目录#cp /mnt/sysimage/sbin/grub* /sbin安装grub.先想看下帮助[root@yangcan grub]# grub-install --helpUsage: grub-install [OPTION] install_deviceInstall GRUB on your drive. -h, --help print this message and exit -v, --version print the version information and exit --root-directory=DIR install GRUB images under the directory DIR instead of the root directory --grub-shell=FILE use FILE as the grub shell --no-floppy do not probe any floppy drive --force-lba force GRUB to use LBA mode even for a buggy BIOS --recheck probe a device map even if it already exists This flag is unreliable and its use is strongly discouraged.INSTALL_DEVICE can be a GRUB device name or a system device filename.grub-install copies GRUB images into the DIR/boot directory specfied by--root-directory, and uses the grub shell to install grub into the bootsector.# grub-install /dev/sda --root-directory=/mnt/sysimage --no-floppy --recheck8.重建或者修复grub.conf文件default=0timeout=5title Red Hat Enterprise Linux (2.6.32-220.el6.i686) root (hd0,0) kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/sda2 quiet initrd /initramfs-2.6.32-220.el6.i686.img我们还需要修改/etc/fstab,把想对应的boot分区的uuid 改成/dev/sda1最后reboot


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:11pm
栏目列表