標籤:

CentOS6.5 /boot分區損壞恢復

前幾天突然發現我的本地yum伺服器突然不能正常啟動了,經過觀察發現原來是/boot分區出現了問題。上網查詢了問題的解決方法,這裡總結如下:

1.使用CentOS啟動光碟啟動,選擇Rescue installed system;

2.將原系統文件掛載過來

chroot /mnt/sysimage/n

3.查看分區狀態

fdisk -l #查看分區nmount #查看掛載的分區ndf -Th #查看掛載的分區類型n

4.將/boot分區重新格式化

mkfs.ext4 /dev/sda1ndf -Thn

5.掛載光碟

mount /dev/sr0 /mntn

啟動網路:

/etc/init.d/network startn/etc/init.d/sshd startn

可以開始使用SecureCRT遠程登錄管理。

6.安裝光碟的kernel軟體包

rpm -ivh /mnt/Packages/kernel-2.6.32-431.el6.x86_64.rpm --root=/ --forcenls /bootn

7.重建grub目錄

mkdir /boot/grubntouch /boot/grub/grub.confncp -rf /usr/share/grub/x86_64-redhat/* /boot/grub/ nls /boot/nls /boot/grub/ n

8.查看並修改修復的系統參數

fdisk -lnmountn[root@nagios ~]# blkidn/dev/sda1: UUID="1411858a-9b11-4229-b58d-3666d6a068e0" TYPE="ext4" n/dev/sda2: UUID="bc2be020-b99e-41f7-b779-e616908b6530" TYPE="swap" n/dev/sda3: UUID="e336a606-0dea-490a-bdf3-dfd12e5af0cf" TYPE="ext4" n[root@nagios ~]# vi /etc/fstabnn#n# /etc/fstabn# Created by anaconda on Fri Mar 31 20:24:27 2017n#n# Accessible filesystems, by reference, are maintained under /dev/diskn# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more infon#nUUID=e336a606-0dea-490a-bdf3-dfd12e5af0cf / ext4 defaults 1 1nUUID=1411858a-9b11-4229-b58d-3666d6a068e0 /boot ext4 defaults 1 2nUUID=bc2be020-b99e-41f7-b779-e616908b6530 swap swap defaults 0 0ntmpfs /dev/shm tmpfs defaults 0 0ndevpts /dev/pts devpts gid=5,mode=620 0 0nsysfs /sys sysfs defaults 0 0nproc /proc proc defaults 0 0n檢查UUID的變化情況修改/etc/fstabn

9.修復grub

[root@nagios ~]# grubnProbing devices to guess BIOS drives. This may take a long time.nnn GNU GRUB version 0.97 (640K lower / 3072K upper memory)nn [ Minimal BASH-like line editing is supported. For the first word, TABn lists possible command completions. Anywhere else TAB lists the possiblen completions of a device/filename.]ngrub> root (hd0,0)nroot (hd0,0)n Filesystem type is ext2fs, partition type 0x83ngrub> setup (hd0)nsetup (hd0)n Checking if "/boot/grub/stage1" exists... non Checking if "/grub/stage1" exists... yesn Checking if "/grub/stage2" exists... yesn Checking if "/grub/e2fs_stage1_5" exists... yesn Running "embed /grub/e2fs_stage1_5 (hd0)"... 27 sectors are embedded.nsucceededn Running "install /grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeedednDone.ngrub> quitn

配置grub文件

[root@nagios ~]# vi /boot/grub/grub.confn# grub.conf generated by anacondan#n# Note that you do not have to rerun grub after making changes to this filen# NOTICE: You have a /boot partition. This means thatn# all kernel and initrd paths are relative to /boot/, eg.n# root (hd0,0)n# kernel /vmlinuz-version ro root=/dev/sda3n# initrd /initrd-[generic-]version.imgn#boot=/dev/sdandefault=0ntimeout=5nsplashimage=(hd0,0)/grub/splash.xpm.gznhiddenmenuntitle CentOS (2.6.32-431.el6.x86_64)n root (hd0,0)n kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=UUID=e336a606-0dea-490a-bdf3-dfd12e5af0cf nomodeset rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_NO_LVM crnashkernel=auto rhgb quiet rd_NO_DM rhgb quietn initrd /initramfs-2.6.32-431.el6.x86_64.imgn

以上內容為使用下面幾步嘗試出的正確配置:

重啟系統到grub畫面:nfind /grub/stage1n然後找到/boot分區為(hd0,0),指定kernel,initrd, boot啟動系統成功。n

10.大功告成。

kfwimg.ikafan.com/uploa
推薦閱讀:

linux下使用sendmail發郵件,郵箱收不到的解決辦法
如何更換CentOS(Linux)系統默認字體?
在 CentOS 7 上搭建屬於自己的 「完美」 郵件系統
企業用哪個版本的 Linux?

TAG:CentOS | Grub | 故障 |