CentOS 6系統中/boot恢複被刪除的/boot分區 簡單介紹

來源:互聯網
上載者:User

標籤:恢複boot分區

在CentOS 6系統中,因為不小心或操作失誤導致boot分區被刪除,


遇到這種情況是否能夠恢複被刪除的boot分區呢?


  1.首先利用centos6鏡像進入linux rescue救援模式。


650) this.width=650;" style="width:600px;height:196px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152342983786.jpg" width="670" height="223" />


  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.  [[email protected] ~]# cd /boot //進入/boot分區  [[email protected] 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  [[email protected] boot]# cd 。。//返回上層目錄  [[email protected] /]# rm -rf /boot/*//刪除/boot分區所有內容  [[email protected] /]# ls /boot//查看/boot分區內容為空白  [[email protected] /]# mount /dev/sr0 /mnt//掛載cdrom裝置到/mnt目錄下  mount: block device /dev/sr0 is write-protected, mounting read-only  [[email protected] /]# rpm -ivh /mnt/Packages/kernel-2.6.32-71.el6.i686.rpm --root=/ --

force //安裝光碟片的kernel軟體包

 

 Preparing.。。 ########################################### [100%]  1:kernel ########################################### [100%]  [[email protected] /]# 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  [[email protected] /]# mkdir /boot/grub//在/boot目錄建立一個grub目錄  [[email protected] /]# touch /boot/grub/grub.conf//建立一個grub.conf設定檔  [[email protected] /]# cp -rf /usr/share/grub/i386-pc/* /boot/grub/ //

把/usr/share/grub/i386-pc的所有內容拷貝到/boot/grub中。

  

[[email protected] /]# 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  [[email protected] /]# 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  [[email protected] /]# 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 //這個為/根分區  [[email protected] /]# 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)  [[email protected] /]# 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介面測試


650) this.width=650;" style="width:600px;height:328px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152343294313.jpg" width="670" height="369" />


  4.尋找find /grub/stage1然後找到/boot分區為(hd0,0),指定kernel,initrd, boot啟動系統成功。


650) this.width=650;" style="width:595px;height:317px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152343533555.jpg" width="670" height="360" />


  5.系統啟動成功,然後進入系統重新寫/boot/grub/grub.conf檔案。


650) this.width=650;" style="width:539px;height:241px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152343891931.jpg" />


  6.[[email protected] /]# 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


650) this.width=650;" style="width:600px;height:255px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152344078442.jpg" width="670" height="288" />


  8.最後啟動介面如下


650) this.width=650;" style="width:600px;height:310px;" alt="CentOS 6刪除的boot分區如何還原" src="http://image.mamicode.com/info/201506/20180923152344397758.jpg" width="670" height="349" />


  上面就是CentOS 6恢複被刪除boot分區的方法介紹了,步驟有些長,如果覺得麻煩的話可以重裝系統,同樣能恢複boot分區。


本文出自 “我是一隻小小鳥” 部落格,請務必保留此出處http://liyanchao.blog.51cto.com/9954601/1659891

CentOS 6系統中/boot恢複被刪除的/boot分區 簡單介紹

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.