Win7下安裝雙系統Centos,並修複Centos引導載入程式安裝在隨身碟上的問題

來源:互聯網
上載者:User

標籤:

1、使用隨身碟安裝Centos時,磁碟分割劃分要注意:系統(包含Win7)只能4個主要磁碟分割,所以只能在刪除一個主要磁碟分割或者在擴充分區的空閑分區內建立目錄。

2、Centos在安裝步驟的最後,引導載入程式的選項只有“安裝在隨身碟”一項,註:不可輕易選擇安裝在MBR上,會覆蓋掉Win7系統的引導載入程式。

  所以我們先選擇將引導載入程式安裝在隨身碟上,然後再修複。

3、Centos修複grub啟動程序載入程式

  參考並轉自:http://blog.csdn.net/llhwin2010/article/details/8435153

用隨身碟安裝CentOS,如果使用預設的boot掛載,會將引導安裝在隨身碟上,必須用隨身碟啟動,遇到這種情況可以通過grub手動寫入引導。(我在另一台伺服器上安裝時手動設定boot但是裝好停留在Grub無法啟動,這個沒深入研究了,在這裡就先說手動修改引導方法,給遇到同樣問題的人蔘考,如有錯誤,歡迎拍磚)

 

進入grub

Linux代碼
  1. [[email protected] home]# /sbin/grub 

找到grub的位置

Linux代碼
  1. grub> find /grub/stage1     
  2. (hd0,6)   

如果提示Error 15: File not found,則嘗試 find /boot/grub/stage1 或者 find stage1 (hd0,6)代表的第1個硬碟的第7個分區,相應的(hd0,0)代表的就是第一個硬碟第一個分區,這一步其實就是告訴我們引導是否被寫入了隨身碟中

[因為正常情況下,我們的電腦裡只有一塊硬碟,所以第二個硬碟是指隨身碟。(hd1 -->  hd0 )至於分區,在使用空閑磁碟空間建立目錄時,會顯示裝置名稱如/dev/sda‘x‘,所在分區即為‘x-1‘,或者使用df命令查看/boot目錄的所在磁碟]

 

下面進入正題

我們將引導寫入(hd0,6),即第一個磁碟第一個分區中,我在這裡的系統硬碟是這個,具體可以在linux下用df指令查看

Linux代碼
  1. grub> root (hd0,6)      [ 以我的系統為例,我的Centos系統中目錄/boot的分區號為6,所以此處該為root (hd0,6)  ]
  2. Filesystem type is ext2fs, partition type 0x83    
  3.     
  4. grub> setup (hd0)     
  5. Checking if "/boot/grub/stage1" exists... no     
  6. Checking if "/grub/stage1" exists... yes     
  7. Checking if "/grub/stage2" exists... yes     
  8. Checking if "/grub/e2fs_stage1_5" exists... yes     
  9. Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.     
  10. succeeded     
  11. Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded     
  12. Done.     
  13.     
  14. grub> reboot   

然後修改啟動的 /boot/grub/menu.lst 或者 /boot/grub/grub.conf  CentOS下這兩個檔案是綁定的,改一個即可

Linux代碼
  1. [[email protected] home]# vi /boot/grub/menu.lst     
  2.     
  3. # grub.conf generated by anaconda     
  4. #     
  5. # Note that you do not have to rerun grub after making changes to this file     
  6. # NOTICE:  You have a /boot partition.  This means that     
  7. #          all kernel and initrd paths are relative to /boot/, eg.     
  8. #          root (hd0,6)  [與上面/boot分區號對應]   
  9. #          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00     
  10. #          initrd /initrd-version.img     
  11. #boot=/dev/sdb     
  12. default=0    
  13. timeout=5    
  14. splashimage=(hd0,6)   /grub/splash.xpm.gz     
  15. hiddenmenu     
  16. title CentOS (2.6.18-274.3.1.el5)     
  17.         root (hd0,6)     
  18.         kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=/dev/VolGroup00/LogVol00     
  19.         initrd /initrd-2.6.18-274.3.1.el5.img     
  20. title CentOS (2.6.18-238.el5)     
  21.         root (hd0,6)     
  22.         kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00     
  23.         initrd /initrd-2.6.18-238.el5.img     
  24. title Other     
  25.         rootnoverify (hd0,6)     
  26.         chainloader +1   
 

把當中的(hd1,0)都改成(hd0,6),splashimage=(hd0,6)/grub/splash.xpm.gz 這個是開機引導背景圖片的位置,改不改都關係不大,重啟CentOS就可以正常啟動了

Win7下安裝雙系統Centos,並修複Centos引導載入程式安裝在隨身碟上的問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.