[轉貼自]http://www.ge.net.tw/?q=node/3483
設定Grub4Dos 選單
五, 2010/11/05 - 16:22 — aikicat
設定Grub4Dos 選單
請將 menu.lst、grldr 複製到C:\。
使用記事本修改 menu.lst
######################## menu.lst ########################
#設定背景、文字顏色
color black/cyan yellow/cyan
#設定背景圖 EX:splashimage /LOGO.xpm
splashimage (hd0,0)/boot.xpm.gz
#設定讀秒時間
timeout 30
#預設值
default /default
#設定名稱 title +空格+名稱
#find 搜尋 /bootmgr 設為根目錄
#chainloader 交棒給 /bootmgr
title Windows Vista
find --set-root /bootmgr
chainloader /bootmgr
#設定名稱 title +空格+名稱
#find 搜尋 /ntldr 設為根目錄
#chainloader 交棒給 /ntldr
title Windows Server 2003
find --set-root /ntldr
chainloader /ntldr
#設定名稱 title +空格+名稱
#指定root 為硬碟的第六個分割區(由0開始算)
#載入核心
title Fedora (2.6.23.1-42.fc8)
root (hd0,5)
kernel /vmlinuz-2.6.23.1-42.fc8 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.23.1-42.fc8.img
#設定名稱 title +空格+名稱
#find 搜尋 /io.sys 設為根目錄
#chainloader 交棒給 /io.sys
title Ghost From Dos
find --set-root /io.sys
chainloader /io.sys
#設定光碟開機
title Boot From CDROM
cdrom --init
map --hook
chainloader (cd0)
#命令列
title Commandline
commandline
#軟碟開機
title Floppy (fd0)
chainloader (fd0)+1
rootnoverify (fd0)
#重新開機
title Reboot
reboot
#關機
title shutdown
halt
######################## menu.lst ########################
title Install ubuntu
map (hd0,0)/ubuntu.iso (hd32)
map --hook
root (hd0,0)
kernel (hd32)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu.iso
initrd (hd32)/casper/initrd.gz
=============================================================
c:\menu.lst (部份內容)
===========
color black/cyan yellow/cyan
timeout 30
default /default
root ()/boot/images
# boot into a floppy image
title DOS 98 (Absolute Path)
map --mem (hd0,0)/boot/images/w98_emm.ima (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
boot
# boot into a floppy image
title DOS 98 (Relative Path)
map --mem /w98_emm.ima (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
boot
# boot into a bootable iso image
title RXPE - (0xff --mem)
map --mem /rxpe.iso (0xff)
map --hook
chainloader (0xff)
title RXPE - (hd32)
map /rxpe.iso (hd32)
map --hook
chainloader (hd32)
title RXPE - (hd32 --mem)
map --mem /rxpe.iso (hd32)
map --hook
chainloader (hd32)
===========
上述試驗, 我並非完全明白指令內容, 衹依前人照樣使用.
以 floppy image 啟動 dos98, 沒什麼大問題.
以 iso image 啟動 RXPE, 也成功.
但啟後動的 RXPE , 在 \OUTTOOL\WIMMODE 內, 完全沒有 WIM 模組.
衹餘下空殼一個.
=============================================================
grub> map (hd1,1)PATHtoISO.iso (hd4)
grub> map --rehook
grub> chainloader (hd4)+1
grub> rootnoverify (hd4)
grub> boot
grub> map (hd1,1)PATHtoISO.iso (hd4)
grub> map --rehook
grub> chainloader (hd4)+1
grub> rootnoverify (hd4)
grub> boot
title Test ISO Boot
map (hd0,0)/Test.iso (hd3)
map --rehook
chainloader (hd3)+1
rootnoverify (hd3)
boot
title Ubuntu 8.10 (Live CD)
map (hd0,0)/ubuntu810.iso (hd32)
map --rehook
chainloader (hd32)
rootnoverify (hd32)
boot
title Ubuntu 8.10
find --set-root /U810/casper/initrd.gz
kernel /U810/casper/vmlinuz boot=casper persistent rw splash
initrd /U810/casper/initrd.gz
boot
=============================================================
Installation
There are many ways to install GRUB for DOS. Some of them require modifying MBR or partition boot sector, while others require changing system startup configuration files.
[edit]Install GRUB for DOS boot code to MBR
You can use bootlace.com or grubinst.exe to install GRUB for DOS boot code to MBR:
bootlace.com can be used in DOS, Windows 95/98/Me and Linux. Examples:
Install GRUB for DOS boot code to the MBR of first hard drive under DOS, Windows 95/98/Me:
bootlace 0x80
Install GRUB for DOS boot code to the MBR of IDE channel 0, primary drive under Linux:
bootlace /dev/hda
Install GRUB for DOS boot code to the MBR of hard drive image file aa.dsk:
bootlace aa.dsk
grubinst.exe can be used in Linux, FreeBSD and Windows NT family OSs (Windows NT/2000/XP/2003/Vista). Examples:
Install GRUB for DOS boot code to the MBR of first hard drive under Windows NT family OSs:
grubinst (hd0)
Install GRUB for DOS boot code to the MBR of IDE channel 0, primary drive under Linux/FreeBSD:
grubinst "(hd0)"
You can also use device names:
grubinst /dev/hda (Linux)
grubinst /dev/ad0 (FreeBSD)
Install GRUB for DOS boot code to the MBR of hard drive image file aa.dsk:
grubinst aa.dsk
There are many options you can use with bootlace and grubinst, use the -h option to display help message.
After installing the boot code, you need to copy grldr and menu.lst to the root directory of any FAT16/FAT32/NTFS/EXT2 partition.
[edit]Install GRUB for DOS boot code to partition boot sector
You can use grubinst to install GRUB for DOS boot code to partition boot sector. Examples:
Install GRUB for DOS boot code to the first primary partition of the first hard drive:
grubinst (hd0,0)
or
grubinst --install-partition=0 (hd0)
or
grubinst -p=0 (hd0)
Install GRUB for DOS boot code to the first primary partition of the hard drive image file aa.dsk:
grubinst --install-partition=0 aa.dsk
or
grubinst -p=0 aa.dsk
Just as in GRUB, extended partition starts with (hd0,4).
After installing the boot code, you need to copy grldr and menu.lst to the partition which you install the boot code on.
[edit]Starting GRUB for DOS from DOS
You can use load GRUB for DOS in config.sys using one of the following lines:
DEVICE=GRUB.EXE
INSTALL=GRUB.EXE
SHELL=GRUB.EXE
grub.exe can also be launched from DOS prompt or batch file such as AUTOEXEC.BAT.
[edit]Starting GRUB for DOS from Linux
First, you need to apply the kexec patch to the Linux kernel.
Then, you can use the following commands to launch GRUB for DOS from linux:
kexec -l grub.exe
kexec -e
[edit]Booting GRUB for DOS via the Windows NT/2000/XP/2003 boot manager
Add the following line at the end of boot.ini (this file is hidden):
C:\grldr="Start GRUB4DOS"
Then copy grldr to C:\, and create the GRUB4DOS configuration file at C:\menu.lst.
Next time you start windows, there is a new option "Start GRUB4DOS" which can be used to start GRUB for DOS.
[edit]Booting GRUB for DOS via the Windows Vista boot manager
Use bcdedit to configure the startup menu:
bcdedit /create /d "Start GRUB4DOS" /application bootsector
bcdedit /set {id} device boot
bcdedit /set {id} path \grldr.mbr
bcdedit /displayorder {id} /addlast
Then copy grldr.mbr to C:\, grldr and menu.lst to the root directory of any FAT16/FAT32/NTFS/EXT2 partition.
Note: previous version of grldr.mbr can also be used in boot.ini of Windows NT/2000/XP/2003. But it doesn't work anymore with the latest version.
[edit]Loading GRUB for DOS using other boot loader
grub.exe can be loaded as a linux kernel.
Load GRUB for DOS using GRUB or another copy of GRUB for DOS, add the following section to menu.lst:
title Load GRUB4DOS
kernel /grub.exe
Load GRUB for DOS using syslinux, add the following section to syslinux.cfg:
label GRUB4DOS
KERNEL grub.exe
[edit]Booting DOS/Windows 9X/Windows NT startup files
In GRUB for DOS, you can load the DOS/Windows 9X/Windows NT startup files directly.
DOS, Windows 95/98/Me:
title Load io.sys
root (hd0,0)
chainloader (hd0,0)/io.sys
Windows NT/2000/XP/2003:
title Load ntldr
root (hd0,0)
chainloader (hd0,0)/ntldr
Windows Vista:
title Load bootmgr
root (hd0,0)
chainloader (hd0,0)/bootmgr
[edit]Disk emulation
In GRUB for DOS, disk emulation is implemented using the "map" command.
[edit]Direct mapping
Here is an example of mapping a image file as virtual floppy, and boot from it:
title Boot from floppy image
map (hd0,0)/aa.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --hook is used to make the mapping created by first map command take effect immediately.
Here is an example of booting from the virtual hard disk:
title Boot from hard disk image
map (hd0,0)/aa.dsk (hd0)
map (hd0) (hd1)
map --hook
chainloader (hd0,0)+1
rootnoverify (hd0,0)
Map the image file as virtual hard disk, but boot from the original disk:
title Create virtual hard disk
map (hd0,0)/aa.dsk (hd1)
map --hook
chainloader (hd0,0)+1
rootnoverify (hd0,0)
CDROM emulation is not implemented.
In direct mapping, the image file must be contiguous.
The virtual disk is implemented using INT 13. Therefore, it can be accessed in system that still uses INT 13, such as all kinds of DOS and Windows 9X (compatible mode disk access), and it can't be accessed in system that usesprotected mode drivers, such as Linux, FreeBSD and Windows NT family OSs.
[edit]Indirect mapping
Indirect mapping is very similar to direct mapping, here is an example:
title Boot from floppy image
map --mem (hd0,0)/aa.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
The --mem option indicates indirect mapping.
In indirect mapping, the image file is copy to memory before the mapping is applies, therefore, the image file need not to be contiguous, however, you must have enough memory to hole the image file.
[edit]Auto MBR creation
To create virtual hard disk, you need an image file that resemble a real hard disk, which consist of MBR and partition data. If the image file only contains partition data, you need to patch it with MBR to create disk image. GRUB for DOS has taken this into consideration. When mapping disk image file, it will test the presence of MBR, if not found, it will create MBR automatically using the partition data. For example:
title Boot from hard disk image
map --mem (hd0,0)/aa.dsk (hd0)
map (hd0) (hd1)
map --hook
chainloader (hd0,0)+1
rootnoverify (hd0,0)
aa.dsk can be either disk image or partition image, in the later case, GRUB for DOS will create the MBR in the air.
[edit]memdisk
The indirect mapping of GRUB for DOS is similar to the function of external tool memdisk from syslinux. In fact, the following two menu entries do roughly the same thing:
title Boot from virtual disk using internal map command
map --mem (hd0,0)/aa.dsk (hd0)
map (hd0) (hd1)
map --hook
chainloader (hd0,0)+1
rootnoverify (hd0,0)
title Boot from virtual disk using external memdisk
kernel (hd0,0)/memdisk
initrd (hd0,0)/aa.dsk
However, memdisk does not support direct mapping or auto MBR creation.
[edit]CDROM related subjects
[edit]Using ATAPI CDROM in GRUB for DOS
Use the following command to initialize ATAPI CDROM:
cdrom --init
Then, use the following command to start using ATATPI CDROM:
map --hook
After map --hook, the CDROM device can be accessed using (cd0), (cd1), etc.
(Note, if you need to use more than one map --hook, perhaps because you are also mapping disk images to memory, then the second and subsequent hook commands need to be map --rehook)
To boot from the first CDROM, use the following commands:
chainloader (cd0)
boot
To stop using CDROM:
map --unhook
cdrom --stop
The first command removes the (cdN) device mapping, while the second one stops the CDROM driver.
Note: If you boot GRUB for DOS from CDROM, the booting device will be (cd). This device is always accessible. However, if you want to access file from other CDROMs, you still need to initialize them using the above commands.
Examples:
To boot from the first CDROM:
title Boot From First CDROM
cdrom --init
map --hook
chainloader (cd0)
boot
[edit]Create a bootable CDROM
In GRUB for DOS, you can use grldr to create bootable CDROM:
mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o bootable.iso iso_root
mkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o grldr.iso iso_root
grldr and menu.lst should be placed at the root directory of CDROM image.
The above two commands can both create a bootable CDROM, but they are not totally the same.
The first one tells BIOS to load the whole grldr. However, some buggy BIOS might ignore it and load only a portion of the file, typically one sector (2048 bytes). This will cause the program to fail.
The second one tells BIOS to load only the first sector (2048 bytes), and the program loads the rest from CDROM. This method is safer, it should work for most BIOS.
Note: you can optionally use the -boot-info-table option, but the info table will be ignored by the program.
[edit]Load GRUB for DOS from BCDW
To load GRUB for DOS from BCDW, first copy grldr and menu.lst to the root directory of CDROM image, then add a new line to the [MenuItems] section of BCDW configuration file bcdw.ini:
\grldr ; Grub4Dos
留言列表