2011年4月3日 星期日

Grub 2 初探

Grub 2 的設定檔共有 1 個目錄及 1 個共同設定檔案:
目錄在 /etc/grub.d 包含好幾個規劃好的設定檔, 看其命名應該就能體會其用意, 另外一個共同檔案則是 /etc/default/grub, 執行 sudo update-grub 後, 將會自動產生 grub.cfg, 並將它放在 /boot/grub 目錄內
一般如果要修改,或增加 menuentry, 可以加入到 /etc/grub.d/41_custom 檔案內, 再執行 update-grub 來變更設定
另外 Grub 2 多了 loopback device, 可以用以提取檔案內容, 讓後面的 linux 或 initrd 來使用. 是一相當實用的功能, 以下例子

menuentry "Ubuntu 10.10" {
# set root directory to disk0, 2nd patition
root (hd0,2)

# define a loopback device as loop, point to file: /boot/ubuntu.iso
loopback loop /boot/ubuntu.iso

#grab the linux kernel from loopback device (loop)
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu.iso ro splash quiet locale=zh_TW.UTF-8

#grab the initial ram disk from loopback device (loop)
initrd (loop)/casper/initrd.lz
}


參考 Grub 2 說明書網址:
http://www.gnu.org/software/grub/manual/grub.html#Introduction

沒有留言: