📄 grub.texi
字号:
\input texinfo@c -*-texinfo-*-@c %**start of header@setfilename grub.info@settitle GRUB Manual@c %**end of header@include version.texi@c Unify all our little indices for now.@syncodeindex fn cp@syncodeindex vr cp@syncodeindex ky cp@syncodeindex pg cp@syncodeindex tp cp@footnotestyle separate@paragraphindent 3@finalout@dircategory Kernel@direntry* GRUB: (grub). The GRand Unified Bootloader* grub-install: (grub)Invoking grub-install. Install GRUB on your drive* grub-md5-crypt: (grub)Invoking grub-md5-crypt. Encrypt a password in MD5 format* grub-terminfo: (grub)Invoking grub-terminfo. Generate a terminfo command from a terminfo name* grub-set-default: (grub)Invoking grub-set-default. Set a default boot entry* mbchk: (grub)Invoking mbchk. Check for the format of a Multiboot kernel@end direntry@setchapternewpage odd@ifinfoCopyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries a copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided also thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions.@end ifinfo@titlepage@sp 10@title the GRUB manual@subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.@author Gordon Matzigkeit@author Yoshinori K. Okuji@c The following two commands start the copyright page.@page@vskip 0pt plus 1filllCopyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that the entireresulting derived work is distributed under the terms of a permissionnotice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translation approvedby Free Software Foundation.@end titlepage@c Output the table of contents at the beginning.@contents@finalout@headings double@ifnottex@node Top@top GRUB manualThis is the documentation of GNU GRUB, the GRand Unified Bootloader,a flexible and powerful boot loader program for @sc{pc}s.This edition documents version @value{VERSION}.@end ifnottex@menu* Introduction:: Capturing the spirit of GRUB* Naming convention:: Names of your drives in GRUB* Installation:: Installing GRUB on your drive* Booting:: How to boot different operating systems* Configuration:: Writing your own configuration file* Network:: Downloading OS images from a network* Serial terminal:: Using GRUB via a serial line* Preset Menu:: Embedding a configuration file into GRUB* Security:: Improving the security* Images:: GRUB image files* Filesystem:: Filesystem syntax and semantics* Interface:: The menu and the command-line* Commands:: The list of available builtin commands* Troubleshooting:: Error messages produced by GRUB* Invoking the grub shell:: How to use the grub shell* Invoking grub-install:: How to use the GRUB installer* Invoking grub-md5-crypt:: How to generate a cryptic password* Invoking grub-terminfo:: How to generate a terminfo command* Invoking grub-set-default:: How to set a default boot entry* Invoking mbchk:: How to use the Multiboot checker* Obtaining and Building GRUB:: How to obtain and build GRUB* Reporting bugs:: Where you should send a bug report* Future:: Some future plans on GRUB* Internals:: Hacking GRUB* Index::@end menu@node Introduction@chapter Introduction to GRUB@menu* Overview:: What exactly GRUB is and how to use it* History:: From maggot to house fly* Features:: GRUB features* Role of a boot loader:: The role of a boot loader@end menu@node Overview@section OverviewBriefly, a @dfn{boot loader} is the first software program that runs whena computer starts. It is responsible for loading and transferringcontrol to an operating system @dfn{kernel} software (such as Linux orGNU Mach). The kernel, in turn, initializes the rest of the operatingsystem (e.g. a GNU system).GNU GRUB is a very powerful boot loader, which can load a wide varietyof free operating systems, as well as proprietary operating systems withchain-loading@footnote{@dfn{chain-load} is the mechanism for loadingunsupported operating systems by loading another boot loader. It istypically used for loading DOS or Windows.}. GRUB is designed toaddress the complexity of booting a personal computer; both theprogram and this manual are tightly bound to that computer platform,although porting to other platforms may be addressed in the future.One of the important features in GRUB is flexibility; GRUB understandsfilesystems and kernel executable formats, so you can load an arbitraryoperating system the way you like, without recording the physicalposition of your kernel on the disk. Thus you can load the kerneljust by specifying its file name and the drive and partition where thekernel resides.When booting with GRUB, you can use either a command-line interface(@pxref{Command-line interface}), or a menu interface (@pxref{Menuinterface}). Using the command-line interface, you type the drivespecification and file name of the kernel manually. In the menuinterface, you just select an OS using the arrow keys. The menu isbased on a configuration file which you prepare beforehand(@pxref{Configuration}). While in the menu, you can switch to thecommand-line mode, and vice-versa. You can even edit menu entriesbefore using them.In the following chapters, you will learn how to specify a drive, apartition, and a file name (@pxref{Naming convention}) to GRUB, how toinstall GRUB on your drive (@pxref{Installation}), and how to boot yourOSes (@pxref{Booting}), step by step.Besides the GRUB boot loader itself, there is a @dfn{grub shell}@command{grub} (@pxref{Invoking the grub shell}) which can be run whenyou are in your operating system. It emulates the boot loader and canbe used for installing the boot loader.@node History@section History of GRUBGRUB originated in 1995 when Erich Boleyn was trying to boot the GNUHurd with the University of Utah's Mach 4 microkernel (now known as GNUMach). Erich and Brian Ford designed the Multiboot Specification(@pxref{Top, Multiboot Specification, Motivation, multiboot, The MultibootSpecification}), because they were determined not to add to the largenumber of mutually-incompatible PC boot methods.Erich then began modifying the FreeBSD boot loader so that it wouldunderstand Multiboot. He soon realized that it would be a lot easierto write his own boot loader from scratch than to keep working on theFreeBSD boot loader, and so GRUB was born.Erich added many features to GRUB, but other priorities prevented himfrom keeping up with the demands of its quickly-expanding user base. In1999, Gordon Matzigkeit and Yoshinori K. Okuji adopted GRUB as anofficial GNU package, and opened its development by making the latestsources available via anonymous CVS. @xref{Obtaining and BuildingGRUB}, for more information.@node Features@section GRUB featuresThe primary requirement for GRUB is that it be compliant with the@dfn{Multiboot Specification}, which is described in @ref{Top, MultibootSpecification, Motivation, multiboot, The Multiboot Specification}.The other goals, listed in approximate order of importance, are:@itemize @bullet{}@itemBasic functions must be straightforward for end-users.@itemRich functionality to support kernel experts and designers.@itemBackward compatibility for booting FreeBSD, NetBSD, OpenBSD, andLinux. Proprietary kernels (such as DOS, Windows NT, and OS/2) aresupported via a chain-loading function.@end itemizeExcept for specific compatibility modes (chain-loading and the Linux@dfn{piggyback} format), all kernels will be started in much the samestate as in the Multiboot Specification. Only kernels loaded at 1 megabyteor above are presently supported. Any attempt to load below thatboundary will simply result in immediate failure and an error messagereporting the problem.In addition to the requirements above, GRUB has the following features(note that the Multiboot Specification doesn't require all the featuresthat GRUB supports):@table @asis@item Recognize multiple executable formatsSupport many of the @dfn{a.out} variants plus @dfn{ELF}. Symboltables are also loaded.@item Support non-Multiboot kernelsSupport many of the various free 32-bit kernels that lack Multibootcompliance (primarily FreeBSD, NetBSD, OpenBSD, andLinux). Chain-loading of other boot loaders is also supported.@item Load multiples modulesFully support the Multiboot feature of loading multiple modules.@item Load a configuration fileSupport a human-readable text configuration file with preset bootcommands. You can also load another configuration file dynamically andembed a preset configuration file in a GRUB image file. The list ofcommands (@pxref{Commands}) are a superset of those supported on thecommand-line. An example configuration file is provided in@ref{Configuration}.@item Provide a menu interfaceA menu interface listing preset boot commands, with a programmabletimeout, is available. There is no fixed limit on the number of bootentries, and the current implementation has space for several hundred.@item Have a flexible command-line interfaceA fairly flexible command-line interface, accessible from the menu,is available to edit any preset commands, or write a new boot commandset from scratch. If no configuration file is present, GRUB drops tothe command-line.The list of commands (@pxref{Commands}) are a subset of those supportedfor configuration files. Editing commands closely resembles the Bashcommand-line (@pxref{Command Line Editing, Bash, Command Line Editing,features, Bash Features}), with @key{TAB}-completion of commands,devices, partitions, and files in a directory depending on context.@item Support multiple filesystem typesSupport multiple filesystem types transparently, plus a useful explicitblocklist notation. The currently supported filesystem types are@dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linuxext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTafs}. @xref{Filesystem}, for more information.@item Support automatic decompressionCan decompress files which were compressed by @command{gzip}. Thisfunction is both automatic and transparent to the user (i.e. allfunctions operate upon the uncompressed contents of the specifiedfiles). This greatly reduces a file size and loading time, aparticularly great benefit for floppies.@footnote{There are a fewpathological cases where loading a very badly organized ELF kernel mighttake longer, but in practice this never happen.}It is conceivable that some kernel modules should be loaded in acompressed state, so a different module-loading command can be specifiedto avoid uncompressing the modules.@item Access data on any installed deviceSupport reading data from any or all floppies or hard disk(s) recognizedby the BIOS, independent of the setting of the root device.@item Be independent of drive geometry translationsUnlike many other boot loaders, GRUB makes the particular drivetranslation irrelevant. A drive installed and running with onetranslation may be converted to another translation without any adverseeffects or changes in GRUB's configuration.@item Detect all installed @sc{ram}GRUB can generally find all the installed @sc{ram} on a PC-compatiblemachine. It uses an advanced BIOS query technique for finding allmemory regions. As described on the Multiboot Specification (@pxref{Top,Multiboot Specification, Motivation, multiboot, The MultibootSpecification}), not all kernels make use of this information, but GRUBprovides it for those who do.@item Support Logical Block Address modeIn traditional disk calls (called @dfn{CHS mode}), there is a geometrytranslation problem, that is, the BIOS cannot access over 1024cylinders, so the accessible space is limited to at least 508 MB and toat most 8GB. GRUB can't universally solve this problem, as there is nostandard interface used in all machines. However, several newer machineshave the new interface, Logical Block Address (@dfn{LBA}) mode. GRUBautomatically detects if LBA mode is available and uses it ifavailable. In LBA mode, GRUB can access the entire disk.@item Support network bootingGRUB is basically a disk-based boot loader but also has networksupport. You can load OS images from a network by using the @dfn{TFTP}protocol.@item Support remote terminalsTo support computers with no console, GRUB provides remote terminalsupport, so that you can control GRUB from a remote host. Only serialterminal support is implemented at the moment.@end table@node Role of a boot loader@section The role of a boot loaderThe following is a quotation from Gordon Matzigkeit, a GRUB fanatic:@quotationSome people like to acknowledge both the operating system and kernel whenthey talk about their computers, so they might say they use``GNU/Linux'' or ``GNU/Hurd''. Other people seem to think that thekernel is the most important part of the system, so they like to calltheir GNU operating systems ``Linux systems.''I, personally, believe that this is a grave injustice, because the@emph{boot loader} is the most important software of all. I used torefer to the above systems as either ``LILO''@footnote{The LInux LOader,a boot loader that everybody uses, but nobody likes.} or ``GRUB''systems.Unfortunately, nobody ever understood what I was talking about; now Ijust use the word ``GNU'' as a pseudonym for GRUB.So, if you ever hear people talking about their alleged ``GNU'' systems,remember that they are actually paying homage to the best boot loaderaround@dots{} GRUB!@end quotationWe, the GRUB maintainers, do not (usually) encourage Gordon's level offanaticism, but it helps to remember that boot loaders deserverecognition. We hope that you enjoy using GNU GRUB as much as we didwriting it.@node Naming convention@chapter Naming conventionThe device syntax used in GRUB is a wee bit different from what you mayhave seen before in your operating system(s), and you need to know it so
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -