對這文章發表回應
發表限制: 非會員 可以發表
GRUB & LILO 操作備忘
GRUB, Grand UnifiedBootloader, 為 GNU 所開發設計的開機管理程式
LILO, Linux Loader, 係 Linux 傳統的開機管理程式
環境差異
GRUB LILO 設定檔 /boot/grub/menu.lst /etc/lilo.conf 設定檔修改後之套用變更 不需任何動作 執行 /sbin/lilo 安裝開機選單至 MBR /sbin/grub-install /dev/hda /sbin/lilo (在 lilo.conf 設定 boot=/dev/hda)
檔頭基本設定
GRUB LILO default=0
timeout=5
hiddenmenu
splashimage=(hd0,1)/boot/grub/splash.xpm.gz
color cyan/blue white/blueboot=/dev/hda
map=/boot/map
lba32
compact
prompt
default="Linux"
timeout=50
message=/boot/messageGRUB 自製開機畫面備忘:
底圖來源: http://ruslug.rutgers.edu/~mcgrof/grub-images/
- 以 GIMP 處理圖檔, 圖檔規格:
640x480 (影像→縮放影像)
14 色 (影像→模式→索引色)
xpm 格式
(檔案→另存新檔→ X PixMap 影像)- gzip 圖檔.xpm → 圖檔.xpm.gz
LILO 檔頭參數備忘:
- lba32 - 開啟 int 13h ext 呼叫存取位於 1024 磁柱 (cylinders) 以外的開機檔
- linear - 與 lba32 層級相同, 一般用於 SCSI 硬碟
- compact - 加快硬碟讀取速度
- prompt - 於 LILO 開機畫面出現 Boot: 提示項目, 以選擇開機選單與輸入開機命令
- timeout - 單位為 1/10 秒, 50 = 5 秒鐘
- message - 載入文字檔, 顯示於 LILO 開機畫面
選單內容
GRUB LILO Linux title Linux
root (hd0,1)
kernel /boot/vmlinuz ro root=/dev/hda1 quiet 其他參數
initrd /boot/initrdimage=/boot/vmlinuz
label=Linux
root=/dev/hda2
initrd=/boot/initrd
append="root=/dev/hda1 其他參數"
read-onlyWindows title Windows XP
rootnoverify (hd0,0)
makeactive
chainloader +1
bootother=/dev/hda1
label=WindowsXP
table=/dev/hda啟動位於非 hda 的 Windows 系統
other=/dev/hdb1
label=WindowsXP
table=/dev/hdb
boot-as=0x80hdx,y → x=第 n 顆硬碟; y=第 n 個分割區
所以: hd0,0 = hda1; hd0,1 = hda2; hd1,0 = hdb1; hd1,1 = hdb2... 依此類推, SCSI 硬碟亦同[其他參數] 可參考: /usr/src/linux/Documentation/kernel-parameters.txt (包裝於 kernel-source)
密碼保護
GRUB LILO /sbin/grub
GRUB> md5crypt或
/sbin/grub-md5-crypt
產生密碼後, 將 $1.... 密碼字串複製到 menu.lst 如下:
title Linux
password --md5 $1...
root(hd0,1)
...vi /etc/lilo.conf image=/boot/vmlinuz
label=Linux
.
.
.
password= your_password
restrictedchown root:root /etc/lilo.conf
chmod 700 /etc/lilo.conf
lilo密碼為明碼, 設定後 lilo.conf 最好只限 root 讀取
password: 每次開機選擇該 label 都需密碼
restricted: 只在 boot: 輸入額外參數時才需密碼
開機進入 Single User Mode
GRUB: 開機選單出現後, 光棒置於 Linux 項目, 按 "e" 編輯內容, 於 kernel=... 最後加上 s (或 single), 最後按 "b" 進行開機
LILO: 出現 Boot: 提示訊息後, 輸入 Linux single (Linux 是 label 定義的 Linux 開機項目)
錯誤回復:
- 備份 MBR: dd if=/dev/hda of=/root/mbr_backup.bin bs=446 count=1
復原 MBR: dd if=/root/mbr_backup.bin of=/dev/hda bs=446 count=1 - Linux 裝在 /dev/hdb1, GRUB 寫入 /dev/hda, 但開機無法出現 GRUB 選單的處理:
Step 1 - 以 Linux Rescued CD 或其他 Linux LiveCD 開機
Step 2 - mount /dev/hdb1 /mnt && chroot /mnt
Step 3 - grub-install /dev/hda --> 出現 /boot/grub/stage1 not read correctly 錯誤訊息
Step 4 - grub-install /dev/hdb --> 先寫入 /dev/hdb 的 MBR
Step 5 - grub-install /dev/hda --> 此時就能寫入 /dev/hda
若在 Step 3 出現的錯誤訊息是 "找不到裝置 /dev/hda", 表示 chroot 後 /dev 是空的
此時只要 exit 回到原先光碟開機的環境, cp -a /dev/hda /dev/hdb1 /mnt/dev 即可再重新 chroot 並繼續其餘步驟
LILO, Linux Crash Rescue HOW-TO 中譯版 / LILO boot error codes- 恢復 Windows MBR 的各種方式
相關網頁:
原文出處:Jamyy's Weblog : GRUB & LILO 操作備忘