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