LAMP下的脚步声::关于多系统引导之lilo篇
lamp · 2004-02-07
LAMP下的脚步声
看憨狗撑着LAMP,一步一步
<< Windows Resource Kit介绍(一)
|
首页
|
关于多系统引导之grub篇 >>
关于多系统引导之lilo篇
Time:2004-02-07
关于多系统引导之lilo篇
在linux版呆久了,发现一个问题:问关于双系统启动的人很多,
现在大家对linux热爱的同时,又舍不得放弃win*。
有没有什么比较好的解决方法呢 ?
要回答这个问题,首先得看看常见引导程序对多系统的支持情况。
大家知道,系统加电,BIOS自检完成后就会首先读取MBR区(main boot record 主引导记录区)的代码,而MBR的代码一般是用来读取系统真正的引导文件的。依靠MBR区的代码将系统真正的引导程序读入内存,开始执行os的启动。所以说来无非就是个MBR的占领问题。谁占有MBR,谁就在BIOS自检完成后自动读入内存,开始执行,接管系统的启动。(如果MBR被病毒改写为它自己的代码,那结果可想而知哦 :P)所以能否支持多系统引导,完全取决于MBR区内的引导程序,最容易想到的就是使用第三方软件(比如:system commander来完成这些功能。本文旨在讨论利用系统本身的工具来实现多系统引导,故不谈及第三方引导程序)由于9X/ME的引导程序完全不支持多系统引导,所以当安装完9X/ME后MBR都会被9X/ME的引导程序自动强制覆盖。无论系统以前使用的第三方的或者linux的lilo、grub等双系统启动配置都无一幸免瞬间就会化为灰烬。(所以安装多系统引导的兄弟切记切记安装系统的顺序!新手手工恢复比较麻烦)
而2K/XP的引导程序ntldr则支持多系统引导,所以如果你先安装9X,然后安装2k/XP,那2k/XP对自家的9X老哥是会手下留情的。但是如果反过来先2K/XP,再9X,哈哈!那9X老哥可不买2K/XP的账,它会视2K/XP如无物,独占MBR。导致2K/XP无法引导,(再次强调;安装多系统引导的兄弟切记切记安装系统的顺序!新手手工恢复比较麻烦)。但是2K/XP的引导程序——ntldr在自动配置的情况下,只支持win32系统的引导,如果要让他支持linux的引导则得手工配置,这后面会提到。
而在linux上,无论是有着悠久历史的lilo还是后来居上的grub对多系统得支持是最好的!他们都支持常见的win32平台和×nix平台。
由此可以看出对多系统引导的支持最好的是lilo,grub了,其次是ntldr。
首先所说lilo。它出来的最早,网上到处都有关于它的Q&A。
所以只简单说说它的配置,lilo一般位于/sbin/lilo,其配置文件一般位于/etc/lilo.conf。lilo引导系统的时候其实是不会读取/etc/lilo.conf的,因为在更改/etc/lilo.conf后必须重新执行lilo,你的更改才可以生效,由此说明lilo启动的时候是不读/etc/lilo.conf的,但是它将/etc/lilo.conf的配置保存到什么地方了呢?man中没有说明,我猜测应该是lilo可以访问的磁盘空间也就是MBR中吧。/etc/lilo.conf的格式大概如下:(以我linux上的lilo.conf为例,包含以#开始的注释行,真正对lilo起作用的用红色标记,仅翻译解释lilo必需项)
[code]
# /etc/lilo.conf - See: `lilo(8)' and `lilo.conf(5)',
# --------------- `install-mbr(8)', `/usr/share/doc/lilo/',
# and `/usr/share/doc/mbr/'.
# +---------------------------------------------------------------+
# | !! Reminder !! |
# | |
# | Don't forget to run `lilo' after you make changes to this |
# | conffile, `/boot/bootmess.txt', or install a new kernel. The |
# | computer will most likely fail to boot if a kernel-image |
# | post-install script or you don't remember to run `lilo'. |
# | |
# +---------------------------------------------------------------+
# Support LBA for large hard disks. 大硬盘支持的选项,现在一般的硬盘都是20G以上,所以要打开开
#
[color=red]
lba32
[/color]
# Overrides the default mapping between harddisk names and the BIOS'
# harddisk order. Use with caution.
#disk=/dev/hde
# bios=0x81
#disk=/dev/sda
# bios=0x80
# Specifies the boot device. This is where Lilo installs its boot
# block. It can be either a partition, or the raw device, in which
# case it installs in the MBR, and will overwrite the current MBR.
#指定启动设备,也是安装lilo的地方(boot block——启动块),
#可以是一个分区,或者raw设备,如果安装在MBR上会覆盖原来的MBR
[color=red]
boot=/dev/hda
[/color]
#表示我的第一块硬盘 (唯一一块 :P)
# Specifies the device that should be mounted as root. (`/')
#指定根文件所在的分区
[color=red]
root=/dev/hda2
[/color]
#硬盘的第二分区
# Enable map compaction:
# Tries to merge read requests for adjacent sectors into a single
# read request. This drastically reduces load time and keeps the
# map smaller. Using `compact' is especially recommended when
# booting from a floppy disk. It is disabled here by default
# because it doesn't always work.
#
# compact
# Installs the specified file as the new boot sector
# You have the choice between: bmp, compat, menu and text
# Look in /boot/ and in lilo.conf(5) manpage for details
#
install=/boot/boot-menu.b
# Specifies the location of the map file
#
map=/boot/map
# You can set a password here, and uncomment the `restricted' lines
# in the image definitions below to make it so that a password must
# be typed to boot anything but a default configuration. If a
# command line is given, other than one specified by an `append'
# statement in `lilo.conf', the password will be required, but a
# standard default boot will not require one.
#
# This will, for instance, prevent anyone with access to the
# console from booting with something like `Linux init=/bin/sh',
# and thus becoming `root' without proper authorization.
#
# Note that if you really need this type of security, you will
# likely also want to use `install-mbr' to reconfigure the MBR
# program, as well as set up your BIOS to disallow booting from
# removable disk or CD-ROM, then put a password on getting into the
# BIOS configuration as well. Please RTFM `install-mbr(8)'.
#
# password=tatercounter2000
# Specifies the number of deciseconds (0.1 seconds) LILO should
# wait before booting the first image.
#
[color=red]
delay=20
[/color]
#启动菜单显示时间,以0.1S为单位,超过此时间会引导第一个系统
# You can put a customized boot message up if you like. If you use
# `prompt', and this computer may need to reboot unattended, you
# must specify a `timeout', or it will sit there forever waiting
# for a keypress. `single-key' goes with the `alias' lines in the
# `image' configurations below. eg: You can press `1' to boot
# `Linux', `2' to boot `LinuxOLD', if you uncomment the `alias'.
#
# message=/boot/bootmess.txt
[color=red]
prompt
[/color]
#prompt 是个必需选项,否则就没有LILO 的提示符了。但是按住 shift 键可以看到提示。
[color=red]
timeout=150
[/color]
#启动菜单显示时间,以0.1S为单位,超过此时间会引导默认启动的系统
# prompt
# single-key
# delay=100
# timeout=100
# Specifies the VGA text mode at boot time. (normal, extended, ask, <mode>)
#
# vga=ask
# vga=9
#
[color=red]
vga=normal
[/color]
#vga 是显示启动菜单的VGA模式配置选项,可选项有:
#'normal' (80x25 文本模式),
#'extended' (80x50 文本模式)
#以及 'ask' (提示你选择文本模式)。
# Kernel command line options that apply to all installed images go
# here. See: The `boot-prompt-HOWO' and `kernel-parameters.txt' in
# the Linux kernel `Documentation' directory.
#
[color=red]
# append=""
[/color]
#此参数虽然被注释掉,但是鉴于它的重要性,特别说明:
#append 它允许你把其他参数传递给内核,
#LILO 也可以让你手工在LILO 提示符下传递这些参数。例如:
#LILO: linux single
#就是告诉Linux 启动Linux 进入单用户模式。
#LILO: linux rescue
#则进入紧急修复模式
#LILO: linux root=/dev/hda2
#在引导区损坏时,可以从软盘启动,然后指定根所在的分区/dev/hda2来修复硬盘引导扇区。
# Boot up Linux by default.
#
[color=red]
default=windows
[/color]
#lilo默认引导的系统,
#在超过timeout指定的时间或者直接按回车时引导此
#系统映像,使用各个系统的标签(label)来区别相应的系统映像
#如果无此项,则将第一个系统映像,作为default值
[color=red]
image=/vmlinuz
[/color]
#第一个系统映像,位置在/vmlinuz
[color=red]
label=Linux
[/color]
#第一个系统映像的标签
[color=red]
read-only
[/color]
#以只读方式启动此吸引映像
#采用read-only 选项时,系统会把根分区挂接为只读方式,
#因为 fsck 程序要求文件系统只读。
#但不用担心你的根分区会不能写入了,
#在系统正常启动后,会自动把根分区挂接为读写方式。
#
# restricted
# alias=1
[color=red]
image=/vmlinuz.old
label=LinuxOLD
read-only
optional
[/color]
#和上面类似
# restricted
# alias=2
# If you have another OS on this machine to boot, you can uncomment the
# following lines, changing the device name on the `other' line to
# where your other OS' partition is.
#
# other=/dev/hda4
# label=HURD
# restricted
# alias=3
[color=red]
other=/dev/hda1
label="windows"
[/color]
#我的ntldr所在的分区,负责引导xp和98
#other 指明操作系统所在的分区,同样的和Linux 下的image 一样也需要给定一个标签(label),
#注意老点的lilo需要table 选项,它指向包含分区表的设备,LILO 会从这个这个分区表寻找对应的分区信息,
#然后把他传递给要启动的系统映像。
#其他数据分区,安装Debian时,自动建立的无用引导标签
#注释掉,
#other=/dev/hda5
# label="Windows(hda5)"
#other=/dev/hda6
# label="Windows(hda6)"
#other=/dev/hda7
# label="WinNT(hda7)"
[/code]
到现在,差不多都可以相当自由的,使用和配置lilo吧,
但是有点切记:在更改/etc/lilo.conf后必须重新运行/sbin/lilo。以使更改生效。
HackGou
撰写于
2004-02-07 11:07
|
发布于
之下 |
编辑
|
Trackback(1)
评论
添加评论
最新更新
原始快照:web.archive.org