首先提示:
因爲要修改啓動配置文件,所以在各位動手之前先做個/boot/grub/grub.conf的備份,有備無患。
和許多其他linux發行版一樣,Fedora使用Grub作爲32位和64位X86系統的啓動加載器(bootloader)。
grub的配置文件主要是/boot/grub/grub.conf,而/boot/grub/menu.list是這個文件的軟連接(soft link)。該配置文件樣式如下。
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd1,0)
# kernel /vmlinuz-version ro root=/dev/sda7
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.23.1-42.fc8)
root (hd0,0)
kernel /vmlinuz-2.6.23.1-42.fc8 ro root=LABEL=/
initrd /initrd-2.6.23.1-42.fc8.img
title other
rootnoverify (hd0,0)
chainloader +1
主要分爲三個部分,開始的註釋(#開頭)不算,依次是通用的選項,Fedora 8的啓動選項和Windows系統的啓動選項。
這種情況下默認的是啓動Fedora,在title other 指的就是你的XP系統。
問:如果要改成是默認爲XP啓動如何做?
將:
///////////////////////////////////////////////////////
hiddenmenu
title Fedora (2.6.23.1-42.fc8)
root (hd0,0)
kernel /vmlinuz-2.6.23.1-42.fc8 ro root=LABEL=/
initrd /initrd-2.6.23.1-42.fc8.img
title other
rootnoverify (hd0,0)
chainloader +1
/////////////////////////////////////////////////////////////////////
中的title other改爲title Windows XP或者是別的如Windows 2000
然後將title other
rootnoverify (hd0,0)
chainloader +1
剪切到hiddenmenu的下面,呵呵,很Easy吧。這就是hiddenmenu的作用。
修改後就變成:
//////////////////////////////////////////////////////////////
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd1,0)
# kernel /vmlinuz-version ro root=/dev/sda7
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Windows XP
rootnoverify (hd0,0)
chainloader +1
title Fedora (2.6.23.1-42.fc8)
root (hd0,0)
kernel /vmlinuz-2.6.23.1-42.fc8 ro root=LABEL=/
initrd /initrd-2.6.23.1-42.fc8.img
//////////////////////////////////////////////////////////////
解釋一下 :
通用選項部分
default 表示默認啓動的系統,以0開始計數,表示第一,二……
timeout 多少秒之後默認的系統被自動加載,這裏是5秒後,用戶不做選擇的話,Fedora 8 被啓動;
hiddenmen 默認隱藏菜單,直到用戶按下某個鍵;
splashimage 起動器顯示的背景圖像,該圖像的格式是一種特殊格式,需要特殊工具製作,然後放置在合適的位置;
Fedora啓動章節
root 設置啓動系統的分區,這裏指定的不是linux系統的根分區(root system),而是boot分區,Grub是系統啓動加載器,因而他所謂的root是指系統從那個分區開始啓動,對於Linux系統而言是boot分區;
kernel 內核,位於boot分區上的合適內核;
initrd 指定特殊的initrd鏡像文件用於啓動系統時ramdisk(內存中的虛擬盤技術)加載的對象,一般會在該鏡像中包含一些特殊設備的驅動等,如USB驅動的支持,一遍Linux系統可以從UBS設備上正常的啓動,該文件可以根據特定的內核和啓動介質定製,關於如何定製,可以查看RedHat相關的文檔;
Grub啓動linux的順序是從指定的boot分區加載指定的kernel(內核)和initrd鏡像,而對於其他系統,處理情況不同,Grub會把任務交由該系統的引導程序(如windows的bootloader)去啓動系統;
rootnoverify 指定包含引導器的分區,類似Linux root指令;
chainloader 指定非linux系統的加載程序位於指定分區的+1扇區上,以便其它系統的加載器被正確加載並能執行加載其它系統的任務;
在該文件中,磁盤分區以(hdX,N)描述,X表示磁盤號,以0開始計數,依照BIOS的磁盤順序指定;N是磁盤分區號,也是從0開始計數;如BIOS順序第一塊磁盤的第二個分區(/dev/sda2), 在Grub中表示爲(hd0, 1);
Grub.conf是普通text文件格式的,可以用任何文本編輯器編輯,如VI,gedit或者kate等;需要注意的是,任何編輯錯誤都將導致系統無法正常加載和啓動,需要特別慎重和小心!