⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grub.texi

📁 Linux的启动装载(BootLoader)程序
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
@end example@samp{+1} indicates that GRUB should read one sector from the start ofthe partition. The complete description about this syntax can be foundin @ref{Block list syntax}.@itemRun the command @command{boot} (@pxref{boot}).@end enumerateHowever, DOS and Windows have some deficiencies, so you might have touse more complicated instructions. @xref{DOS/Windows}, for moreinformation.@node OS-specific notes@section Some caveats on OS-specific issuesHere, we describe some caveats on several operating systems.@menu* GNU/Hurd::* GNU/Linux::* FreeBSD::* NetBSD::* OpenBSD::* DOS/Windows::* SCO UnixWare::* QNX::@end menu@node GNU/Hurd@subsection GNU/HurdSince GNU/Hurd is Multiboot-compliant, it is easy to boot it; there isnothing special about it. But do not forget that you have to specify aroot partition to the kernel.@enumerate@itemSet GRUB's root device to the same drive as GNU/Hurd's. Probably thecommand @code{find /boot/gnumach} or similar can help you(@pxref{find}).@itemLoad the kernel and the module, like this:@example@groupgrub> @kbd{kernel /boot/gnumach root=hd0s1}grub> @kbd{module /boot/serverboot}@end group@end example@itemRun the command @command{boot} (@pxref{boot}).@end enumerate@node GNU/Linux@subsection GNU/LinuxIt is relatively easy to boot GNU/Linux from GRUB, because it somewhatresembles to boot a Multiboot-compliant OS.@enumerate@itemSet GRUB's root device to the same drive as GNU/Linux's. Probably thecommand @code{find /vmlinuz} or similar can help you (@pxref{find}).@itemLoad the kernel:@examplegrub> @kbd{kernel /vmlinuz root=/dev/hda1}@end exampleIf you need to specify some kernel parameters, just append them to thecommand. For example, to set @option{vga} to @samp{ext}, do this:@examplegrub> @kbd{kernel /vmlinuz root=/dev/hda1 vga=ext}@end exampleSee the documentation in the Linux source tree for completeinformation on the available options.@itemIf you use an initrd, execute the command @command{initrd}(@pxref{initrd}) after @command{kernel}:@examplegrub> @kbd{initrd /initrd}@end example@itemFinally, run the command @command{boot} (@pxref{boot}).@end enumerate@strong{Caution:} If you use an initrd and specify the @samp{mem=}option to the kernel to let it use less than actual memory size, youwill also have to specify the same memory size to GRUB. To let GRUB knowthe size, run the command @command{uppermem} @emph{before} loading thekernel. @xref{uppermem}, for more information.@node FreeBSD@subsection FreeBSDGRUB can load the kernel directly, either in ELF or a.out format. Butthis is not recommended, since FreeBSD's bootstrap interface sometimeschanges heavily, so GRUB can't guarantee to pass kernel parameterscorrectly.Thus, we'd recommend loading the very flexible loader@file{/boot/loader} instead. See this example:@example@groupgrub> @kbd{root (hd0,a)}grub> @kbd{kernel /boot/loader}grub> @kbd{boot}@end group@end example@node NetBSD@subsection NetBSDGRUB can load NetBSD a.out and ELF directly, follow these steps:@enumerate@itemSet GRUB's root device with @command{root} (@pxref{root}).@itemLoad the kernel with @command{kernel} (@pxref{kernel}). You shouldappend the ugly option @option{--type=netbsd}, if you want to load anELF kernel, like this:@examplegrub> @kbd{kernel --type=netbsd /netbsd-elf}@end example@itemRun @command{boot} (@pxref{boot}).@end enumerateFor now, however, GRUB doesn't allow you to pass kernel parameters, soit may be better to chain-load it instead. For more information, pleasesee @ref{Chain-loading}.@node OpenBSD@subsection OpenBSDThe booting instruction is exactly the same as for NetBSD(@pxref{NetBSD}).@node DOS/Windows@subsection DOS/WindowsGRUB cannot boot DOS or Windows directly, so you must chain-load them(@pxref{Chain-loading}). However, their boot loaders have some criticaldeficiencies, so it may not work to just chain-load them. To overcomethe problems, GRUB provides you with two helper functions.If you have installed DOS (or Windows) on a non-first hard disk, youhave to use the disk swapping technique, because that OS cannot bootfrom any disks but the first one. The workaround used in GRUB is thecommand @command{map} (@pxref{map}), like this:@example@groupgrub> @kbd{map (hd0) (hd1)}grub> @kbd{map (hd1) (hd0)}@end group@end exampleThis performs a @dfn{virtual} swap between your first and second harddrive.@strong{Caution:} This is effective only if DOS (or Windows) uses BIOSto access the swapped disks. If that OS uses a special driver for thedisks, this probably won't work.Another problem arises if you installed more than one set of DOS/Windowsonto one disk, because they could be confused if there are more than oneprimary partitions for DOS/Windows. Certainly you should avoid doingthis, but there is a solution if you do want to do so. Use the partitionhiding/unhiding technique.If GRUB @dfn{hide}s a DOS (or Windows) partition (@pxref{hide}), DOS (orWindows) will ignore the partition. If GRUB @dfn{unhide}s a DOS (orWindows) partition (@pxref{unhide}), DOS (or Windows) will detect thepartition. Thus, if you have installed DOS (or Windows) on the firstand the second partition of the first hard disk, and you want to bootthe copy on the first partition, do the following:@example@groupgrub> @kbd{unhide (hd0,0)}grub> @kbd{hide (hd0,1)}grub> @kbd{rootnoverify (hd0,0)}grub> @kbd{chainloader +1}grub> @kbd{makeactive}grub> @kbd{boot}@end group@end example@node SCO UnixWare@subsection SCO UnixWareIt is known that the signature in the boot loader for SCO UnixWare iswrong, so you will have to specify the option @option{--force} to@command{chainloader} (@pxref{chainloader}), like this:@example@groupgrub> @kbd{rootnoverify (hd1,0)}grub> @kbd{chainloader --force +1}grub> @kbd{makeactive}grub> @kbd{boot}@end group@end example@node QNX@subsection QNXQNX seems to use a bigger boot loader, so you need to boot it up, likethis:@example@groupgrub> @kbd{rootnoverify (hd1,1)}grub> @kbd{chainloader +4}grub> @kbd{boot}@end group@end example@node Configuration@chapter ConfigurationYou've probably noticed that you need to type several commands to boot yourOS. There's a solution to that - GRUB provides a menu interface(@pxref{Menu interface}) from which you can select an item (using arrowkeys) that will do everything to boot an OS.To enable the menu, you need a configuration file,@file{menu.lst} under the boot directory. We'll analyze an examplefile.The file first contains some general settings, the menu interfacerelated options. You can put these commands (@pxref{Menu-specificcommands}) before any of the items (starting with @command{title}(@pxref{title})).@example@group## Sample boot menu configuration file#@end group@end exampleAs you may have guessed, these lines are comments. Lines starting with ahash character (@samp{#}), and blank lines, are ignored by GRUB.@example@group# By default, boot the first entry.default 0@end group@end exampleThe first entry (here, counting starts with number zero, not one!) willbe the default choice.@example@group# Boot automatically after 30 secs.timeout 30@end group@end exampleAs the comment says, GRUB will boot automatically in 30 seconds, unlessinterrupted with a keypress.@example@group# Fallback to the second entry.fallback 1@end group@end exampleIf, for any reason, the default entry doesn't work, fall back to thesecond one (this is rarely used, for obvious reasons).Note that the complete descriptions of these commands, which are menuinterface specific, can be found in @ref{Menu-specificcommands}. Other descriptions can be found in @ref{Commands}.Now, on to the actual OS definitions. You will see that each entrybegins with a special command, @command{title} (@pxref{title}), and theaction is described after it. Note that there is no command@command{boot} (@pxref{boot}) at the  end of each item. That is becauseGRUB automatically executes @command{boot} if it loads other commandssuccessfully.The argument for the command @command{title} is used to display a shorttitle/description of the entry in the menu. Since @command{title}displays the argument as is, you can write basically anything there.@example@group# For booting GNU/Hurdtitle  GNU/Hurdroot   (hd0,0)kernel /boot/gnumach.gz root=hd0s1module /boot/serverboot.gz@end group@end exampleThis boots GNU/Hurd from the first hard disk.@example@group# For booting GNU/Linuxtitle  GNU/Linuxkernel (hd1,0)/vmlinuz root=/dev/hdb1@end group@end exampleThis boots GNU/Linux, but from the second hard disk.@example@group# For booting Mach (getting kernel from floppy)title  Utah Mach4 multibootroot   (hd0,2)pause  Insert the diskette now^G!!kernel (fd0)/boot/kernel root=hd0s3module (fd0)/boot/bootstrap@end group@end exampleThis boots Mach with a kernel on a floppy, but the root filesystem athd0s3. It also contains a @command{pause} line (@pxref{pause}), whichwill cause GRUB to display a prompt and delay, before actually executingthe rest of the commands and booting.@example@group# For booting FreeBSDtitle  FreeBSDroot   (hd0,2,a)kernel /boot/loader@end group@end exampleThis item will boot FreeBSD kernel loaded from the @samp{a} partition ofthe third @sc{pc} slice of the first hard disk.@example@group# For booting OS/2title OS/2root  (hd0,1)makeactive# chainload OS/2 bootloader from the first sectorchainloader +1# This is similar to "chainload", but loads a specific file#chainloader /boot/chain.os2@end group@end exampleThis will boot OS/2, using a chain-loader (@pxref{Chain-loading}).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -