pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
em em{font-style:normal}
strong strong{font-weight:400}
.keyseq{color:rgba(51,51,51,.8)}
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
<p><strong>GRUB2</strong> is the latest version of <strong>GNU GRUB</strong>, the <em>GRand Unified Bootloader</em>.
A bootloader is the first software program that runs when a computer
starts. It is responsible for loading and transferring control to the
operating system kernel. In Fedora, the kernel is Linux. The kernel then initializes
the rest of the operating system.</p>
</div>
<divclass="paragraph">
<p><strong>GRUB2</strong> is the follower of the previous version <strong>GRUB</strong> (version 0.9x). The original version is available under the name <strong>GRUB Legacy</strong>.</p>
</div>
<divclass="paragraph">
<p>Since Fedora 16, <strong>GRUB2</strong> has been the default bootloader on x86 BIOS
systems. For upgrades of BIOS systems, the default is also to install
<strong>GRUB2</strong>, but you can opt to skip bootloader configuration entirely.</p>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_installing_grub2_on_a_bios_system">Installing GRUB2 on a BIOS system</h2>
<p>Normally, <strong>GRUB2</strong> will be installed and set up by the installer, <strong>Anaconda</strong>, during the installation process. You will probably never have to deal with manual installation of <strong>GRUB2</strong>. However, in certain situations , you will want to install <strong>GRUB2</strong> manually, especially if you need to repair the existing <strong>GRUB2</strong> installation or you want to change its configuration.</p>
</div>
<divclass="paragraph">
<p>This procedure shows the steps to install <strong>GRUB2</strong> on your <em>Master Boot Record</em> (MBR) of your primary hard disk.</p>
</div>
<divclass="paragraph">
<p>Before you start:</p>
</div>
<divclass="ulist">
<divclass="title">Before you start</div>
<ul>
<li>
<p>Make sure you have the the <strong>GRUB2</strong> packages and the <code>os-prober</code> package installed in your system:</p>
<divclass="listingblock">
<divclass="content">
<pre>$ dnf list installed | grep grub</pre>
</div>
</div>
</li>
<li>
<p>To automatically collect information about your disks and operating systems installed on them, the <code>os-prober</code> package needs to be installed on your system.</p>
</li>
</ul>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Create a configuration file for <strong>GRUB2</strong>.</p>
<p>List block devices available on the system.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ lsblk</pre>
</div>
</div>
</li>
<li>
<p>Identify the primary hard disk. Usually, it is the <code>sda</code> device.</p>
</li>
<li>
<p>Install <strong>GRUB2</strong> in the MBR of the primary hard disk.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo grub2-install /dev/sda</pre>
</div>
</div>
</li>
<li>
<p>Reboot your computer to boot with the newly installed bootloader.</p>
</li>
</ol>
</div>
<divclass="ulist">
<divclass="title">More information</div>
<ul>
<li>
<p>The <code>grub2-mkconfig</code> command creates a new configuration based on the currently
running system. It collects information from the <code>/boot</code> partition (or directory), from the <code>/etc/default/grub</code> file, and the customizable scripts in <code>/etc/grub.d/</code>.</p>
</li>
<li>
<p>The configuration format is changing with time, and a new configuration
file can become slightly incompatible with the older versions of the bootloader. Always run <code>grub2-install</code> before you create the configuration file with <code>grub2-mkconfig</code>.</p>
</li>
<li>
<p>In Fedora, it is generally safe to edit <code>/boot/grub2/grub.cfg</code> manually. <strong>Grubby</strong> in Fedora patches the configuration when a kernel update is performed and will try to not make any other changes than what is necessary. Manual changes can be overwritten with <code>grub2-mkconfig</code> when the system gets upgraded with
<strong>Anaconda</strong>. Customizations placed in <code>/etc/grub.d/40_custom</code> or
<code>/boot/grub2/custom.cfg</code> files will survive running the <code>grub2-mkconfig</code> command.</p>
</li>
</ul>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_installing_grub2_on_a_uefi_system">Installing GRUB2 on a UEFI system</h2>
<p>Normally, <strong>GRUB2</strong> will be installed and set up by the installer, <strong>Anaconda</strong>, during the installation process. You will probably never have to deal with manual installation of <strong>GRUB2</strong>. However, in certain situations , you will want to install <strong>GRUB2</strong> manually, especially if you need to repair the existing <strong>GRUB2</strong> installation or you want to change its configuration.</p>
</div>
<divclass="paragraph">
<p>This procedure shows the steps to install <strong>GRUB2</strong> on a UEFI system on Fedora 18 or newer. The procedure consists of four parts.</p>
</div>
<divclass="sect2">
<h3id="_creating_an_efi_system_partition">Creating an EFI System Partition</h3>
<divid="create-an-esp"class="paragraph">
<p>The UEFI firmware requires to boot from an <em>EFI System Partition</em> on
a disk with a GPT label. To create such a partition:</p>
</div>
<divclass="olist arabic">
<olclass="arabic">
<li>
<p>List available block devices to find a place to create your ESP.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ lsblk</pre>
</div>
</div>
</li>
<li>
<p>Create at least a 128 MiB disk partition using a GPT label on the primary hard disk.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo gdisk /dev/sda</pre>
</div>
</div>
<divclass="paragraph">
<p>For the sake of this procedure, we assume that the created partition is recognized as <code>/dev/sda1</code>.</p>
</div>
</li>
<li>
<p>Format the partition with the <em>FAT32</em> file system.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mkfs.vfat /dev/sda1</pre>
</div>
</div>
</li>
<li>
<p>Create the <code>/boot/efi</code> directory as a mount point for the new partition.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mkdir /boot/efi</pre>
</div>
</div>
</li>
<li>
<p>Mount the partition to the <code>/boot/efi</code> mount point.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mount /dev/sda1 /boot/efi</pre>
</div>
</div>
</li>
<li>
<p>Proceed to the next part.</p>
</li>
</ol>
</div>
</div>
<divclass="sect2">
<h3id="_install_the_bootloader_files">Install the bootloader files</h3>
<p>When you power on your system, your firmware will look for EFI variables that tell it how to boot. On running systems, which have booted into the EFI mode and their EFI runtime services are working correctly, you can configure your boot menu with <code>efibootmgr</code>.</p>
</div>
<divclass="paragraph">
<p>If not, <code>shim</code> can help you bootstrap. The EFI program
<code>/boot/efi/EFI/BOOT/fallback.efi</code> will look for files called <code>BOOT.CSV</code>
in your ESP and will add boot entries corresponding to them. The <code>shim</code> command
provides its own <code>BOOT.CSV</code> file that will add an entry for <code>grub2-efi</code>.</p>
</div>
<divclass="paragraph">
<p>During the boot process, you can use the <strong>EFI Shell</strong> to invoke the <code>fallback.efi</code> profile to boot the system:</p>
</div>
<divclass="olist arabic">
<olclass="arabic">
<li>
<p>Enter the boot partition.</p>
<divclass="listingblock">
<divclass="content">
<pre>> fs0:</pre>
</div>
</div>
</li>
<li>
<p>Navigate into the <code>EFI\BOOT</code> directory.</p>
<divclass="listingblock">
<divclass="content">
<pre>> cd EFI\BOOT</pre>
</div>
</div>
</li>
<li>
<p>Invoke the <code>fallback.efi</code> profile.</p>
<divclass="listingblock">
<divclass="content">
<pre>> fallback.efi</pre>
</div>
</div>
</li>
</ol>
</div>
<divclass="ulist">
<divclass="title">More information</div>
<ul>
<li>
<p>If you have no boot entries at all, then just booting off your disk in
UEFI mode should automatically invoke <code>/boot/efi/EFI/BOOT/BOOTX64.EFI</code>,
which will, in turn, invoke <code>fallback.efi</code>.</p>
</li>
<li>
<p>If you already have incorrect boot entries, you’ll either need to delete
them or to modify <code>BOOT.CSV</code> to create new entries with different names.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_adding_other_operating_systems_to_the_strong_grub2_strong_menu">Adding other operating systems to the <strong>GRUB2</strong> menu</h2>
<p>Normally, <strong>GRUB2</strong> is preset to boot multiple operating systems during the Fedora installation process. If you can, it is advisable to install non-Linux operating systems first. Then, during the installation process, all those operating systems and their locations will be discovered and properly set.</p>
</div>
<divclass="paragraph">
<p>Adding other records into the <strong>GRUB2</strong> menu only means to run <code>grub2-mkconfig</code> command to regenerate the configuration files. During this process, all operating systems known to the system will be added into the configuration. By reinstalling <strong>GRUB2</strong> into the MBR, this configuration will be used for further boots.</p>
</div>
<divclass="ulist">
<divclass="title">Before you start</div>
<ul>
<li>
<p>Make sure that the operating systems are on disks, connected to the system.</p>
</li>
<li>
<p>You have the <code>os-prober</code> package installed.</p>
</li>
</ul>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Recreate the <strong>GRUB2</strong> configuration file.</p>
<p>Install <strong>GRUB2</strong> into the MBR of your primary hard disk.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo grub2-install /dev/sda</pre>
</div>
</div>
</li>
</ol>
</div>
<divclass="ulist">
<divclass="title">More information</div>
<ul>
<li>
<p>The <code>grub2-mkconfig</code> command will add entries for all operating systems it can find.</p>
</li>
<li>
<p>When problems appear, see the <ahref="http://www.gnu.org/software/grub/manual/grub.html#Multi_002dboot-manual-config">GRUB manual</a> to solve issues with booting secondary operating systems.</p>
</li>
</ul>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_setting_default_entry_for_strong_grub2_strong">Setting default entry for <strong>GRUB2</strong></h2>
<divclass="sectionbody">
<divid="setting-default-entry"class="paragraph">
<p>Since <code>grub2-mkconfig</code> (and <strong>os-prober</strong>) cannot estimate which operating system, of those it finds, is to be marked as default, we usually are unable to predict the order of
the entries in <code>/boot/grub2/grub.cfg</code>. To change the default layout, we need to set the default based on the <code>name</code> or <code>title</code>.</p>
</div>
<divclass="olist arabic">
<divclass="title">Before you start</div>
<olclass="arabic">
<li>
<p>Open <code>/etc/default/grub</code> and make sure these lines exist in the file.</p>
<divclass="listingblock">
<divclass="content">
<pre>GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=false</pre>
</div>
</div>
</li>
<li>
<p>If you needed to change the content of the <code>/etc/default/grub</code>, apply the changes to <code>grub.cfg</code>.</p>
<p>Regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>
</li>
</ol>
</div>
<divclass="paragraph">
<divclass="title">More information</div>
<p>If you understand the risks involved, you can manually modify the
<code>/boot/grub2/grub.cfg</code> file. In that case, set the number of the default operating system using the <code>set default</code> variable.</p>
</div>
<divclass="paragraph">
<p>For example:</p>
</div>
<divclass="listingblock">
<divclass="content">
<pre>set default="5"</pre>
</div>
</div>
<divclass="admonitionblock note">
<table>
<tr>
<tdclass="icon">
<divclass="title">Note</div>
</td>
<tdclass="content">
<divclass="paragraph">
<p>If you edit the configuration file manually, the settings will be overwritten each time the <code>grub2-mkconfig</code> command runs.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_restoring_the_bootloader_using_the_live_disk">Restoring the bootloader using the Live disk.</h2>
<p>Sometimes, especially after a secondary operating systems has been installed, the master boot record gets damaged which then prevents the original Linux system from booting.</p>
</div>
<divclass="paragraph">
<p>If this happens, it is necessary to reinstall <strong>GRUB2</strong> to recreate the original settings. The process not only discovers all installed operating systems, but usually adds them to the <strong>GRUB2</strong> configuration files, so they will all become bootable by <strong>GRUB2</strong>.</p>
</div>
<divclass="ulist">
<divclass="title">Before you start</div>
<ul>
<li>
<p>Get the Fedora Live ISO from <ahref="https://download.fedoraproject.org/pub/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-27-1.6.iso">getfedora.org</a>.</p>
</li>
<li>
<p>Prepare a bootable device using the downloaded ISO, either a CD or a USB.</p>
</li>
</ul>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Boot the Fedora live system from the bootable device you have created.</p>
</li>
<li>
<p>Open the terminal.</p>
</li>
<li>
<p>Examine the partition layout and identify the <code>boot</code> and the <code>root</code> partition.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo fdisk -l</pre>
</div>
</div>
<divclass="paragraph">
<p>If you are using the default Fedora layout, there will be one <code>/dev/sda1</code> partition that holds the <code>/boot</code> directory and one <code>/dev/mapper/fedora-root</code> that holds the root file system.</p>
</div>
</li>
<li>
<p>Create the mount point for the root partition.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mkdir -p /mnt/root</pre>
</div>
</div>
</li>
<li>
<p>Mount the root partition on the mount point.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mount /dev/mapper/fedora-root /mnt/root</pre>
</div>
</div>
</li>
<li>
<p>Mount the boot partition in the <code>boot</code> directory of the filesystem that you have mounted in the previous step.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mount /dev/sda1 /mnt/root/boot/</pre>
</div>
</div>
</li>
<li>
<p>Mount system processes and devices into the root filesystem in <code>/mnt/root</code>.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo mount -o bind /dev /mnt/root/dev
$ sudo mount -o bind /proc /mnt/root/proc
$ sudo mount -o bind /sys /mnt/root/sys
$ sudo mount -o bind /run /mnt/root/run</pre>
</div>
</div>
</li>
<li>
<p>Change your filesystem into the one mounted under <code>/mnt/root</code>.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo chroot /mnt/root</pre>
</div>
</div>
</li>
<li>
<p>Regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>
</li>
<li>
<p>Exit this temporary root filesystem.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ exit</pre>
</div>
</div>
</li>
<li>
<p>Your bootloader should be now restored. Reboot your computer to boot into your normal system.</p>
<divclass="listingblock">
<divclass="content">
<pre>$ sudo systemctl reboot</pre>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_using_the_grub2_boot_prompt">Using the GRUB2 boot prompt</h2>
<p>Examine the output to understand the partition table of the <code>/dev/sda</code> device. The following example shows a DOS partition table with three partitions:</p>
<p>The outcome of the previous command will list the files on <code>/dev/sda1</code>. The partition that contains the <code>/boot</code> directory is the correct one. There you will search for the full names of the <code>vmlinuz</code> and <code>initramfs</code> files.</p>
<p>This command tells the bootloader, that the root partition is the third partition on the first drive. This would correspond to the <code>/dev/sda3</code> device.</p>
# NOTE : change the numbers to match your system</pre>
</div>
</div>
</li>
<li>
<p>Boot with the selected settings.</p>
<divclass="listingblock">
<divclass="content">
<pre>grub> boot</pre>
</div>
</div>
</li>
<li>
<p>To restore the bootloader’s functionality, regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>
</li>
</ol>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_booting_the_system_using_a_configuration_file_on_a_different_partition">Booting the system using a configuration file on a different partition.</h2>
<p>If you end up in <strong>GRUB2</strong> boot prompt, it is also possible to boot using a <em>configfile</em> that’s located on another
partition, as is often the case with multi-boot systems containing Ubuntu and Fedora. To boot the system using a configuration files on a different partition:</p>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Load necessary modules to read the partitions.</p>
<divclass="listingblock">
<divclass="content">
<pre>insmod part_msdos
insmod xfs
insmod lvm</pre>
</div>
</div>
</li>
<li>
<p>Set the root partition.</p>
<divclass="listingblock">
<divclass="content">
<pre>set root='hd0,msdos1'</pre>
</div>
</div>
</li>
<li>
<p>Set the path to the configuration file.</p>
<divclass="listingblock">
<divclass="content">
<pre>configfile /grub2/grub.cfg</pre>
</div>
</div>
</li>
</ol>
</div>
<divclass="ulist">
<divclass="title">More information</div>
<ul>
<li>
<p>The <strong>hd0,msdos1</strong> line shows the pertinent <em>boot</em> partition, which holds the
<code>grub.cfg</code> file. The setting may be different on your system. See also <ahref="#using-grub2-prompt">Using the GRUB2 boot prompt</a> for more information.</p>
</li>
</ul>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_setting_a_password_for_interactive_edit_mode">Setting a password for interactive edit mode</h2>
<p>If you wish to protect the <strong>GRUB2</strong> interactive edit mode with a password, but allow ordinary users to boot the computer, you have to create a definition file where you set up this functionality:</p>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Create the <code>/etc/grub.d/01_users</code> file and write the following lines into the file.</p>
<divclass="listingblock">
<divclass="content">
<pre>set superusers="root"
export superusers
password root <password></pre>
</div>
</div>
</li>
<li>
<p>Regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>
</li>
</ol>
</div>
<divclass="paragraph">
<divclass="title">More information</div>
<p>You can encrypt the password by using <strong>pbkdf2</strong>. Use <code>grub2-mkpasswd-pbkdf2</code>
to encrypt the password, then replace the password line with:</p>
<p>Starting from Fedora 21, the <code>--md5pass</code> kickstart option must be used when using the <code>grub2-mkpasswd-pbkdf2</code> command.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<divclass="sect1">
<h2id="solving-absent-floppy">Dealing with the "Absent Floppy Disk" Error</h2>
<divclass="sectionbody">
<divclass="paragraph">
<p>It has been reported by some users that <strong>GRUB2</strong> may fail to install on a partition’s boot sector if the computer’s floppy controller is activated in BIOS without an actual floppy disk
drive being present. Such situations resulted in an <em>Absent Floppy Disk</em> error.</p>
</div>
<divclass="paragraph">
<p>To workaround this issue, go into the rescue mode and follow the procedure in <ahref="#installing-grub-2-on-a-bios-system">Installing GRUB2 on a BIOS system</a><strong>GRUB2</strong>, but use the <code>--no-floppy</code> option with the <code>grub2-install</code> command.</p>
<p>The terminal device is chosen with GRUB_TERMINAL. For more information, see the <ahref="http://www.gnu.org/software/grub/manual/grub.html#Simple-configuration">Grub manual</a>.</p>
</div>
<divclass="paragraph">
<p>Valid terminal output names depend on the platform, but may include
<code>console</code> (PC BIOS and EFI consoles), <code>serial</code> (serial terminal),
or <code>vga_text</code> (VGA text output, mainly useful with Coreboot).</p>
</div>
<divclass="paragraph">
<p>The default is to use the platform’s native terminal output.</p>
</div>
<divclass="paragraph">
<p>In Fedora, <code>gfxterm</code> is the default options. To get the legacy graphics modes:</p>
</div>
<divclass="olist arabic">
<divclass="title">Procedure</div>
<olclass="arabic">
<li>
<p>Edit the <code>/etc/default/grub</code> file.</p>
</li>
<li>
<p>Set the <code>GRUB_TERMINAL</code> variable to one of the above mentioned options.</p>
</li>
<li>
<p>Regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>
</li>
</ol>
</div>
</div>
</div>
<divclass="sect1">
<h2id="_enabling_serial_console_in_grub2">Enabling Serial Console in GRUB2</h2>
<p>Edit the <code>/etc/default/grub</code> file.</p>
</li>
<li>
<p>Adjust <code>baudrate</code>, <code>parity</code>, <code>bits</code>, and <code>flow</code> controls to fit your environment and cables, see the example.</p>
<p>Regenerate the <strong>GRUB2</strong> configuration file and reinstall the bootloader into the MBR, as described in <ahref="#adding-other-operating-systems-grub2">Adding other operating systems to the <strong>GRUB2</strong> menu</a>.</p>