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

📄 grub.texi

📁 grub4dos-0.4.4-2008- 08-src.zip
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
GRUB provides two second stage images, @file{nbgrub} and@file{pxegrub} (@pxref{Images}). These images are the same as thenormal Stage 2, except that they set up a network automatically, and tryto load a configuration file from the network, if specified. The usageis very simple: If the machine has a PXE @sc{rom}, use@file{pxegrub}. If the machine has an NBI loader such as Etherboot, use@file{nbgrub}. There is no difference between them except theirformats. Since the way to load a second stage image you want to useshould be described in the manual on your Net Boot @sc{rom}, pleaserefer to the manual, for more information.However, there is one thing specific to GRUB. Namely, how to specify aconfiguration file in a BOOTP/DHCP server. For now, GRUB uses the tag@samp{150}, to get the name of a configuration file. The following is anexample with a BOOTP configuration:@example@group.allhost:hd=/tmp:bf=null:\        :ds=145.71.35.1 145.71.32.1:\        :sm=255.255.254.0:\        :gw=145.71.35.1:\        :sa=145.71.35.5:foo:ht=1:ha=63655d0334a7:ip=145.71.35.127:\        :bf=/nbgrub:\        :tc=.allhost:\        :T150="(nd)/tftpboot/menu.lst.foo":@end group@end exampleNote that you should specify the drive name @code{(nd)} in the name ofthe configuration file. This is because you might change the root drivebefore downloading the configuration from the TFTP server when thepreset menu feature is used (@pxref{Preset Menu}).See the manual of your BOOTP/DHCP server for more information. Theexact syntax should differ a little from the example.@node Serial terminal@chapter Using GRUB via a serial lineThis chapter describes how to use the serial terminal support in GRUB.If you have many computers or computers with no display/keyboard, itcould be very useful to control the computers through serialcommunications. To connect one computer with another via a serial line,you need to prepare a null-modem (cross) serial cable, and you may needto have multiport serial boards, if your computer doesn't have extraserial ports. In addition, a terminal emulator is also required, such asminicom. Refer to a manual of your operating system, for moreinformation.As for GRUB, the instruction to set up a serial terminal is quitesimple. First of all, make sure that you haven't specified the option@option{--disable-serial} to the configure script when you built yourGRUB images. If you get them in binary form, probably they have serialterminal support already.Then, initialize your serial terminal after GRUB starts up. Here is anexample:@example@groupgrub> @kbd{serial --unit=0 --speed=9600}grub> @kbd{terminal serial}@end group@end exampleThe command @command{serial} initializes the serial unit 0 with thespeed 9600bps. The serial unit 0 is usually called @samp{COM1}, so, ifyou want to use COM2, you must specify @samp{--unit=1} instead. Thiscommand accepts many other options, so please refer to @ref{serial},for more details.The command @command{terminal} (@pxref{terminal}) chooses which type ofterminal you want to use. In the case above, the terminal will be aserial terminal, but you can also pass @code{console} to the command,as @samp{terminal serial console}. In this case, a terminal in whichyou press any key will be selected as a GRUB terminal.However, note that GRUB assumes that your terminal emulator iscompatible with VT100 by default. This is true for most terminalemulators nowadays, but you should pass the option @option{--dumb} tothe command if your terminal emulator is not VT100-compatible orimplements few VT100 escape sequences. If you specify this option thenGRUB provides you with an alternative menu interface, because the normalmenu requires several fancy features of your terminal.@node Preset Menu@chapter Embedding a configuration file into GRUBGRUB supports a @dfn{preset menu} which is to be always loaded beforestarting. The preset menu feature is useful, for example, when yourcomputer has no console but a serial cable. In this case, it iscritical to set up the serial terminal as soon as possible, since youcannot see any message until the serial terminal begins to work. So itis good to run the commands @command{serial} (@pxref{serial}) and@command{terminal} (@pxref{terminal}) before anything else at thestart-up time.How the preset menu works is slightly complicated:@enumerate@itemGRUB checks if the preset menu feature is used, and loads the presetmenu, if available. This includes running commands and reading bootentries, like an ordinary configuration file.@itemGRUB checks if the configuration file is available. Note that this checkis performed @strong{regardless of the existence of the presetmenu}. The configuration file is loaded even if the preset menu wasloaded.@itemIf the preset menu includes any boot entries, they are cleared whenthe configuration file is loaded. It doesn't matter whether theconfiguration file has any entries or no entry. The boot entries in thepreset menu are used only when GRUB fails in loading the configurationfile.@end enumerateTo enable the preset menu feature, you must rebuild GRUB specifying afile to the configure script with the option@option{--enable-preset-menu}. The file has the same semantics asnormal configuration files (@pxref{Configuration}).Another point you should take care is that the diskless support(@pxref{Diskless}) diverts the preset menu. Diskless images embed apreset menu to execute the command @command{bootp} (@pxref{bootp})automatically, unless you specify your own preset menu to the configurescript. This means that you must put commands to initialize a network inthe preset menu yourself, because diskless images don't set it upimplicitly, when you use the preset menu explicitly.Therefore, a typical preset menu used with diskless support would belike this:@example@group# Set up the serial terminal, first of all.serial --unit=0 --speed=19200terminal --timeout=0 serial# Initialize the network.dhcp@end group@end example@node Security@chapter Protecting your computer from crackingYou may be interested in how to prevent ordinary users from doingwhatever they like, if you share your computer with other people. Sothis chapter describes how to improve the security of GRUB.One thing which could be a security hole is that the user can do toomany things with GRUB, because GRUB allows one to modify its configurationand run arbitrary commands at run-time. For example, the user can evenread @file{/etc/passwd} in the command-line interface by the command@command{cat} (@pxref{cat}). So it is necessary to disable all theinteractive operations.Thus, GRUB provides a @dfn{password} feature, so that only administratorscan start the interactive operations (i.e. editing menu entries andentering the command-line interface). To use this feature, you need torun the command @command{password} in your configuration file(@pxref{password}), like this:@examplepassword --md5 PASSWORD@end exampleIf this is specified, GRUB disallows any interactive control, until youpress the key @key{p} and enter a correct password.  The option@option{--md5} tells GRUB that @samp{PASSWORD} is in MD5 format.  If itis omitted, GRUB assumes the @samp{PASSWORD} is in clear text.You can encrypt your password with the command @command{md5crypt}(@pxref{md5crypt}). For example, run the grub shell (@pxref{Invoking thegrub shell}), and enter your password:@example@groupgrub> md5cryptPassword: **********Encrypted: $1$U$JK7xFegdxWH6VuppCUSIb.@end group@end exampleThen, cut and paste the encrypted password to your configuration file.Also, you can specify an optional argument to @command{password}. Seethis example:@examplepassword PASSWORD /boot/grub/menu-admin.lst@end exampleIn this case, GRUB will load @file{/boot/grub/menu-admin.lst} as aconfiguration file when you enter the valid password.Another thing which may be dangerous is that any user can choose anymenu entry. Usually, this wouldn't be problematic, but you might want topermit only administrators to run some of your menu entries, such as anentry for booting an insecure OS like DOS.GRUB provides the command @command{lock} (@pxref{lock}). This commandalways fails until you enter the valid password, so you can use it, likethis:@example@grouptitle Boot DOSlockrootnoverify (hd0,1)makeactivechainload +1@end group@end exampleYou should insert @command{lock} right after @command{title}, becauseany user can execute commands in an entry until GRUB encounters@command{lock}.You can also use the command @command{password} instead of@command{lock}. In this case the boot process will ask for the passwordand stop if it was entered incorrectly.  Since the @command{password}takes its own @var{PASSWORD} argument this is useful if you wantdifferent passwords for different entries.@node Images@chapter GRUB image filesGRUB consists of several images: two essential stages, optional stagescalled @dfn{Stage 1.5}, one image for bootable CD-ROM, and two networkboot images. Here is a short overview of them. @xref{Internals}, formore details.@table @file@item stage1This is an essential image used for booting up GRUB. Usually, this isembedded in an MBR or the boot sector of a partition. Because a PC bootsector is 512 bytes, the size of this image is exactly 512 bytes.All @file{stage1} must do is to load Stage 2 or Stage 1.5 from a localdisk. Because of the size restriction, @file{stage1} encodes thelocation of Stage 2 (or Stage 1.5) in a block list format, so it neverunderstand any filesystem structure.@item stage2This is the core image of GRUB. It does everything but booting upitself. Usually, this is put in a filesystem, but that is not required.@item e2fs_stage1_5@itemx fat_stage1_5@itemx ffs_stage1_5@itemx jfs_stage1_5@itemx minix_stage1_5@itemx reiserfs_stage1_5@itemx vstafs_stage1_5@itemx xfs_stage1_5These are called @dfn{Stage 1.5}, because they serve as a bridgebetween @file{stage1} and @file{stage2}, that is to say, Stage 1.5 isloaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between@file{stage1} and @file{*_stage1_5} is that the former doesn'tunderstand any filesystem while the latter understands one filesystem(e.g. @file{e2fs_stage1_5} understands ext2fs). So you can move theStage 2 image to another location safely, even after GRUB has beeninstalled.While Stage 2 cannot generally be embedded in a fixed area as the sizeis so large, Stage 1.5 can be installed into the area right after an MBR,or the boot loader area of a ReiserFS or a FFS.@item stage2_eltoritoThis is a boot image for CD-ROMs using the @dfn{no emulation mode} inEl Torito specification. This is identical to Stage 2, except thatthis boots up without Stage 1 and sets up a special drive @samp{(cd)}.@item nbgrubThis is a network boot image for the Network Image Proposal used by somenetwork boot loaders, such as Etherboot. This is mostly the same asStage 2, but it also sets up a network and loads a configuration filefrom the network.@item pxegrubThis is another network boot image for the Preboot Execution Environmentused by several Netboot ROMs. This is identical to @file{nbgrub}, exceptfor the format.@end table@node Filesystem@chapter Filesystem syntax and semanticsGRUB uses a special syntax for specifying disk drives which can beaccessed by BIOS. Because of BIOS limitations, GRUB cannot distinguishbetween IDE, ESDI, SCSI, or others. You must know yourself which BIOSdevice is equivalent to which OS device. Normally, that will be clear ifyou see the files in a device or use the command @command{find}(@pxref{find}).@menu* Device syntax::               How to specify devices* File name syntax::            How to specify files* Block list syntax::           How to specify block lists@end menu@node Device syntax@section How to specify devicesThe device syntax is like this:@example@code{(@var{device}[,@var{part-num}][,@var{bsd-subpart-letter}])}@end example@samp{[]} means the parameter is optional. @var{device} should beeither @samp{fd} or @samp{hd} followed by a digit, like @samp{fd0}.But you can also set @var{device} to a hexadecimal or a decimal numberwhich is a BIOS drive number, so the following are equivalent:@example(hd0)(0x80)(128)@end example@var{part-num} represents the partition number of @var{device}, startingfrom zero for primary partitions and from four for extended partitions,and @var{bsd-subpart-letter} represents the BSD disklabel subpartition,such as @samp{a} or @samp{e}.A shortcut for specifying BSD subpartitions is@code{(@var{device},@var{bsd-subpart-letter})}, in this case, GRUBsearches for the first PC partition containing a BSD disklabel, thenfinds the subpartition @var{bsd-subpart-letter}. Here is an example:@example(hd0,a)@end exampleThe syntax @samp{(hd0)} represents using the entire disk (or theMBR when installing GRUB), while the syntax @samp{(hd0,0)}represents using the first partition of the disk (or the boot sectorof the partition when installing GRUB).If you enabled the network support, the special drive, @samp{(nd)}, isalso available. Before using the network drive, you must initialize thenetwork. @xref{Network}, for more information.If you boot GRUB from a CD-ROM, @samp{(cd)} is available. @xref{Makinga GRUB bootable CD-ROM}, for details.@node File name syntax@section How to specify filesThere are two ways to specify files, by @dfn{absolute file name} and by@dfn{block list}.An absolute file name resembles a Unix absolute file name, using@samp{/} for the directory separator (not @samp{\} as in DOS). Oneexample is @samp{(hd0,0)/boot/grub/menu.lst}. This means the file@file{/boot/grub/menu.lst} in the first partition of the first harddisk. If you 

⌨️ 快捷键说明

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