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