d15742b166ff92efab1c10ba3c1083b66e7d6f5d
[refind] / docs / refind / bootcoup.html
1 <?xml version="1.0" encoding="utf-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head>
7 <title>The rEFInd Boot Manager: Keeping rEFInd Booting</title>
8 <link href="../Styles/styles.css" rel="stylesheet" type="text/css" />
9 </head>
10
11 <meta name="viewport" content="width=device-width, initial-scale=1">
12
13 <body>
14 <h1>The rEFInd Boot Manager:<br />Keeping rEFInd Booting</h1>
15
16 <p class="subhead">by Roderick W. Smith, <a
17 href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
18
19 <p>Originally written: 1/28/2016, referencing rEFInd 0.10.2</p>
20
21
22 <p>This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!</p>
23
24 <table border="1">
25 <tr>
26 <td>Donate $1.00</td>
27 <td>Donate $2.50</td>
28 <td>Donate $5.00</td>
29 <td>Donate $10.00</td>
30 <td>Donate $20.00</td>
31 <td>Donate another value</td>
32 </tr>
33 <tr>
34
35 <td>
36 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
37 <input type="hidden" name="cmd" value="_donations">
38 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
39 <input type="hidden" name="lc" value="US">
40 <input type="hidden" name="no_note" value="0">
41 <input type="hidden" name="currency_code" value="USD">
42 <input type="hidden" name="amount" value="1.00">
43 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
44 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
45 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
46 </form>
47 </td>
48
49 <td>
50 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
51 <input type="hidden" name="cmd" value="_donations">
52 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
53 <input type="hidden" name="lc" value="US">
54 <input type="hidden" name="no_note" value="0">
55 <input type="hidden" name="currency_code" value="USD">
56 <input type="hidden" name="amount" value="2.50">
57 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
58 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
59 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
60 </form>
61 </td>
62
63
64 <td>
65 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
66 <input type="hidden" name="cmd" value="_donations">
67 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
68 <input type="hidden" name="lc" value="US">
69 <input type="hidden" name="no_note" value="0">
70 <input type="hidden" name="currency_code" value="USD">
71 <input type="hidden" name="amount" value="5.00">
72 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
73 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
74 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
75 </form>
76 </td>
77
78 <td>
79 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
80 <input type="hidden" name="cmd" value="_donations">
81 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
82 <input type="hidden" name="lc" value="US">
83 <input type="hidden" name="no_note" value="0">
84 <input type="hidden" name="currency_code" value="USD">
85 <input type="hidden" name="amount" value="10.00">
86 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
87 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
88 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
89 </form>
90 </td>
91
92 <td>
93 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
94 <input type="hidden" name="cmd" value="_donations">
95 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
96 <input type="hidden" name="lc" value="US">
97 <input type="hidden" name="no_note" value="0">
98 <input type="hidden" name="currency_code" value="USD">
99 <input type="hidden" name="amount" value="20.00">
100 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
101 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
102 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
103 </form>
104 </td>
105
106 <td>
107 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
108 <input type="hidden" name="cmd" value="_donations">
109 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
110 <input type="hidden" name="lc" value="US">
111 <input type="hidden" name="no_note" value="0">
112 <input type="hidden" name="currency_code" value="USD">
113 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
114 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
115 <input type="image" src="donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
116 </form>
117 </td></tr>
118 </table>
119
120 <hr />
121
122 <p>This page is part of the documentation for the rEFInd boot manager. If a Web search has brought you here, you may want to start at the <a href="index.html">main page.</a></p>
123
124 <hr />
125
126 <div style="float:right; width:55%">
127
128 <p>Once you've installed rEFInd, you may face a new challenge: Keeping it set as your default boot manager. Users of multi-boot computers have long faced similar challenges, because most OSes provide mechanisms to keep themselves booting, even at the cost of disrupting other OSes&mdash;or overriding your own choices. On this page, I refer to such unwanted changes as <i>boot coups.</i> Experienced multi-booters know the tools and techniques to avoid or recover from boot coups. If you're new to the EFI world, though, most of the techniques you may know for helping with BIOS-mode booting don't apply to EFI-mode booting.</p>
129
130 <p>This page describes tools and techniques you can use to keep rEFInd set as your default boot manager, or at least to recover it as the default boot option if something else takes over. This page is organized by OS, describing the tools and techniques you can use in each OS to recover from a boot coup&mdash;or in some cases, to prevent one from occurring. I begin and end with information on firmware-based tools, though. Chances are you should not read this page straight through; instead, peruse the Contents to the left and pick and OS and, perhaps, a recovery tool or technique you wish to pursue and read the relevant section. In most cases, the recovery technique is fairly quick and painless, once you understand how to do it.</p>
131
132 </div>
133
134 <div class="navbar">
135
136 <h4 class="tight">Contents</h4>
137
138 <ul class="tight">
139
140 <li class="tight"><a href="#evade_guards">Evading the Guards: Performing a One-Time Boot to Your Desired OS</a></li>
141
142 <li class="tight"><a href="#counter_revolution">Staging a Counter-Revolution: Re-Installing rEFInd</a></li>
143
144 <li class="tight"><a href="#linux">Recovering from a Coup Using Linux</a>
145
146 <ul class="tight">
147
148 <li class="tight"><a href="#refind-mkdefault">Using <tt>refind-mkdefault</tt> to Adjust Your Boot Priority</a></li>
149
150 <li class="tight"><a href="#efibootmgr">Using <tt>efibootmgr</tt> to Adjust Your Boot Priority</a></li>
151
152 <li class="tight"><a href="#disabling_grub">Preventing a Linux Coup by Disabling GRUB Updates</a></li>
153
154 </ul></li>
155
156 <li class="tight"><a href="#osx">Recovering from a Coup Using OS X</a>
157
158 <ul class="tight">
159
160 <li class="tight"><a href="#startup_disk">Using Startup Disk to Adjust Your Boot Priority</a></li>
161
162 <li class="tight"><a href="#bless">Using <tt>bless</tt> to Adjust Your Boot Priority</a></li>
163
164 </ul></li>
165
166 <li class="tight"><a href="#windows">Recovering from a Coup Using Windows</a>
167
168 <ul class="tight">
169
170 <li class="tight"><a href="#easyuefi">Using EasyUEFI to Adjust Your Boot Priority</a></li>
171
172 <li class="tight"><a href="#bcdedit">Using <tt>bcdedit</tt> to Adjust Your Boot Priority</a></li>
173
174 </ul></li>
175
176 <li class="tight"><a href="#firmware">Using Your Firmware to Repair a Boot Coup</a></li>
177
178 </ul>
179
180 </div>
181
182 <a name="evade_guards">
183 <h2>Evading the Guards: Performing a One-Time Boot to Your Desired OS</h2>
184 </a>
185
186 <p>Most EFIs provide their own build-in boot managers. These tools are primitive, and in some cases they can be difficult to reach, but they can be useful if you need to bypass a new system default in order to boot an OS that has the tools you need to control the boot process.</p>
187
188 <p>On Macs, holding the Option key (usually Alt with a PC keyboard) brings up the Mac's boot manager. Typically, the Esc key, Enter key, or a function key (usually F8 or above) does the job on UEFI-based PCs. Some computers provide a prompt for what key will do the job, but this isn't always true. Sometimes the keyboard is disabled in the early stages of the boot process by default&mdash;part of a strategy to speed up system boots. Disabling a "fast start" feature in the firmware may work around this problem.</p>
189
190 <p>Once you've found the built-in boot manager, you'll see its display, which is typically a text-mode listing of boot options. On UEFI-based PCs, the user interface is typically similar to the one used in years past on BIOS-based computers to select the boot device; it's simply been upgraded to include the descriptions held in NVRAM for specific boot loaders. (In fact, prompts are often outdated and misleading; as in the below example, they may refer to "boot devices," when in fact most of the options are EFI boot loader programs.) As an example, an ASUS P8 H77-I's boot manager looks like this:</p>
191
192 <br /><center><img src="asus-bootmanager.jpg" align="center" width="392"
193 height="268" alt="A typical EFI boot manager display is very
194 rudimentary." border=2> </center><br />
195
196 <p>You typically select the option you want to boot by using the arrow keys, then hit the Enter key to boot it. If rEFInd is working but has been overridden as the default, you can select it; or if your preferred OS has its own option, you may be able to launch it directly.</p>
197
198 <p>Keep in mind, though, that some of the options on the built-in boot manager's menu may not work, or may work in unexpected ways. For instance, you might see options to boot hard disks in BIOS/CSM/legacy mode. These options might not work; and even if they do, they'll boot the computer in BIOS mode, so you won't be able to use the tools described on this page to correct your boot problems.</p>
199
200 <a name="counter_revolution">
201 <h2>Staging a Counter-Revolution: Re-Installing rEFInd</h2>
202 </a>
203
204 <p>The most general, and in some cases the easiest, solution to a boot coup is to re-install rEFInd. If you haven't updated rEFInd in a while, this approach has the advantage of providing an update to rEFInd (assuming you first download the latest version). The <a href="installing.html">Installing rEFInd</a> page describes how to install rEFInd from Linux, OS X, Windows, or an EFI shell. The <tt>refind-install</tt> script preserves your existing <tt>refind.conf</tt> configuration file, so an upgrade should not affect your customizations. (The rEFInd icons will be updated to the latest versions, but <tt>refind-install</tt> moves the original icons to a backup directory, so you can restore them if you've customized them or if they've changed and you don't like the new icons.)</p>
205
206 <p>One possible complication to this approach is if you're stuck booting in an unfamiliar OS. In such a case, you may be able to boot into your preferred OS on a one-time basis by using your computer's built-in boot manager. The trouble is that how you do this varies greatly from one computer to another. On a Mac, you should hold down the Option key as the startup chime sounds. On a UEFI-based PC, you can usually access a boot manager menu by hitting the Esc, Enter, or a function key (typically F8 or above) soon after powering on the computer. Some modern computers disable this functionality in the interest of speeding the boot process. You can often re-enable it by disabling the "fast start" option in the firmware&mdash;but entering the firmware presents an equal challenge. Microsoft provides a way to do this in Windows 8 and later; see <a href="https://support.lenovo.com/us/en/documents/ht081446">this Lenovo page</a> for documentation on how to use this feature. (The same procedure works on any brand of computer.)</p>
207
208 <a name="linux">
209 <h2>Recovering from a Coup Using Linux</h2>
210 </a>
211
212 <p>Linux's primary tool for adjusting the EFI boot order is <tt>efibootmgr</tt>. If you installed rEFInd from Linux, chances are you used this tool, even if you don't realize it. (The <tt>refind-install</tt> script calls <tt>efibootmgr</tt>, and this script is called automatically by the rEFInd RPM and Debian packages). The easiest way to do this is to use the <a href="#refind-mkdefault"><tt>refind-mkdefault</tt> script</a>. A more complex but flexible approach is to <a href="#efibootmgr">use <tt>efibootmgr</tt> directly.</a> I also describe some steps you can take to <a href="#disabling_grub">make it less likely that Linux will stage a boot coup</a> to begin with, thus obviating the need to perform a repair.</p>
213
214 <a name="refind-mkdefault">
215 <h3>Using <tt>refind-mkdefault</tt> to Adjust Your Boot Priority</h3>
216 </a>
217
218 <p>Since version 0.10.3, rEFInd has shipped with a script called <tt>refind-mkdefault</tt>, which uses <tt>efibootmgr</tt> to identify rEFInd and set it as the default (first) boot option. Use of this script is quite simple: Launch it as root (or via <tt>sudo</tt>):</p>
219
220 <pre class="listing">$ <tt class="userinput">sudo refind-mkdefault</tt>
221 rEFInd is not the first boot entry; adjusting....
222 Setting a boot order of 0000,0002,0085,0003,0081</pre>
223
224 <p>The exact output of the script depends on the current state of the system; it might also respond that rEFInd is already the default boot entry or that it could not identify a rEFInd entry, for instance. The boot order shown in this example is meaningless by itself; it's the boot order as identified by <tt>efibootmgr</tt>; for details, see <a href="#efibootmgr">the next section.</a></p>
225
226 <p>Instead of using <tt>refind-mkdefault</tt> manually, you might consider running it automatically at every boot or shutdown. You can, for instance, call it from <tt>/etc/rc.local</tt> or create a script in <tt>/etc/rc6.d</tt> that calls it to have it run when you shut down the computer. Details, however, vary from one distribution to another, so you should consult your distribution's documentation for details. If you use it in this way, rEFInd should correct a boot coup caused by an update to GRUB; however, this repair will happen only <i>after</i> a reboot if you call <tt>refind-mkdefault</tt> in a startup script. If you call it from a shutdown script, rEFInd should correct such a coup before it has a chance to cause problems.</p>
227
228 <p>If you've given the rEFInd entry an unusual name, you can pass the script the <tt>-L <tt class="variable">name</tt></tt> or <tt>--label <tt class="variable">name</tt></tt> option, as in:</p>
229
230 <pre class="listing">$ <tt class="userinput">sudo refind-mkdefault -L ubuntu</tt></pre>
231
232 <p>This example moves an entry that contains the string <tt>ubuntu</tt> (case-insensitive) to the top of the boot order. Thus, <tt>refind-mkdefault</tt> can set <i>any</i> boot program as the default, so long as it's already registered with the firmware. The script searches the entirety of output lines created by <tt>efibootmgr -v</tt> (as described shortly), and so it matches on descriptions, filenames, and even the obscure EFI codes that identify devices.</p>
233
234 <a name="efibootmgr">
235 <h3>Using <tt>efibootmgr</tt> to Adjust Your Boot Priority</h3>
236 </a>
237
238 <p>Adjusting your boot order in Linux is a two-step process: First you must identify the existing boot entries. With that done, you specify a new boot order. You can identify boot entries by typing <tt class="userinput">efibootmgr</tt> alone (as <tt>root</tt> or via <tt>sudo</tt>). This may be adequate; however, a more complete display, including the name of the boot loader executable, can be obtained by adding <tt>-v</tt>:</p>
239
240 <pre class="listing">
241 $ <tt class="userinput">sudo efibootmgr</tt>
242 BootCurrent: 0000
243 Timeout: 0 seconds
244 BootOrder: 0002,0000,0085,0003,0081
245 Boot0000* rEFInd Boot Manager
246 Boot0002* Windows Boot Manager
247 Boot0003* Windows Boot Manager
248 Boot0081* Mac OS X
249 Boot0085* ubuntu
250 </pre>
251
252 <p>In this example, the use of <tt>-v</tt> was not necessary, because the labels were clear and accurate; you can see that the <tt>BootOrder</tt> line identifies a boot order of <tt>Boot0002</tt> (Windows) followed by <tt>Boot0000</tt> (rEFInd), then various others. If you're in doubt, you can examine the complete output with <tt>efibootmgr -v</tt>:</p>
253
254 <pre class="listing"
255 $ <tt class="userinput">sudo efibootmgr -v</tt>
256 BootCurrent: 0000
257 Timeout: 0 seconds
258 BootOrder: 0002,0000,0085,0003,0081
259 Boot0000* rEFInd Boot Manager HD(1,800,113000,2491a00e-2a89-4dc4-af21-34c436c8f88a)File(\EFI\refind\shimx64.efi)
260 Boot0002* Windows Boot Manager HD(2,113800,113000,8b0b6d94-06af-4894-b9de-13ca354714a5)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
261 Boot0003* Windows Boot Manager HD(1,800,113000,2491a00e-2a89-4dc4-af21-34c436c8f88a)File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
262 Boot0081* Mac OS X Vendor(99e275e7-75a0-4b37-a2e6-c5385e6c00cb,)-.o. .-.e.e. .-.f. .e.f.i.-.a.p.p.l.e.-.p.a.y.l.o.a.d.0.-.d.a.t.a...
263 Boot0085* ubuntu HD(1,800,113000,2491a00e-2a89-4dc4-af21-34c436c8f88a)File(EFI\Ubuntu\grubx64.efi)</pre>
264
265 <p>Much of this output looks like gibberish, and is useful only for very advanced diagnostics. Note, however, the part of each line that specifies a filename, in parentheses after <tt>File</tt>&mdash;this information can help disambiguate a misleading or redundant name.</p>
266
267 <p>To adjust the boot order, you must identify the rEFInd entry and then use the <tt>-o</tt> option to <tt>efibootmgr</tt> to adjust the order:</p>
268
269 <pre class="listing">$ <tt class="userinput">sudo efibootmgr -o 0000,0085,0002,0003,0081</tt>
270 BootCurrent: 0000
271 Timeout: 0 seconds
272 BootOrder: 0000,0085,0002,0003,0081
273 Boot0000* rEFInd Boot Manager
274 Boot0002* Windows Boot Manager
275 Boot0003* Windows Boot Manager
276 Boot0081* Mac OS X
277 Boot0085* ubuntu</pre>
278
279 <p>In this example, I moved rEFInd to the top of the list, followed by <tt>ubuntu</tt> (GRUB), Windows, and OS X. You can adjust the order in any way you want. You can also omit items you don't want to include&mdash;but be aware that if you omit Windows entirely from the boot list, it's likely to add itself back (at the top of the list) the next time you boot it.</p>
280
281 <a name="disabling_grub">
282 <h3>Preventing a Linux Coup by Disabling GRUB Updates</h3>
283 </a>
284
285 <p>Once Linux is installed, the usual cause of a Linux boot coup is an update of GRUB. Such updates are relatively rare, but they can happen at any time when the distribution maintainer pushes out a version of GRUB with a bug fix. Therefore, one way to prevent a Linux boot coup is to disable such updates. Unfortunately, the details of how to do this vary from one distribution to another. Furthermore, disabling such updates has its drawbacks.</p>
286
287 <p>One problem with disabling GRUB updates is that you'll be cut off from the benefits they bring&mdash;GRUB updates are normally distributed because they contain important bug fixes. These updates might even be security-related. Of course, if you're booting via rEFInd without involving GRUB, you may not care about such updates. This possibility suggests the first way to disable GRUB updates: Remove GRUB entirely.</p>
288
289 <p>To remove GRUB, you must employ your package management system. For instance, on an RPM-based system, you might type:</p>
290
291 <pre class="listing"># <tt class="userinput">rpm -e grub2 grub2-efi grub2-tools</tt></pre>
292
293 <p>On a system that uses Debian packages, a similar command is:</p>
294
295 <pre class="listing"># <tt class="userinput">dpkg -P grub-efi-amd64 grub-efi-amd64-signed grub-common grub-efi-amd64-bin \
296 grub-common grub2-common shim-signed</tt></pre>
297
298 <p>The details of what packages you must remove vary from one distribution to another, though. (The preceding examples are from Fedora and Ubuntu installations.) If you're unsure what packages to remove, you may need to use a your package management tools to track down all GRUB-related packages. GUI tools, such as Yumex for Fedora and Synaptic for Debian-based systems, can be very helpful in this task. Unfortunately, you must sometimes remove packages that you might not want to remove&mdash;for instance, the preceding example removes <tt>shim-signed</tt> from Ubuntu because <tt>shim-signed</tt> contains a dependency on GRUB, but rEFInd can use Shim for its Secure Boot support. Fortunately, if rEFInd is already booting via Shim, removing the <tt>shim-signed</tt> package will <i>not</i> remove the <tt>shimx64.efi</tt> binary from rEFInd's directory, so the system will continue to boot.</p>
299
300 <p>Note also that removing the GRUB packages will <i>not</i> remove the files installed to the EFI System Partition (ESP), so rEFInd will continue to show a GRUB option, normally with an icon for your distribution, in its main menu. If you want to remove that menu entry, you can delete the relevant files, normally from <tt>/boot/efi/EFI/<tt class="variable">distribution_name</tt></tt>.</p>
301
302 <p>An added bonus to removing the GRUB packages is that you will no longer have to wait while GRUB's scripts scan your system every time your kernel updates. (Such scans can take well over a minute on a system with lots of installed OSes, and annoy me greatly.) Of course, these scans keep the GRUB menu up-to-date, so if they stop, GRUB will eventually stop working, even if you leave its binaries installed on your ESP.</p>
303
304 <p>One limitation to removing GRUB packages is that your distribution may try to re-install GRUB. As a workaround for Ubuntu systems, I use <a href="http://www.rodsbooks.com/refind/grub-pc_3.0-1_all.deb">this dummy package,</a> which claims to be "GRUB 3"&mdash;a version high enough that no GRUB 2 update should ever try to displace it. My "GRUB 3" dummy package contains nothing but a few empty directories.</p>
305
306 <p>A less radical approach to preventing boot coups related to GRUB updates is to use your packaging system to lock the current version in place. You can do this with Debian-based installations with the <tt>apt-mark hold</tt> command, as in:</p>
307
308 <pre class="listing"># <tt class="userinput">apt-mark hold grub-efi-amd64 grub-efi-amd64-signed grub-common grub-efi-amd64-bin \
309 grub-common grub2-common</tt></pre>
310
311 <p>You can achieve a similar result in Fedora by installing the <tt>yum-plugin-versionlock</tt> package, ensuring that <tt>enabled = 1</tt> is set in <tt>/etc/yum/pluginconf.d/versionlock.conf</tt>, and editing <tt>/etc/yum/pluginconf.d/versionlock.list</tt> to include the names and versions of packages you want to lock at a particular version.</p>
312
313 <a name="osx">
314 <h2>Recovering from a Coup Using OS X</h2>
315 </a>
316
317 <p>A boot coup that leaves a computer booting straight to OS X was most likely caused by an update to OS X&mdash;either a software update that installed a fresh copy of the OS X boot loader or a complete re-installation of the OS. In either event, the solution is conceptually similar to the Linux solution, but the tools you use to correct the problem differ. In OS X, you would either <a href="#startup_disk">use Startup Disk</a> to set rEFInd as the default or <a href="#bless">use <tt>bless</tt></a> to do the same.</p>
318
319 <a name="startup_disk">
320 <h3>Using Startup Disk to Adjust Your Boot Priority</h3>
321 </a>
322
323 <p>The Startup Disk utility appears in the System Preferences tool. Unfortunately, it will likely be useless if you installed rEFInd using <tt>refind-install</tt> and its default options, since this tool is designed to switch between OS X installations; it's not smart enough to detect a rEFInd installation and re-activate it.</p>
324
325 <p>If, however, you installed rEFInd by using the <tt>--ownhfs</tt> option to <tt>refind-install</tt>, your rEFInd installation volume should show up as an option in the Startup Disk utility. You should be able to click on it and then click Restart. Note that the name of the rEFInd volume may not be rEFInd, as it is in this screen shot; the name will match whatever volume holds rEFInd on your computer.</p>
326
327 <br /><center><img src="startup-disk.png" align="center" width="669"
328 height="402" alt="Startup Disk may enable you to reset rEFInd to being
329 the default boot program." border=2> </center><br />
330
331 <a name="bless">
332 <h3>Using <tt>bless</tt> to Adjust Your Boot Priority</h3>
333 </a>
334
335 <p>The more general solution to resetting rEFInd as the default boot manager from OS X is to follow a subset of the <a href="installing.html#osx">manual OS X installation instructions.</a> Unfortunately, some details depend on where it is installed&mdash;on the ESP, on the main OS X root (<tt>/</tt>) partition, or on a separate HFS+ volume. If rEFInd is installed on its own HFS+ partition, using Startup Disk, as described in <a href="#startup_disk">the previous section,</a> is likely to be the easier solution. For the other two options, you should first figure out where rEFInd is installed and then follow this procedure:</p>
336
337 <ol>
338
339 <li>Open a Terminal window in which you'll type the following
340 commands.</li>
341
342 <li>If rEFInd is installed on your ESP, you must first mount it. The
343 easy way to do this is to use the <tt>mountesp</tt> script that comes
344 with rEFInd. When you run it, the script should tell you where the ESP
345 was mounted. You can do the job manually by typing <b><tt>mkdir
346 /Volumes/ESP</tt></b> followed by <b><tt>sudo mount -t msdos
347 /dev/disk0s1 /Volumes/ESP</tt></b>. Note that you may need to change
348 <tt>/dev/disk0s1</tt> to something else if your ESP is at an unusual
349 location. Type <tt class="userinput">diskutil list</tt> or use a tool
350 such as my <a href="http://www.rodsbooks.com/gdisk/">GPT fdisk
351 (<tt>gdisk</tt>)</a> to examine your partition table to find your ESP
352 if necessary.</li>
353
354 <li>"Bless" rEFInd by typing one of the following two commands:
355 <ul>
356 <li>If rEFInd is installed on the ESP, type <tt
357 class="userinput">sudo bless --mount /Volumes/ESP --setBoot --file
358 /Volumes/ESP/efi/refind/refind_x64.efi --shortform</tt>, adjusting
359 the mount point and exact path to the file as appropriate for your
360 installation.</li>
361 <li>If rEFInd is installed on an ordinary HFS+ volume, type <tt
362 class="userinput">sudo bless --setBoot --folder /efi/refind --file
363 /efi/refind/refind_x64.efi</tt>. (Adjust the path and filename as
364 necessary if you're placing rEFInd somewhere else or using the
365 32-bit version.)</li>
366 </ul></li>
367
368 </ol>
369
370 <p>One major caveat is that the <tt>bless</tt> command will fail if System Integrity Protection (SIP) is active. This feature is part of OS X 10.11 (El Capitan) and later, and you will have dealt with it during rEFInd installation if it's active. See <a href="sip.html">this page of the rEFInd documentation</a> for more on this subject. You can use any of the procedures outlined there with reference to installing rEFInd for dealing with a boot coup, as well.</p>
371
372 <p>As with most of the fixes described on this page, this method of recovering from a boot coup will not protect you from future boot coups. Fortunately, OS X updates that create boot coups are fairly rare, but you'll have to resign yourself to the fact that the problem may recur in the future.</p>
373
374 <a name="windows">
375 <h2>Recovering from a Coup Using Windows</h2>
376 </a>
377
378 <p>A couple of tools exist to help you manage the boot order in Windows. The easiest of these to use is the third-party <a href="#easyuefi">EasyUEFI.</a> Microsoft's <a href="#bcdedit"><tt>bcdedit</tt>,</a> though, has the advantage of working around a problem in which Windows keeps setting its own boot manager as the default. (This problem is rare, but crops up from time to time.)</p>
379
380 <a name="easyuefi">
381 <h3>Using EasyUEFI to Adjust Your Boot Priority</h3>
382 </a>
383
384 <p>The third-party <a href="http://www.easyuefi.com/index-us.html">EasyUEFI program</a> is a user-friendly GUI tool for managing EFI boot entries. If a Windows update resets Windows as the default boot program, you can use EasyUEFI to restore rEFInd as the default. Doing so is pretty straightforward:</p>
385
386 <ol>
387
388 <li>Download and install EasyUEFI.</li>
389
390 <li>Launch EasyUEFI. The resulting display will look something like this:</li>
391
392 <br /><center><img src="easyuefi.png" align="center" width="804"
393 height="629" alt="The Windows EasyUEFI tool enables adjusting the EFI
394 boot entries in a GUI environment." border=2> </center><br />
395
396 <li>Click the rEFInd entry.</li>
397
398 <li>Click the green up-arrow button (at the top of the column of icons between the <i>Boot order</i> and <i>Detailed information</i> panes) as many times as needed to bring rEFInd to the top of the list.</li>
399
400 <li>Exit from EasyUEFI. Alternatively, you can select the Power -&gt; Reboot menu entry to reboot and test the change immediately.</li>
401
402 </ol>
403
404 <p>Note that EasyUEFI's menu shows the <i>names</i> of the boot entries. In some cases, rEFInd may be registered under another name. This is particularly likely if you used OS X's <tt>bless</tt> or Windows' <tt>bcdedit</tt> tools to register rEFInd with the firmware. You may be able to locate the rEFInd binary by examining the <i>File path</i> entry in the <i>Detailed information</i> pane, after selecting a "candidate" entry.</p>
405
406 <p>Like most of the remedies described on this page, this one makes an immediate change to the boot order but does not guarantee that the problem will not recur. In most cases, rEFInd will remain the primary boot program until it's changed again by another OS update, but all bets are off when that happens.</p>
407
408 <a name="bcdedit">
409 <h3>Using <tt>bcdedit</tt> to Adjust Your Boot Priority</h3>
410 </a>
411
412 <p>You can use a truncated version of the <a href="installing.html#windows">Windows installation instructions</a> to restore rEFInd as the default boot manager:</p>
413
414 <ol>
415
416 <li>Locate Command Prompt in the Start menu, right-click it, and select Run as Administrator. This action opens a Command Prompt window with administrative privileges.</li>
417
418 <li>Type <b><tt>bcdedit /set {bootmgr} path \EFI\refind\refind_x64.efi</tt></b> to set rEFInd as the default EFI boot program. Note that <tt>{bootmgr}</tt> is entered as such; that's not a notation for a variable. Also, change <tt>refind_x64.efi</tt> to <tt>refind_ia32.efi</tt> on systems with 32-bit EFIs. Such computers are rare, and most of them are tablets. Check your Windows bit depth to determine which binary you should use. If you use Shim or PreLoader to boot with Secure Boot active, you should change the name of the binary appropriately.</li>
419
420 <li>If you like, type <b><tt>bcdedit /set {bootmgr} description "<i>rEFInd description</i>"</tt></b> to set a description (change <tt><i>rEFInd description</i></tt> as you see fit).</li>
421
422 </ol>
423
424 <p>This procedure, unlike the EasyUEFI one, creates a new boot menu item. It requires that you know the exact path to the rEFInd binary. (If you don't know this detail, you can mount your ESP, as described in the <a href="installing.html#windows">Windows installation instructions,</a> and try to find it.) Overall, it's likely to be easier to use EasyUEFI; however, this procedure has one potential advantage: I've seen reports of cases in which Windows changes the default boot program on every boot. This procedure sometimes puts an end to such shenanigans. Thus, it can serve as a preventive measure against at least some future boot coups. I can't promise that it will work in all such cases, though. In particular, some EFIs, especially older ones, are buggy and ignore or forget their entries. Using <tt>bcdedit</tt> will not help protect against this problem.</p>
425
426 <a name="firmware">
427 <h2>Using Your Firmware to Repair a Boot Coup</h2>
428 </a>
429
430 <p>Some, but not all, EFIs provide the means to adjust the boot order themselves. The details of how this works vary greatly from one implementation to another, so I can provide only fairly broad guidance on this point. As an example, consider how to adjust the boot order with the ASUS P8 H77-I motherboard:</p>
431
432 <ol>
433
434 <li>Turn on the computer.</li>
435
436 <li>As the computer begins its Power-On Self-Test (POST), there will be a brief window in which you can hit the F2 or Del key to enter the firmware setup utility. Do so.</li>
437
438 <li>In the "EZ-Mode" menu shown below, the boot order is shown graphically near the bottom of the screen. As you move the mouse over the entries, you'll see an expansion of each one. In the screen shot below, the second item is highlighted, and you can see it's rEFInd.</li>
439
440 <br /><center><img src="asus-bootorder.jpg" align="center" width="800"
441 height="600" alt="Some EFIs provide a way to adjust the boot order."
442 border=2> </center><br />
443
444 <li>Click and drag the rEFInd entry to move it to the front of the list.</li>
445
446 <li>Hit F10 to save your changes. A dialog box will ask for confirmation; click <i>Save Changes & Reset.</i></li>
447
448 </ol>
449
450 <p>This procedure is only an example for one EFI. In fact, some EFIs, including the one in the ASUS P8 H77-I, feature multiple user interface modes. The ASUS has an "Advanced" mode, for instance, in which the procedure would be slightly different. They key point, though, is to locate whatever menu displays the boot order and use that menu to adjust it. Such a menu may be shown on the main screen, as in the case of the ASUS' "EZ-Mode," or on a menu you must select&mdash;often called "Boot" or something similar. Some EFIs, particularly for low-end fully-assembled desktop and laptop computers, lack this functionality altogether.</p>
451
452 <p>As with most other fixes described on this page, this one won't protect you from future boot coups. Most boot coups are caused by actions of an OS, so prevention must be handled on an OS-by-OS basis.</p>
453
454 <hr />
455
456 <p>copyright &copy; 2016 by Roderick W. Smith</p>
457
458 <p>This document is licensed under the terms of the <a href="FDL-1.3.txt">GNU Free Documentation License (FDL), version 1.3.</a></p>
459
460 <p>If you have problems with or comments about this Web page, please e-mail me at <a href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com.</a> Thanks.</p>
461
462 <p><a href="index.html">Go to the main rEFInd page</a></p>
463
464 <p><a href="yosemite.html">Comments on rEFInd and OS X 10.10 (Yosemite)</a></p>
465
466 <p><a href="http://www.rodsbooks.com/">Return</a> to my main Web page.</p>
467 </body>
468 </html>