From Fedora Project Wiki

(Redirected page to GRUB 2)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{autolang|base=yes}}
#REDIRECT [[GRUB 2]]
= Grub2 =
 
Starting with Fedora 16, grub2 is used for new installs on x86 BIOS systems. For upgrades of BIOS systems the default is also to install grub2, but you can opt to skip bootloader configuration entirely.
 
= Tasks / Common issues =
 
== Adding Other operating systems to the grub2 menu ==
 
If you have other operating systems setup and wish to boot them via grub2:
 
{{admon/note|Note|As of the F16 Beta, os-prober should get pulled in automatically during install and used to auto-generate entries for your other installed operating systems.}}
 
<pre>
# yum install os-prober
 
# grub2-mkconfig -o /boot/grub2/grub.cfg
</pre>
 
== Setting default entry ==
 
Due to <code>grub2-mkconfig</code> (and os-prober) we cannot predict the order of the entries in /boot/grub2/grub.cfg, so we set the default by name/title instead. To do this, first, we set <pre>GRUB_DEFAULT=saved</pre> in <code>/etc/default/grub</code>, and run <pre>grub2-mkconfig -o /boot/grub2/grub.cfg</pre> to update grub.cfg. Then we call <pre>grub2-set-default <title or number></pre> with the title of the newly installed Fedora's entry. From that point on you can change the default by calling <pre>grub2-set-default <title or number></pre> or view it by running <pre>grub2-editenv list</pre>
 
To do that, you'll need the list of possible menu entries, which you can find with
<pre>grep menuentry /boot/grub2/grub.cfg</pre> (Surely there's a better way?)
 
{{admon/note|Note|There are other, simpler, ways of setting the default entry, but they are prone to error if/when grub2-mkconfig is re-run. These include directly setting the default in /boot/grub2/grub.cfg or setting GRUB_DEFAULT to either a number or an entry title in /etc/default/grub. Neither of these methods is recommended.}}
 
If you understand the risks involved and still want to directly modify /boot/grub2/grub.cfg, here's how you can do it:
 
Edit /boot/grub2/grub.cfg, and change the line
 
{{admon/caution|This is not the recommended method|This will not survive grub2-mkconfig. It might not even survive a kernel update.}}
 
<pre>
set default="0"
</pre>
 
to
<pre>
set default="5"
</pre>
 
== Updating Grub configuration ==
 
It is safe to directly edit /boot/grub2/grub.cfg in Fedora.  Grubby in Fedora modifies the configuration when a kernel update is performed but does so in a safe manner. Other distributions, in particular Debian and Debian derived distributions provide a distribution-specific patch that adds an {{command|update-grub}} command.
 
== Encountering the dreaded Grub2 boot prompt ==
If improperly configured, Grub2 may fail to load and dropping to a boot prompt. To address this issue, proceed as follows:
1. List the drives which Grub2 sees:
<pre>
grub2> ls
</pre>
 
2. The output for a dos partition table /dev/sda with three partitons will look something like this:
<pre>
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)
</pre>
 
3.  While the output for a gpt partition table /dev/sda with four partitions will look something like this:
<pre>
(hd0) (hd0,gpt4) (hd0,gpt3)  (hd0,gpt2) (hd0,gpt1)
</pre>
 
4. With this information you can now probe each partition of the drive and locate your vmlinuz and initramfs files:
<pre>
ls (hd0,1)/
</pre>
Will list the files on /dev/sda1. If this partition contains /boot, the output will show the full name of vmlinuz and initramfs.
 
5. Armed with the location and full name of vmlinuz and initramfs you can "bootstrap" boot your system.
 
5a. Declare your root partition:
<pre>
grub> set root=(hd0,3)
</pre>
 
5b. Declare the kernel you want to use:
<pre>
grub> linux (hd0,1)/vmlinuz-3.0.0-1.fc16.i686 root=/dev/sda3 rhgb quiet selinux=0
# NOTE : add other kernel args if you have need of them
# NOTE : change the numbers to match your system
</pre>
 
5c. Declare the initrd to use:
<pre> 
grub> initrd (hd0,1)/initramfs-3.0.0-1.fc16.i686.img
# NOTE : change the numbers to match your system
</pre>
 
5d. Instruct Grub2 to boot the chosen files:
<pre>
grub> boot
</pre>
 
6. After boot, open a terminal.
 
7. Issue the grub2-mkconfig command to re-create the grub.cfg file grub2 needed to boot your system:
<pre>
grub2-mkconfig -o /boot/grub2/grub.cfg
</pre>
 
8. Issue the grub2-install command to install grub2 to your hard drive and make use of your config:
<pre>
grub2-install --boot-directory=/boot /dev/sda
# Note: your drive may have another device name. Check for it with mount command output.
</pre>
 
== Other issues ==
 
'''Other grub2 issues''': it refuses to install on partition's boot sector (maybe can be forced?) and, !!! this is important !!!, it fails to install if for whatever reason your floppy controller is activated in BIOS and there's no drive connected or floppy disk inserted. The workaround is to run (post OS install) from rescue mode:
 
<pre>
grub2-install <target device> --no-floppy
</pre>
 
= Further Reading =
 
http://www.gnu.org/software/grub/manual/grub.html
 
http://fedoraproject.org/wiki/Features/Grub2
 
http://fedoraproject.org/wiki/Anaconda/Features/Grub2Migration

Latest revision as of 22:10, 18 March 2012

Redirect to: