个人工具

“UbuntuHelp:GrubHowto”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第2行: 第2行:
 
{{Languages|UbuntuHelp:GrubHowto}}
 
{{Languages|UbuntuHelp:GrubHowto}}
 
'''Other Languages: ComoGrub (Spanish)'''
 
'''Other Languages: ComoGrub (Spanish)'''
 
 
 
 
=== What Is GRUB ===
 
=== What Is GRUB ===
 
 
GRUB is a bootloader, it is the first thing that loads when the computer starts.  It allows you to have different operating systems, and versions of them, on the same or different hard drives.  For example, if you have both Windows and Linux installed on a computer, GRUB would load before either of these and let you choose which one to boot.  You can also create a boot floppy with GRUB to use in case of emergency.
 
GRUB is a bootloader, it is the first thing that loads when the computer starts.  It allows you to have different operating systems, and versions of them, on the same or different hard drives.  For example, if you have both Windows and Linux installed on a computer, GRUB would load before either of these and let you choose which one to boot.  You can also create a boot floppy with GRUB to use in case of emergency.
 
 
=== Modifying boot options in GRUB ===
 
=== Modifying boot options in GRUB ===
 
 
 
If you need to get into the grub menu, to modify boot options or choose a different kernel, you need to press 'ESC' just after it starts.  By default you have to press 'ESC' very quickly.  To increase this time edit /boot/grub/menu.lst, increasing the seconds in the TIMEOUT part.  Alternatively you could have the menu always come up at boot time.  To do this, comment out 'hiddenmenu' by inserting a # at the beginning of the line.
 
If you need to get into the grub menu, to modify boot options or choose a different kernel, you need to press 'ESC' just after it starts.  By default you have to press 'ESC' very quickly.  To increase this time edit /boot/grub/menu.lst, increasing the seconds in the TIMEOUT part.  Alternatively you could have the menu always come up at boot time.  To do this, comment out 'hiddenmenu' by inserting a # at the beginning of the line.
 
 
After pressing 'ESC' you will be presented with a list of kernels and operating systems that you can boot.  To modify the boot options highlight
 
After pressing 'ESC' you will be presented with a list of kernels and operating systems that you can boot.  To modify the boot options highlight
 
the operating system you want to edit and press 'e'.  There you will be presented with lines starting with 'root', 'kernel', 'initrd', 'quiet' and 'savedefault'.  To receive a more verbose boot process you can remove the 'quiet' line by highlighting it and pressing 'd' to remove that line.  You will also need to highlight the 'kernel' line press 'e' to edit and remove the word 'splash' from the end of the line .  After making any necessary modifications you can press 'b' to boot that operating system.  These modifications will not persist across reboots.
 
the operating system you want to edit and press 'e'.  There you will be presented with lines starting with 'root', 'kernel', 'initrd', 'quiet' and 'savedefault'.  To receive a more verbose boot process you can remove the 'quiet' line by highlighting it and pressing 'd' to remove that line.  You will also need to highlight the 'kernel' line press 'e' to edit and remove the word 'splash' from the end of the line .  After making any necessary modifications you can press 'b' to boot that operating system.  These modifications will not persist across reboots.
 
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png If the Ubuntu installer detected other operating systems on the disk during the installation, then the grub menu will be displayed by default and the timeout will be increased, so the step above will be unnecessary.
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=IconNote.png If the Ubuntu installer detected other operating systems on the disk during the installation, then the grub menu will be displayed by default and the timeout will be increased, so the step above will be unnecessary.
 
 
=== Automagic Kernels List ===
 
=== Automagic Kernels List ===
 
 
Ubuntu uses a tool called <code><nowiki>update-grub</nowiki></code> to modify <code><nowiki>menu.lst</nowiki></code>.  It automatically detects all of the kernels you have in the <code><nowiki>/boot</nowiki></code> directory, and applies various global settings to each one.  Whenever you install kernel updates from the repositories, <code><nowiki>update-grub</nowiki></code> is run to update the grub settings.
 
Ubuntu uses a tool called <code><nowiki>update-grub</nowiki></code> to modify <code><nowiki>menu.lst</nowiki></code>.  It automatically detects all of the kernels you have in the <code><nowiki>/boot</nowiki></code> directory, and applies various global settings to each one.  Whenever you install kernel updates from the repositories, <code><nowiki>update-grub</nowiki></code> is run to update the grub settings.
 
 
The relevant parts of <code><nowiki>menu.lst</nowiki></code> that <code><nowiki>update-grub</nowiki></code> looks at are the ones in between the "### BEGIN AUTOMAGIC KERNELS LIST" and "### END DEBIAN AUTOMAGIC KERNELS LIST" lines.  Comments are preceded by at least two '#', e.g. '## this is a comment'.  Global options are after single '#', e.g. '# groot=(hd0,4)'.  The most common one to change is probably the groot option.  Change this if <code><nowiki>/boot</nowiki></code> resides on a different partition that <code><nowiki>/</nowiki></code>.  See the appropriate section on this page for more information about different <code><nowiki>/boot</nowiki></code> partitions.  Another common option is 'kopt=', which are kernel options applied to all kernels in the <code><nowiki>menu.lst</nowiki></code>.
 
The relevant parts of <code><nowiki>menu.lst</nowiki></code> that <code><nowiki>update-grub</nowiki></code> looks at are the ones in between the "### BEGIN AUTOMAGIC KERNELS LIST" and "### END DEBIAN AUTOMAGIC KERNELS LIST" lines.  Comments are preceded by at least two '#', e.g. '## this is a comment'.  Global options are after single '#', e.g. '# groot=(hd0,4)'.  The most common one to change is probably the groot option.  Change this if <code><nowiki>/boot</nowiki></code> resides on a different partition that <code><nowiki>/</nowiki></code>.  See the appropriate section on this page for more information about different <code><nowiki>/boot</nowiki></code> partitions.  Another common option is 'kopt=', which are kernel options applied to all kernels in the <code><nowiki>menu.lst</nowiki></code>.
 
 
=== Setting kernel parameters ===
 
=== Setting kernel parameters ===
 
 
In `/boot/grub/menu.lst`, you will find a line like this:  
 
In `/boot/grub/menu.lst`, you will find a line like this:  
 
<code><nowiki># kopt=root=/dev/sda1 ro</nowiki></code>
 
<code><nowiki># kopt=root=/dev/sda1 ro</nowiki></code>
 
 
This looks like a comment, but do not remove the '# ' at the beginning. /!\  THIS IS IMPORTANT: <code><nowiki>grub</nowiki></code> sees this line as a comment and ignores it, but it is used as a configuration parameter by <code><nowiki>update-grub</nowiki></code> to generate the contents of the file that <code><nowiki>grub</nowiki></code> will read at boot.
 
This looks like a comment, but do not remove the '# ' at the beginning. /!\  THIS IS IMPORTANT: <code><nowiki>grub</nowiki></code> sees this line as a comment and ignores it, but it is used as a configuration parameter by <code><nowiki>update-grub</nowiki></code> to generate the contents of the file that <code><nowiki>grub</nowiki></code> will read at boot.
 
 
If you require additional kernel parameters (for example, if someone has asked you to test booting with certain parameters in order to troubleshoot a problem), add them to the end of the line, for example to add `noapic`:  
 
If you require additional kernel parameters (for example, if someone has asked you to test booting with certain parameters in order to troubleshoot a problem), add them to the end of the line, for example to add `noapic`:  
 
<code><nowiki># kopt=root=/dev/sda1 ro noapic</nowiki></code>
 
<code><nowiki># kopt=root=/dev/sda1 ro noapic</nowiki></code>
 
 
After editing the file, run:  
 
After editing the file, run:  
 
<code><nowiki>sudo update-grub</nowiki></code>
 
<code><nowiki>sudo update-grub</nowiki></code>
 
 
Note that you can temporarily add kernel parameters at the grub boot menu also, by pressing 'e ' and editing the kernel line.
 
Note that you can temporarily add kernel parameters at the grub boot menu also, by pressing 'e ' and editing the kernel line.
 
 
 
=== If /boot is on another partition ===
 
=== If /boot is on another partition ===
 
 
If <code><nowiki>/boot</nowiki></code> is mounted on another partition and you use <code><nowiki>update-grub</nowiki></code>, then you may run into problems.  One fix is to use <code><nowiki>grub-install</nowiki></code>, which is a distribution-agnostic way to install the <code><nowiki>grub</nowiki></code> boot loader to a boot sector.
 
If <code><nowiki>/boot</nowiki></code> is mounted on another partition and you use <code><nowiki>update-grub</nowiki></code>, then you may run into problems.  One fix is to use <code><nowiki>grub-install</nowiki></code>, which is a distribution-agnostic way to install the <code><nowiki>grub</nowiki></code> boot loader to a boot sector.
 
<code><nowiki>sudo grub-install --root-directory=/boot /dev/sda</nowiki></code>
 
<code><nowiki>sudo grub-install --root-directory=/boot /dev/sda</nowiki></code>
 
This is probably less desirable because <code><nowiki>update-grub</nowiki></code> is very good at setting things up properly, therefore it should be used instead.
 
This is probably less desirable because <code><nowiki>update-grub</nowiki></code> is very good at setting things up properly, therefore it should be used instead.
 
 
Another fix is to create a symlink in <code><nowiki>/boot</nowiki></code> to itself:
 
Another fix is to create a symlink in <code><nowiki>/boot</nowiki></code> to itself:
 
<pre><nowiki>cd /boot
 
<pre><nowiki>cd /boot
 
sudo ln -s . boot</nowiki></pre>
 
sudo ln -s . boot</nowiki></pre>
 
 
The reasoning behind this is when grub boots, it looks at whatever partition it is installed on.  <code><nowiki>update-grub</nowiki></code> (and <code><nowiki>grub-install</nowiki></code>) assumes that everything is in <code><nowiki>/boot</nowiki></code>.  When <code><nowiki>/boot</nowiki></code> is on the same partition as <code><nowiki>/</nowiki></code>, then all is OK, as <code><nowiki>menu.lst</nowiki></code> will be in <code><nowiki>/boot/grub</nowiki></code>.  If <code><nowiki>/boot</nowiki></code> is on a separate partition, then grub sees <code><nowiki>/boot</nowiki></code> as <code><nowiki>/</nowiki></code> (hence the '--root-directory' above).  By adding a symlink, when it looks for <code><nowiki>/boot/grub</nowiki></code>, it will be there.  By creating the symlink, you have put a loop in the file system, which may cause problems when using certain options of <code><nowiki>cp</nowiki></code>, <code><nowiki>mv</nowiki></code>, etc.
 
The reasoning behind this is when grub boots, it looks at whatever partition it is installed on.  <code><nowiki>update-grub</nowiki></code> (and <code><nowiki>grub-install</nowiki></code>) assumes that everything is in <code><nowiki>/boot</nowiki></code>.  When <code><nowiki>/boot</nowiki></code> is on the same partition as <code><nowiki>/</nowiki></code>, then all is OK, as <code><nowiki>menu.lst</nowiki></code> will be in <code><nowiki>/boot/grub</nowiki></code>.  If <code><nowiki>/boot</nowiki></code> is on a separate partition, then grub sees <code><nowiki>/boot</nowiki></code> as <code><nowiki>/</nowiki></code> (hence the '--root-directory' above).  By adding a symlink, when it looks for <code><nowiki>/boot/grub</nowiki></code>, it will be there.  By creating the symlink, you have put a loop in the file system, which may cause problems when using certain options of <code><nowiki>cp</nowiki></code>, <code><nowiki>mv</nowiki></code>, etc.
 
 
=== Changing the Disk that Grub is installed to ===
 
=== Changing the Disk that Grub is installed to ===
 
 
Consider the following problem: You have two hard drives, one SATA (/dev/sda), the other PATA (/dev/hda).  Your BIOS seems to think that PATA drives should always be booted in preference of SATA drives, but you want to boot from the SATA drive.  Grub can work around this problem.
 
Consider the following problem: You have two hard drives, one SATA (/dev/sda), the other PATA (/dev/hda).  Your BIOS seems to think that PATA drives should always be booted in preference of SATA drives, but you want to boot from the SATA drive.  Grub can work around this problem.
 
 
Finding groot
 
Finding groot
 
 
First, figure out what Grub names the drives.  This is listed in <code><nowiki>/boot/grub/device.map</nowiki></code>.  There you will find a table of Grub-style names (e.g. ''(hd0)'') and Linux-style names (e.g. ''/dev/hda/'').  You need to know what drive and partition <code><nowiki>/boot</nowiki></code> is on.  To find where <code><nowiki>/boot</nowiki></code> is, use <code><nowiki>df</nowiki></code>:
 
First, figure out what Grub names the drives.  This is listed in <code><nowiki>/boot/grub/device.map</nowiki></code>.  There you will find a table of Grub-style names (e.g. ''(hd0)'') and Linux-style names (e.g. ''/dev/hda/'').  You need to know what drive and partition <code><nowiki>/boot</nowiki></code> is on.  To find where <code><nowiki>/boot</nowiki></code> is, use <code><nowiki>df</nowiki></code>:
 
<code><nowiki>df /boot</nowiki></code>
 
<code><nowiki>df /boot</nowiki></code>
 
This should tell you the Linux-style partition name where <code><nowiki>/boot</nowiki></code> is.  Then simply match it with the Grub-style name in <code><nowiki>device.map</nowiki></code>.  This is what ''groot'' should be.   
 
This should tell you the Linux-style partition name where <code><nowiki>/boot</nowiki></code> is.  Then simply match it with the Grub-style name in <code><nowiki>device.map</nowiki></code>.  This is what ''groot'' should be.   
 
 
Example:   
 
Example:   
 
<pre><nowiki>$ df /boot
 
<pre><nowiki>$ df /boot
 
Filesystem            Size  Used Avail Use% Mounted on
 
Filesystem            Size  Used Avail Use% Mounted on
 
/dev/sda5              46M  15M  30M  33% /boot
 
/dev/sda5              46M  15M  30M  33% /boot
 
 
$ cat /boot/grub/device.map  
 
$ cat /boot/grub/device.map  
 
(hd0) /dev/hda
 
(hd0) /dev/hda
第74行: 第45行:
 
<pre><nowiki>## default grub root device
 
<pre><nowiki>## default grub root device
 
# groot=(hd1,4)</nowiki></pre>
 
# groot=(hd1,4)</nowiki></pre>
 
 
Finding kernel root
 
Finding kernel root
 
 
The other piece of the puzzle is telling the kernel where <code><nowiki>/</nowiki></code> is.  Simply find out where <code><nowiki>/</nowiki></code> is mounted.
 
The other piece of the puzzle is telling the kernel where <code><nowiki>/</nowiki></code> is.  Simply find out where <code><nowiki>/</nowiki></code> is mounted.
 
<code><nowiki>df /</nowiki></code>
 
<code><nowiki>df /</nowiki></code>
 
This is what ''root'' should be in ''kopt''.   
 
This is what ''root'' should be in ''kopt''.   
 
 
Example:
 
Example:
 
<pre><nowiki>$ df /
 
<pre><nowiki>$ df /
第88行: 第56行:
 
<pre><nowiki>## default kernel options
 
<pre><nowiki>## default kernel options
 
# kopt=root=/dev/sda3 ro</nowiki></pre>
 
# kopt=root=/dev/sda3 ro</nowiki></pre>
 
 
In summary, ''groot'' is where <code><nowiki>/boot</nowiki></code> is, and is what Grub sees that drive as.  ''kopt=root'' is where <code><nowiki>/</nowiki></code> is, and is what the kernel sees that drive as.
 
In summary, ''groot'' is where <code><nowiki>/boot</nowiki></code> is, and is what Grub sees that drive as.  ''kopt=root'' is where <code><nowiki>/</nowiki></code> is, and is what the kernel sees that drive as.
 
 
=== Boot splash images ===
 
=== Boot splash images ===
 
 
Grub allows an image to be displayed behind the menu.  You can obtain a set of images with the package "grub-splashimages", or you can make your own.  The images must be 640x480 pixels, contain no more than 16 colors (but a smaller number like 12 works better to allow some different colors for the menu text), and be in gzipped xpm format.  The GIMP can be used to resize (Image -> Scale Image...), reduce colors (Image -> Mode -> Indexed...), and can save to .xpm.gz files.   
 
Grub allows an image to be displayed behind the menu.  You can obtain a set of images with the package "grub-splashimages", or you can make your own.  The images must be 640x480 pixels, contain no more than 16 colors (but a smaller number like 12 works better to allow some different colors for the menu text), and be in gzipped xpm format.  The GIMP can be used to resize (Image -> Scale Image...), reduce colors (Image -> Mode -> Indexed...), and can save to .xpm.gz files.   
 
 
==== Manual configuration ====
 
==== Manual configuration ====
 
After creating a splash image, add a line like
 
After creating a splash image, add a line like
第103行: 第67行:
 
Grub loads the image from the disk upon boot; it is not stored in the MBR.  If you use a symlink, you will not have to edit menu.lst and reinstall grub to change the image, you just have to change the symlink. Make sure any symlink does not point to a file on another partition, for instance if you have /boot on a separate partition.  
 
Grub loads the image from the disk upon boot; it is not stored in the MBR.  If you use a symlink, you will not have to edit menu.lst and reinstall grub to change the image, you just have to change the symlink. Make sure any symlink does not point to a file on another partition, for instance if you have /boot on a separate partition.  
 
Here is an image of the GNU by Peter Gerwinski: https://help.ubuntu.com/community/GrubHowto?action=AttachFile&do=get&target=gnu-head.xpm.gz
 
Here is an image of the GNU by Peter Gerwinski: https://help.ubuntu.com/community/GrubHowto?action=AttachFile&do=get&target=gnu-head.xpm.gz
 
 
==== Splash Image with update-grub ====
 
==== Splash Image with update-grub ====
 
The command '''update-grub''' will automatically pick up /boot/grub/splash.xpm.gz and configure the ''menu.lst'' file for you. It will take care of the correct hdX and partition number [no need to type in (hd0,4)].  
 
The command '''update-grub''' will automatically pick up /boot/grub/splash.xpm.gz and configure the ''menu.lst'' file for you. It will take care of the correct hdX and partition number [no need to type in (hd0,4)].  
第110行: 第73行:
 
sudo update-grub</nowiki></pre>
 
sudo update-grub</nowiki></pre>
 
'''Note:''' replace the my_image.xpm.gz with the one that you want.
 
'''Note:''' replace the my_image.xpm.gz with the one that you want.
 
 
=== Creating a boot floppy ===
 
=== Creating a boot floppy ===
 
 
You can use grub to create a boot floppy. See [[UbuntuHelp:/BootFloppy]]
 
You can use grub to create a boot floppy. See [[UbuntuHelp:/BootFloppy]]
 
 
=== Change the default operating system ===
 
=== Change the default operating system ===
 
 
By default, Grub in Ubuntu boots Ubuntu by default. If you wish to change this to another operating system, see [[UbuntuHelp:/ChangeDefaultOS]]
 
By default, Grub in Ubuntu boots Ubuntu by default. If you wish to change this to another operating system, see [[UbuntuHelp:/ChangeDefaultOS]]
 
 
=== Network booting ===
 
=== Network booting ===
 
 
If you use LTSP or Edubuntu, you may want to boot from your network card.  
 
If you use LTSP or Edubuntu, you may want to boot from your network card.  
 
 
Specific network cards need a specifc rom to boot from. To find which one you need, run <code><nowiki>lsmod</nowiki></code> and then search for your floppy. Then go to www.rom-o-matic.com and get the appropriate rom.
 
Specific network cards need a specifc rom to boot from. To find which one you need, run <code><nowiki>lsmod</nowiki></code> and then search for your floppy. Then go to www.rom-o-matic.com and get the appropriate rom.
 
 
Edit `/boot/grub/menu.lst` and add the following before <code><nowiki>### BEGIN AUTOMAGIC KERNELS LIST</nowiki></code> or after <code><nowiki>### END DEBIAN AUTOMAGIC KERNELS LIST</nowiki></code>, otherwise your changes will be wiped out by security updates, etc.
 
Edit `/boot/grub/menu.lst` and add the following before <code><nowiki>### BEGIN AUTOMAGIC KERNELS LIST</nowiki></code> or after <code><nowiki>### END DEBIAN AUTOMAGIC KERNELS LIST</nowiki></code>, otherwise your changes will be wiped out by security updates, etc.
 
<pre><nowiki>title LTSP
 
<pre><nowiki>title LTSP
 
root (hd0,2)
 
root (hd0,2)
 
kernel /boot/(rom you get from rom-o-matic)</nowiki></pre>
 
kernel /boot/(rom you get from rom-o-matic)</nowiki></pre>
 
 
 
=== Security ===
 
=== Security ===
 
 
By editing the boot command in grub, root access can be gained without the need of a password. To avoid this, edit the part "## password ['--md5'] passwd" of `/boot/grub/menu.lst`:
 
By editing the boot command in grub, root access can be gained without the need of a password. To avoid this, edit the part "## password ['--md5'] passwd" of `/boot/grub/menu.lst`:
 
<pre><nowiki>password yourfancyplaintextpassword
 
<pre><nowiki>password yourfancyplaintextpassword
第140行: 第92行:
 
</nowiki></pre>
 
</nowiki></pre>
 
You can also use a md5 password, more info in the [http://www.gentoo.org/doc/en/security/security-handbook.xml?part=1&chap=2 Gentoo Security Handbook].
 
You can also use a md5 password, more info in the [http://www.gentoo.org/doc/en/security/security-handbook.xml?part=1&chap=2 Gentoo Security Handbook].
 
 
=== More information ===
 
=== More information ===
 
The official [http://www.gnu.org/software/grub/manual/html_node/index.html GNU GRUB manual] has a "DOS/Windows" chapter with hints on setting up dual-boot systems.
 
The official [http://www.gnu.org/software/grub/manual/html_node/index.html GNU GRUB manual] has a "DOS/Windows" chapter with hints on setting up dual-boot systems.
 
 
[http://users.bigpond.net.au/hermanzone/p15.htm This] page has a lot of Grub information (and other general information).
 
[http://users.bigpond.net.au/hermanzone/p15.htm This] page has a lot of Grub information (and other general information).
 
----
 
----

2007年11月30日 (五) 17:29的版本


Other Languages: ComoGrub (Spanish)

What Is GRUB

GRUB is a bootloader, it is the first thing that loads when the computer starts. It allows you to have different operating systems, and versions of them, on the same or different hard drives. For example, if you have both Windows and Linux installed on a computer, GRUB would load before either of these and let you choose which one to boot. You can also create a boot floppy with GRUB to use in case of emergency.

Modifying boot options in GRUB

If you need to get into the grub menu, to modify boot options or choose a different kernel, you need to press 'ESC' just after it starts. By default you have to press 'ESC' very quickly. To increase this time edit /boot/grub/menu.lst, increasing the seconds in the TIMEOUT part. Alternatively you could have the menu always come up at boot time. To do this, comment out 'hiddenmenu' by inserting a # at the beginning of the line. After pressing 'ESC' you will be presented with a list of kernels and operating systems that you can boot. To modify the boot options highlight the operating system you want to edit and press 'e'. There you will be presented with lines starting with 'root', 'kernel', 'initrd', 'quiet' and 'savedefault'. To receive a more verbose boot process you can remove the 'quiet' line by highlighting it and pressing 'd' to remove that line. You will also need to highlight the 'kernel' line press 'e' to edit and remove the word 'splash' from the end of the line . After making any necessary modifications you can press 'b' to boot that operating system. These modifications will not persist across reboots. IconsPage?action=AttachFile&do=get&target=IconNote.png If the Ubuntu installer detected other operating systems on the disk during the installation, then the grub menu will be displayed by default and the timeout will be increased, so the step above will be unnecessary.

Automagic Kernels List

Ubuntu uses a tool called update-grub to modify menu.lst. It automatically detects all of the kernels you have in the /boot directory, and applies various global settings to each one. Whenever you install kernel updates from the repositories, update-grub is run to update the grub settings. The relevant parts of menu.lst that update-grub looks at are the ones in between the "### BEGIN AUTOMAGIC KERNELS LIST" and "### END DEBIAN AUTOMAGIC KERNELS LIST" lines. Comments are preceded by at least two '#', e.g. '## this is a comment'. Global options are after single '#', e.g. '# groot=(hd0,4)'. The most common one to change is probably the groot option. Change this if /boot resides on a different partition that /. See the appropriate section on this page for more information about different /boot partitions. Another common option is 'kopt=', which are kernel options applied to all kernels in the menu.lst.

Setting kernel parameters

In `/boot/grub/menu.lst`, you will find a line like this: # kopt=root=/dev/sda1 ro This looks like a comment, but do not remove the '# ' at the beginning. /!\ THIS IS IMPORTANT: grub sees this line as a comment and ignores it, but it is used as a configuration parameter by update-grub to generate the contents of the file that grub will read at boot. If you require additional kernel parameters (for example, if someone has asked you to test booting with certain parameters in order to troubleshoot a problem), add them to the end of the line, for example to add `noapic`: # kopt=root=/dev/sda1 ro noapic After editing the file, run: sudo update-grub Note that you can temporarily add kernel parameters at the grub boot menu also, by pressing 'e ' and editing the kernel line.

If /boot is on another partition

If /boot is mounted on another partition and you use update-grub, then you may run into problems. One fix is to use grub-install, which is a distribution-agnostic way to install the grub boot loader to a boot sector. sudo grub-install --root-directory=/boot /dev/sda This is probably less desirable because update-grub is very good at setting things up properly, therefore it should be used instead. Another fix is to create a symlink in /boot to itself:

cd /boot
sudo ln -s . boot

The reasoning behind this is when grub boots, it looks at whatever partition it is installed on. update-grub (and grub-install) assumes that everything is in /boot. When /boot is on the same partition as /, then all is OK, as menu.lst will be in /boot/grub. If /boot is on a separate partition, then grub sees /boot as / (hence the '--root-directory' above). By adding a symlink, when it looks for /boot/grub, it will be there. By creating the symlink, you have put a loop in the file system, which may cause problems when using certain options of cp, mv, etc.

Changing the Disk that Grub is installed to

Consider the following problem: You have two hard drives, one SATA (/dev/sda), the other PATA (/dev/hda). Your BIOS seems to think that PATA drives should always be booted in preference of SATA drives, but you want to boot from the SATA drive. Grub can work around this problem. Finding groot First, figure out what Grub names the drives. This is listed in /boot/grub/device.map. There you will find a table of Grub-style names (e.g. (hd0)) and Linux-style names (e.g. /dev/hda/). You need to know what drive and partition /boot is on. To find where /boot is, use df: df /boot This should tell you the Linux-style partition name where /boot is. Then simply match it with the Grub-style name in device.map. This is what groot should be. Example:

$ df /boot
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              46M   15M   30M  33% /boot
$ cat /boot/grub/device.map 
(hd0)	/dev/hda
(hd1)	/dev/sda

So groot should be (hd1,4) (note that Grub partition numbers are always one less than Linux numbers). Thus in /boot/grub/menu.lst,

## default grub root device
# groot=(hd1,4)

Finding kernel root The other piece of the puzzle is telling the kernel where / is. Simply find out where / is mounted. df / This is what root should be in kopt. Example:

$ df /
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              14G  8.3G  5.0G  63% /

/ is on /dev/hda3. Because this is going to be passed to the kernel, there's no need to translate to Grub notation. The 'ro' causes the kernel to mount the drive read-only initially; later the drive will be remounted read/write. This is generally done so fsck can run on / at bootup.

## default kernel options
# kopt=root=/dev/sda3 ro

In summary, groot is where /boot is, and is what Grub sees that drive as. kopt=root is where / is, and is what the kernel sees that drive as.

Boot splash images

Grub allows an image to be displayed behind the menu. You can obtain a set of images with the package "grub-splashimages", or you can make your own. The images must be 640x480 pixels, contain no more than 16 colors (but a smaller number like 12 works better to allow some different colors for the menu text), and be in gzipped xpm format. The GIMP can be used to resize (Image -> Scale Image...), reduce colors (Image -> Mode -> Indexed...), and can save to .xpm.gz files.

Manual configuration

After creating a splash image, add a line like splashimage=(hd0,4)/boot/grub/splash.xpm.gz to your menu.lst file. A useful trick is to make a symlink to the actual image named splash.xpm.gz.

cd /boot/grub
sudo ln -s my_image.xpm.gz splash.xpm.gz

Grub loads the image from the disk upon boot; it is not stored in the MBR. If you use a symlink, you will not have to edit menu.lst and reinstall grub to change the image, you just have to change the symlink. Make sure any symlink does not point to a file on another partition, for instance if you have /boot on a separate partition. Here is an image of the GNU by Peter Gerwinski: https://help.ubuntu.com/community/GrubHowto?action=AttachFile&do=get&target=gnu-head.xpm.gz

Splash Image with update-grub

The command update-grub will automatically pick up /boot/grub/splash.xpm.gz and configure the menu.lst file for you. It will take care of the correct hdX and partition number [no need to type in (hd0,4)].

sudo apt-get install grub-splashimages
sudo ln -s /boot/grub/splashimages/my_image.xpm.gz /boot/grub/splash.xpm.gz
sudo update-grub

Note: replace the my_image.xpm.gz with the one that you want.

Creating a boot floppy

You can use grub to create a boot floppy. See UbuntuHelp:/BootFloppy

Change the default operating system

By default, Grub in Ubuntu boots Ubuntu by default. If you wish to change this to another operating system, see UbuntuHelp:/ChangeDefaultOS

Network booting

If you use LTSP or Edubuntu, you may want to boot from your network card. Specific network cards need a specifc rom to boot from. To find which one you need, run lsmod and then search for your floppy. Then go to www.rom-o-matic.com and get the appropriate rom. Edit `/boot/grub/menu.lst` and add the following before ### BEGIN AUTOMAGIC KERNELS LIST or after ### END DEBIAN AUTOMAGIC KERNELS LIST, otherwise your changes will be wiped out by security updates, etc.

title LTSP
root (hd0,2)
kernel /boot/(rom you get from rom-o-matic)

Security

By editing the boot command in grub, root access can be gained without the need of a password. To avoid this, edit the part "## password ['--md5'] passwd" of `/boot/grub/menu.lst`:

password yourfancyplaintextpassword

Insert the password of your choice. To prevent normal users to read this password, you should also remove read permission for these:

sudo chmod o-r /boot/grub/menu.lst

You can also use a md5 password, more info in the Gentoo Security Handbook.

More information

The official GNU GRUB manual has a "DOS/Windows" chapter with hints on setting up dual-boot systems. This page has a lot of Grub information (and other general information).