+<a name="efi_shell">
+<h3>Using an EFI Shell to Adjust Your Boot Priority</h3>
+</a>
+
+<p>Version 2 of the EFI shell provides a command, <tt>bcfg</tt>, which can adjust the EFI boot order. Unfortunately, this tool is not present in version 1 of the EFI shell, and version 2 is reliable only with EFI version 2.3 and later. To date (early 2016), all Intel-based Macs use EFI 1.1, and many PCs sold prior to Windows 8's release use UEFI (EFI 2.x) versions prior to 2.3. Thus, this approach may not work for you.</p>
+
+<p>Even if your computer works with a version 2 shell, it may not have one built in. In fact, most EFIs I've seen lack a built-in shell. If a shell is available, it should appear on the EFI's built-in boot manager, as described earlier, in <a href="#evade_guards">Evading the Guards: Performing a One-Time Boot to Your Desired OS.</p> If a shell is not built into your firmware, you can add one; here are a few links that may be helpful:</p>
+
+<ul>
+
+<li><a href="https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi"><i>x</i>86-64 (64-bit) shell 2</a></li>
+
+<li><a href="https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/Ia32/Shell.efi"><i>x</i>86 (32-bit) shell 2</a></li>
+
+<li><a href="http://dl.dropbox.com/u/17629062/Shell2.zip">Alternate <i>x</i>86-64 (64-bit) shell 2 for older EFIs,</a> which <i>may</i> run on pre-2.3 EFIs</li>
+
+</ul>
+
+<p>If you need to use the shell to overcome a boot coup, your best bet is to install it to a USB flash drive and boot from it, as follows:</p>
+
+<ol>
+
+<li>Prepare a USB flash drive with a FAT filesystem. Depending on your firmware, it may need to use GPT and the partition may need to be marked as an EFI System Partition (ESP)—that is, with a type code of EF00 in <tt>gdisk</tt> or with its "boot flag" set in <tt>parted</tt> or GParted.</li>
+
+<p class="sidebar"><b>Note:</b> You can use an OS other than Linux to prepare the EFI shell boot disk, but you'll need to adjust the commands appropriately.</p>
+
+<li>Mount the USB flash drive. In this procedure, I assume it's mounted at <tt>/mnt</tt>. If you mount it elsewhere, adjust the following commands appropriately.</li>
+
+<li>Type <tt class="userinput">mkdir -p /mnt/EFI/BOOT</tt> to create the <tt>EFI/BOOT</tt> directory on the USB drive.</li>
+
+<li>Copy the shell binary you downloaded to <tt>/mnt/EFI/BOOT/bootx64.efi</tt> (for a system with a 64-bit EFI) or to <tt>/mnt/EFI/BOOT/bootia32.efi</tt> (for a system with a 32-bit EFI).</li>
+
+<li>Unmount the USB drive.</li>
+
+</ol>
+
+<p>At this point, you should have a working USB flash drive with an EFI shell. It should show up in your computer's built-in boot manager, as described earlier, in <a href="#evade_guards">Evading the Guards: Performing a One-Time Boot to Your Desired OS.</a> It will probably appear there under the brand name of the USB drive, perhaps with "UEFI" in the description. (If the boot medium shows up twice, select the option that includes "UEFI" in the description.)</p>
+
+<p>Once you've booted the EFI shell, you can follow a subset of the <a href="installing.html#efishell">EFI shell rEFInd installation instructions</a> to repair the boot coup:</p>
+
+<ol>
+
+<li>Type <tt class="userinput">bcfg boot dump -b</tt> to see a list of
+ existing NVRAM entries. Pay attention to their numbers (labelled
+ <tt>Option:</tt> and <tt>Variable:</tt>, with the latter number
+ preceded by the string <tt>Boot</tt>, as in <tt>Boot0007</tt>). Look
+ for the existing rEFInd entry.</li>
+
+<li>Type <tt class="userinput">bcfg boot mv <i>#</i> 0</tt>, substituting
+ the option number for the rEFInd entry you identified for <tt
+ class="variable">#</tt>. This moves rEFInd to the top of the boot
+ order.</li>
+
+<li>Type <tt class="userinput">reset</tt> to reboot the computer.</li>
+
+</ol>
+
+<p class="sidebar"><b>Tip:</b> If you install the EFI shell in the <tt>EFI/tools/shell.efi</tt> or <tt>EFI/tools/shellx64.efi</tt> (on x86-64 systems; <tt>EFI/TOOLS/shellia32.efi</tt> on IA-32 systems) on your hard disk's ESP, rEFInd will detect it and enable you to boot it from rEFInd. If you also register the shell with the firmware's boot manager, you'll be able to launch it that way without using the USB flash drive.</p>
+
+<p>With any luck, rEFInd will be restored as the default boot manager at this point. As with most of the methods described on this page, this procedure will do nothing to prevent future boot coups, so you may need to repeat the process in the future.</p>
+
+<p>Because of the complexity of the procedure for starting an EFI shell if one is not already prepared, this procedure works best if one is built into your EFI or if you already have one ready.</p>
+
+<a name="unstable">
+<h2>The Unstable State: Dealing With Persistent Boot Coups</h2>
+</a>
+
+<p>If your computer simply refuses to boot into rEFInd, chances are your firmware is either ignoring its boot entries or forgetting them. For the most part, which is the case doesn't really matter, since the solutions are similar for both cases. There are a few obscure exceptions, though; for instance, an entry will be ignored if it's malformed—for instance, if the filename specification includes a typo. Also, there is at least one <a href="http://mjg59.dreamwidth.org/20187.html">known bug</a> that causes the computer to ignore boot loader entries except for those named "Windows Boot Manager" or "Red Hat Enterprise Linux." Such problems can be fixed by creating a fresh NVRAM entry for rEFInd that fix the typo or give the entry the name that the EFI expects (even if it's a misleading name).</p>
+
+<p>More common are problems in which the firmware ignores or forgets its boot entries. Such problems used to be quite common, but are becoming rarer as manufacturers (slowly) improve their products. My general advice for fixing such problems is to attempt each of the following, in more-or-less the stated order:</p>
+
+<ol>
+
+<li>Upgrade your firmware. Go to the manufacturer's Web page and search for a firmware update. (Most manufacturers call these "BIOS updates.") After you apply the update, you may need to add the rEFInd entry back (re-installing it will do so).</li>
+
+<li>Reset your firmware settings to their default values. Most EFIs provide an option to do this. The idea is that corrupted settings may be causing the firmware to misbehave, so resetting everything to factory defaults may work around the problem. You may need to re-install rEFInd, or at least re-create its NVRAM entry.</li>
+
+<li>Use another tool. The Linux <tt>efibootmgr</tt> tool sometimes doesn't work correctly even when another tool does work. As noted earlier, the <a href="#bcdedit">Windows <tt>bcdedit</tt> program</a> can overcome some persistent problems related to Windows; and the EFI shell's <tt>bcfg</tt> works better than <tt>efibootmgr</tt> on a small number of EFIs.</li>
+
+<li>Return the computer for a refund. If none of the preceding steps works, chances are your firmware is just plain defective. Note that by "defective" I mean "defective by design," not a sample defect, so you should not exchange the computer for another of the same model. (Indeed, even another model of the same brand may suffer from the same problem.) Your best bet in this case is to return the product to the store for a refund and <i>write to the manufacturer about the problem.</i> Manufacturers will not fix problems that they don't know exist, so informing them of the problem is important. Unfortunately, many people learn of such problems only after having owned a computer for months, so a return is not always practical....</li>
+
+<li>Use a fallback filename. You can use <tt>mvrefind</tt> in Linux to rename rEFInd to use either of two fallback filenames:
+
+ <ul>
+
+ <li>Type <tt class="userinput">mvrefind /boot/efi/EFI/refind /boot/efi/EFI/BOOT</tt> to rename rEFInd to use the official EFI fallback filename of <tt>EFI/BOOT/bootx64.efi</tt>. (Change <tt>/boot/efi</tt> to the ESP's mount point if it's something else.) This location works well if you're single-booting Linux, or booting multiple Linux distributions.</li>
+
+ <li>Type <tt class="userinput">mvrefind /boot/efi/EFI/refind /boot/efi/EFI/Microsoft/Boot</tt> to rename the Microsoft boot loader as a backup filename and to rename rEFInd as the Microsoft boot loader (<tt>EFI/Microsoft/Boot/bootmgfw.efi</tt>). This is a somewhat confusing hack, but it's necessary on some very badly broken EFIs, particularly if you're dual-booting Windows and another OS. Unfortunately, Windows might, quite reasonably, replace rEFInd with a fresh copy of its own boot loader if a system update provides a new boot loader, or even for other reasons. Thus, you might need to re-install rEFInd and repeat this hack at some point in the future.</li>
+
+ </ul>
+
+ You can perform these actions in another OS, too, but you'll need to do so manually. See the <a href="installing.html#manual_renaming">Renaming Files Manually</a> section of the rEFInd installation page for details. If you upgrade rEFInd in the future, the <tt>refind-install</tt> script should detect rEFInd at its altered location and upgrade it there, so you should not need to repeat this step after a future rEFInd upgrade.</li>
+
+</ol>
+
+<p>Persistent boot coups may also be related to OS actions. As noted earlier, Windows will sometimes cause repeated problems, which can usually be fixed via <tt>bcdedit</tt>. I've not heard of repeated problems caused by Linux or OS X, with the exception of occasional problems caused by GRUB updates in Linux, which can be dealt with by use of <a href="#refind-mkdefault"><tt>refind-mkdefault</tt></a> in a startup or shutdown script or by <a href="#disabling_grub">disabling GRUB updates.</a></p>
+
+<p>Another thing that can produce symptoms similar to a persistent boot coup is Secure Boot. If Secure Boot is enabled on your computer and you install rEFInd without a Shim or PreLoader program, your computer will probably refuse to launch rEFInd. In this case, inserting Shim or PreLoader into the boot process, as described on the <a href="secureboot.html">rEFInd Secure Boot page,</a> normally overcomes this problem. On rare occasions, though, Shim or PreLoader won't work with a particular computer. In such a case, you may need to <a href="http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable">disable Secure Boot.</a> Note that this level of Secure Boot malfunction is quite rare. I see many posts in online forums that jump to the conclusion that Secure Boot is causing a problem, when in fact there's another more likely cause. Thus, I urge you to investigate other possibilities before concluding that Secure Boot is causing an inability to boot rEFInd.</p>
+