在 /etc/grub.d/ 目錄下,有一些數字開頭的 script 檔,這些 script 檔會在執行 grub-mkconfig 時依序的執行並加到 grub.cfg 中。
所以當我們要加入一個 OS 項目時,可以這樣實作:
1. 加入一個 WinXP 的項目檔案,
# vim /etc/grub.d/40_winxp
#! /bin/sh -e
echo 」Adding Windows" >&2
cat << EOF
menuentry 「Windows XP」 {
set root=(hd0,1)
chainloader +1
}
EOF
然後再執行,grub-mkconfig,就會加入WinXP的選項。但我並不建議這樣用,太累了。
Debian有更聰明的做法,/etc/grub.d/下有一個30_os_prober的 script,望文生意就能知道它能自動偵測有什麼OS在硬碟裡。
首先,安裝os-prober後,再執行一次 grub-mkconfig,就會發現到 console 有這樣的敘述:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.26-2-686-bigmem
Found initrd image: /boot/initrd.img-2.6.26-2-686-bigmem
Found Microsoft Windows XP Professional on /dev/sda1
這樣就表示已經抓到Windows的磁區了,這樣就不用再煩惱OS開機碟怎麼設定了!
2009年8月7日 星期五
Debian Testing 升級到grub2
今早upgrade的時候,發現debian已建議轉換成 grub2,既然都這樣建議了,當然是把它換掉。
一開始安裝 grub2-pc後,會先相容舊的grub,開機的時候會出現:
When you have verified GRUB 2 works, you can use this command to
complete the upgrade: upgrade-from-grub-legacy
選擇linux-kernel的選項後,再執行 upgrade-from-grub-legacy,就能轉換成功。
設定檔由原本的 menu.lst 變成 /etc/grub.d/ 和 /etc/default/grub,設定完這兩個檔案內容後,執行 /usr/sbin/grub-mkconfig 就能產生 /boot/grub/grub.cfg,也就是開機時的選單了。
配合新版的grub2-splashimage,開機選單真是漂亮!而且,我覺得開機變快!
GRUB 2 has the following tasks:
* Create a compact core image. This will make Stage 1.5 unnecessary.
* Add support for dynamic loading to the core image, so that it can extend itself at the run time rather than at the build time.
* Add real memory management, to make GNU GRUB more extensible.
* Add a more object-oriented framework for file systems, files, devices, drives, terminals, commands, and OS loaders.
* Add support for internationalization. This includes support for non-ASCII character code, message catalogs like gettext, fonts, graphics console, and so on.
* Add an actual localization, based on the above internationalization support. We will target on Japanese as the first step.
* Segregate code specific to i386-pc from generic code, to make GNU GRUB portable.
* Add support for cross-platform installation.
* Develop additional software packages which will help our project and hopefully other projects.
一開始安裝 grub2-pc後,會先相容舊的grub,開機的時候會出現:
When you have verified GRUB 2 works, you can use this command to
complete the upgrade: upgrade-from-grub-legacy
選擇linux-kernel的選項後,再執行 upgrade-from-grub-legacy,就能轉換成功。
設定檔由原本的 menu.lst 變成 /etc/grub.d/ 和 /etc/default/grub,設定完這兩個檔案內容後,執行 /usr/sbin/grub-mkconfig 就能產生 /boot/grub/grub.cfg,也就是開機時的選單了。
配合新版的grub2-splashimage,開機選單真是漂亮!而且,我覺得開機變快!
GRUB 2 has the following tasks:
* Create a compact core image. This will make Stage 1.5 unnecessary.
* Add support for dynamic loading to the core image, so that it can extend itself at the run time rather than at the build time.
* Add real memory management, to make GNU GRUB more extensible.
* Add a more object-oriented framework for file systems, files, devices, drives, terminals, commands, and OS loaders.
* Add support for internationalization. This includes support for non-ASCII character code, message catalogs like gettext, fonts, graphics console, and so on.
* Add an actual localization, based on the above internationalization support. We will target on Japanese as the first step.
* Segregate code specific to i386-pc from generic code, to make GNU GRUB portable.
* Add support for cross-platform installation.
* Develop additional software packages which will help our project and hopefully other projects.
訂閱:
文章 (Atom)