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

📄 grub.texi

📁 grub4dos-0.4.4-2008- 08-src.zip
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
title the old kernelroot (hd0,0)kernel /old_kernelsavedefaulttitle the new kernelroot (hd0,0)kernel /new_kernelsavedefault 0         # This is important!!!@end group@end exampleNote that this configuration file uses @samp{default saved}(@pxref{default}) at the head and @samp{savedefault 0}(@pxref{savedefault}) in the entry for the new kernel. This meansthat GRUB boots a saved entry by default, and booting the entry for thenew kernel saves @samp{0} as the saved entry.With this configuration file, after all, GRUB always tries to boot theold kernel after it booted the new one, because @samp{0} is the entryof @code{the old kernel}.The next step is to tell GRUB to boot the new kernel at next boottime. For this, execute @command{grub-set-default} (@pxref{Invokinggrub-set-default}):@example# @kbd{grub-set-default 1}@end exampleThis command sets the saved entry to @samp{1}, that is, to the newkernel.This method is useful, but still not very robust, because GRUB stopsbooting, if there is any error in the boot entry, such that the newkernel has an invalid executable format. Thus, it it even better touse the @dfn{fallback} mechanism of GRUB. Look at next subsection forthis feature.@node Booting fallback systems@subsection Booting fallback systemsGRUB supports a fallback mechanism of booting one or more otherentries if a default boot entry fails. You can specify multiplefallback entries if you wish.Suppose that you have three systems, @samp{A}, @samp{B} and@samp{C}. @samp{A} is a system which you want to boot bydefault. @samp{B} is a backup system which is supposed to bootsafely. @samp{C} is another backup system which is used in case where@samp{B} is broken.Then you may want GRUB to boot the first system which is bootableamong @samp{A}, @samp{B} and @samp{C}. A configuration file can bewritten in this way:@example@groupdefault saved        # This is important!!!timeout 10fallback 1 2         # This is important!!!title Aroot (hd0,0)kernel /kernelsavedefault fallback # This is important!!!title Broot (hd1,0)kernel /kernelsavedefault fallback # This is important!!!title Croot (hd2,0)kernel /kernelsavedefault@end group@end exampleNote that @samp{default saved} (@pxref{default}), @samp{fallback 1 2}and @samp{savedefault fallback} are used. GRUB will boot a saved entryby default and save a fallback entry as next boot entry with thisconfiguration.When GRUB tries to boot @samp{A}, GRUB saves @samp{1} as next bootentry, because the command @command{fallback} specifies that @samp{1}is the first fallback entry. The entry @samp{1} is @samp{B}, so GRUBwill try to boot @samp{B} at next boot time.Likewise, when GRUB tries to boot @samp{B}, GRUB saves @samp{2} asnext boot entry, because @command{fallback} specifies @samp{2} as nextfallback entry. This makes sure that GRUB will boot @samp{C} afterbooting @samp{B}.It is noteworthy that GRUB uses fallback entries both when GRUBitself fails in booting an entry and when @samp{A} or @samp{B} failsin starting up your system. So this solution ensures that your systemis started even if GRUB cannot find your kernel or if your kernelpanics.However, you need to run @command{grub-set-default} (@pxref{Invokinggrub-set-default}) when @samp{A} starts correctly or you fix @samp{A}after it crashes, since GRUB always sets next boot entry to a fallbackentry. You should run this command in a startup script such as@file{rc.local} to boot @samp{A} by default:@example# @kbd{grub-set-default 0}@end examplewhere @samp{0} is the number of the boot entry for the system@samp{A}.If you want to see what is current default entry, you can look at thefile @file{/boot/grub/default} (or @file{/grub/default} insome systems). Because this file is plain-text, you can just@command{cat} this file. But it is strongly recommended @strong{not tomodify this file directly}, because GRUB may fail in saving a defaultentry in this file, if you change this file in an unintendedmanner. Therefore, you should use @command{grub-set-default} when youneed to change the default entry.@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}).@example@group# For booting Windows NT or Windows95title Windows NT / Windows 95 boot menuroot        (hd0,0)makeactivechainloader +1# For loading DOS if Windows NT is installed# chainload /bootsect.dos@end group@end exampleThe same as the above, but for Windows.@example@group# For installing GRUB into the hard disktitle Install GRUB into the hard diskroot    (hd0,0)setup   (hd0)@end group@end exampleThis will just (re)install GRUB onto the hard disk.@example# Change the colors.title Change the colorscolor light-green/brown blink-red/blue@end exampleIn the last entry, the command @command{color} is used (@pxref{color}),to change the menu colors (try it!). This command is somewhat special,because it can be used both in the command-line and in the menu. GRUBhas several such commands, see @ref{General commands}.We hope that you now understand how to use the basic features ofGRUB. To learn more about GRUB, see the following chapters.@node Network@chapter Downloading OS images from a networkAlthough GRUB is a disk-based boot loader, it does provide networksupport. To use the network support, you need to enable at least onenetwork driver in the GRUB build process. For more information pleasesee @file{netboot/README.netboot} in the source distribution.@menu* General usage of network support::* Diskless::@end menu@node General usage of network support@section How to set up your networkGRUB requires a file server and optionally a server that will assign anIP address to the machine on which GRUB is running. For the former, onlyTFTP is supported at the moment. The latter is either BOOTP, DHCP or aRARP server@footnote{RARP is not advised, since it cannot serve muchinformation}. It is not necessary to run both the servers on onecomputer. How to configure these servers is beyond the scope of thisdocument, so please refer to the manuals specific to thoseprotocols/servers.If you decided to use a server to assign an IP address, set up theserver and run @command{bootp} (@pxref{bootp}), @command{dhcp}(@pxref{dhcp}) or @command{rarp} (@pxref{rarp}) for BOOTP, DHCP or RARP,respectively. Each command will show an assigned IP address, a netmask,an IP address for your TFTP server and a gateway. If any of theaddresses is wrong or it causes an error, probably the configuration ofyour servers isn't set up properly.Otherwise, run @command{ifconfig}, like this:@examplegrub> @kbd{ifconfig --address=192.168.110.23 --server=192.168.110.14}@end exampleYou can also use @command{ifconfig} in conjuction with @command{bootp},@command{dhcp} or @command{rarp} (e.g. to reassign the server addressmanually). @xref{ifconfig}, for more details.Finally, download your OS images from your network. The network can beaccessed using the network drive @samp{(nd)}. Everything else is verysimilar to the normal instructions (@pxref{Booting}).Here is an example:@example@groupgrub> @kbd{bootp}Probing... [NE*000]NE2000 base ...Address: 192.168.110.23    Netmask: 255.255.255.0Server: 192.168.110.14     Gateway: 192.168.110.1grub> @kbd{root (nd)}grub> @kbd{kernel /tftproot/gnumach.gz root=sd0s1}grub> @kbd{module /tftproot/serverboot.gz}grub> @kbd{boot}@end group@end example@node Diskless@section Booting from a networkIt is sometimes very useful to boot from a network, especially when youuse a machine which has no local disk. In this case, you need to obtaina kind of Net Boot @sc{rom}, such as a PXE @sc{rom} or a free softwarepackage like Etherboot. Such a Boot @sc{rom} first boots the machine,sets up the network card installed into the machine, and downloads asecond stage boot image from the network. Then, the second image willtry to boot an operating system actually from the network.

⌨️ 快捷键说明

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