]> code.delx.au - refind/blob - docs/refind/installing.html
Improvements to install.sh to better handle installs from BIOS-mode
[refind] / docs / refind / installing.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: Installing rEFInd</title>
8 <link href="../Styles/styles.css" rel="stylesheet" type="text/css" />
9 </head>
10
11 <body>
12 <h1>The rEFInd Boot Manager:<br />Installing rEFInd</h1>
13
14 <p class="subhead">by Roderick W. Smith, <a
15 href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
16
17 <p>Originally written: 3/14/2012; last Web page update:
18 12/31/2012, referencing rEFInd 0.6.2-2</p>
19
20
21 <p>I'm a technical writer and consultant specializing in Linux technologies. 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>
22
23 <table border="1">
24 <tr>
25 <td>Donate $1.00</td>
26 <td>Donate $2.50</td>
27 <td>Donate $5.00</td>
28 <td>Donate $10.00</td>
29 <td>Donate another value</td>
30 </tr>
31 <tr>
32 <td><form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
33 <input type="hidden" name="cmd" value="_xclick">
34 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
35 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
36 <input type="hidden" name="currency_code" value="USD">
37 <input type="hidden" name="amount" value="1.00">
38 <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
39 </form>
40
41 </td>
42 <td><form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
43 <input type="hidden" name="cmd" value="_xclick">
44 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
45 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
46 <input type="hidden" name="currency_code" value="USD">
47 <input type="hidden" name="amount" value="2.50">
48 <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
49 </form>
50
51 </td>
52 <td><form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
53 <input type="hidden" name="cmd" value="_xclick">
54 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
55 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
56 <input type="hidden" name="currency_code" value="USD">
57 <input type="hidden" name="amount" value="5.00">
58 <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
59 </form>
60
61 </td>
62 <td><form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
63 <input type="hidden" name="cmd" value="_xclick">
64 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
65 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
66 <input type="hidden" name="currency_code" value="USD">
67 <input type="hidden" name="amount" value="10.00">
68 <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
69 </form>
70
71 </td>
72 <td>
73 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
74 <input type="hidden" name="cmd" value="_donations">
75 <input type="hidden" name="business" value="rodsmith@rodsbooks.com">
76 <input type="hidden" name="lc" value="US">
77 <input type="hidden" name="no_note" value="0">
78 <input type="hidden" name="currency_code" value="USD">
79 <input type="hidden" name="item_name" value="rEFInd Boot Manager">
80 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest">
81 <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
82 <img alt="Donate with PayPal" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
83 </form>
84 </td></tr>
85 </table>
86
87 <hr />
88
89 <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>
90
91 <hr />
92
93 <div style="float:right; width:55%">
94
95 <p>Once you've obtained a rEFInd binary file, you must install it to your computer's ESP (or conceivably to some other location). The details of how you do this depend on your OS and your computer (UEFI-based PC vs. Macintosh). The upcoming sections provide details. See the Contents sidebar to the left for links to specific installation procedures. For most Linux users, an RPM or Debian package is the best way to go. If your Linux system doesn't support these formats, though, or if you're running OS X, using the <tt>install.sh</tt> script can be a good way to go. If you're using Windows, you'll have to install manually.</p>
96
97 <p class="sidebar" style="width:95%"><b>Important:</b> A rEFInd zip file, when uncompressed, creates a directory called <tt>refind-<i>version</i></tt>, where <tt><i>version</i></tt> is the version number. This directory includes a subdirectory called <tt>refind</tt> that holds the boot loader, along with another that holds documentation, as well as miscellaneous files in <tt>refind-<i>version</i></tt> itself. When I refer to "the <tt>refind</tt> directory" on this page, I mean the directory with that precise name, not the <tt>refind-<i>version</i></tt> directory that is its parent.</p>
98
99 </div>
100
101 <div class="navbar">
102
103 <h4 class="tight">Contents</h4>
104
105 <ul class="tight">
106
107 <li class="tight"><a href="#packagefile">Installing rEFInd using an RPM or Debian package file</a></li>
108
109 <li class="tight"><a href="#installsh">Installing rEFInd Using <tt>install.sh</tt> under Linux or Mac OS X</a>
110
111 <ul class="tight">
112
113 <li class="tight"><a href="#quickstart">Quick <tt>install.sh</tt> Instructions</a></li>
114
115 <li class="tight"><a href="#extra_installsh">Extra <tt>install.sh</tt> Instructions</a></li>
116
117 <li class="tight"><a href="#unhijack">Using <tt>refind-unhijack.sh</tt></li>
118
119 </ul></li>
120
121 <li class="tight"><a href="#manual">Installing rEFInd Manually</a>
122
123 <ul>
124
125 <li class="tight"><a href="#linux">Installing rEFInd Manually Using Linux</a></li>
126
127 <li class="tight"><a href="#osx">Installing rEFInd Manually Using Mac OS X</a></li>
128
129 <li class="tight"><a href="#windows">Installing rEFInd Manually Using Windows</a></li>
130
131 <li class="tight"><a href="#efishell">Installing rEFInd Manually Using an EFI Shell</a></ul></li>
132
133 <li class="tight"><a href="#naming">Alternative Naming Options</a></li>
134
135 <li class="tight"><a href="#upgrading">Upgrading rEFInd</a></li>
136
137 <li class="tight"><a href="#addons">Installing Additional Components</a></li>
138
139 <li class="tight"><a href="#sluggish">Fixing a Sluggish Macintosh Boot</a></li>
140
141 <li class="tight"><a href="#uninstalling">Uninstalling rEFInd</a></li>
142
143 </ul>
144
145 </div>
146
147 <a name="packagefile">
148 <h2>Installing rEFInd Using an RPM or Debian Package File</h2>
149 </a>
150
151 <p>Beginning with version 0.6.2, I've included an RPM package file for rEFInd, and I quickly updated this (in 0.6.2-2) to be more sophisticated and to include a Debian package file, as well. If you have a working RPM-based or Debian-based Linux installation that boots in EFI mode, using one of these files is likely to be the easiest way to install rEFInd: You need only download the file and issue an appropriate installation command. In some cases, double-clicking the package in your file manager will install it. If that doesn't work, a command like the following will install the RPM on an RPM-based system:</p>
152
153 <pre class="listing"># <tt class="userinput">rpm -Uvh refind-0.6.2-2.x86_64.rpm</tt></pre>
154
155 <p>On a Debian-based system, the equivalent command is:</p>
156
157 <pre class="listing"># <tt class="userinput">dpkg -i refind_0.6.2-2_amd64.deb</tt></pre>
158
159 <p>Either command produces output similar to that described for <a href="#installsh">using the <tt>install.sh</tt> script,</a> so you can check it for error messages and other signs of trouble. The package file installs rEFInd and registers it with the EFI to be the default boot loader. The script that runs as part of the installation process tries to determine if you're using Secure Boot, and if so it will try to configure rEFInd to launch using shim; however, this won't work correctly on all systems. Ubuntu 12.10 users who are booting with Secure Boot active should be wary, since the resulting installation will probably try to use Ubuntu's version of shim, which won't work correctly with rEFInd.</p>
160
161 <p>Since version 0.6.3, the installation script makes an attempt to install rEFInd in a bootable way even if you run the script from a BIOS-mode boot, and therefore the RPM and Debian packages do the same. I cannot guarantee that this will work, though, and even if it does, some of the tricks that <tt>install.sh</tt> uses might not last for long. You might therefore want to run the <tt><a href="#unhijack">refind-unhijack.sh</a></tt> script after you boot Linux in EFI mode for the first time.</p>
162
163 <p>Since version 0.6.2-2, my package files have installed the rEFInd binaries to <tt>/usr/share/refind-<tt class="variable">version</tt></tt>, the documentation to <tt>/usr/share/doc/refind-<tt class="variable">version</tt></tt>, and a few miscellaneous files elsewhere. Upon installation, the package runs the <tt>install.sh</tt> script to copy the files to the ESP. This enables you to re-install rEFInd after the fact by running <tt>install.sh</tt>, should some other tool or OS wipe the ESP or should the installation go awry. In such cases you can <a href="#installsh">use <tt>install.sh</tt></a> or <a href="#manual">install manually.</a></p>
164
165 <a name="installsh">
166 <h2>Installing rEFInd Using <tt>install.sh</tt> under Linux or Mac OS X</h2>
167
168 <p class="sidebar"><b>Warning:</b> If you're using a Macintosh, you should run <tt>install.sh</tt> from Mac OS X rather than from Linux. If run from Linux, rEFInd is unlikely to be fully installed. Worse, it's conceivable that running <tt>install.sh</tt> from Linux will damage your firmware, requiring that it be re-flashed. The reason is that Apple uses non-standard methods to enable a boot loader, and the Linux functions in <tt>install.sh</tt> assume standard EFI installation methods.</p>
169
170 <p>If you're using Linux or Mac OS X, the easiest way to install rEFInd is to use the <tt>install.sh</tt> script. This script automatically copies rEFInd's files to your ESP or other target location and makes changes to your firmware's NVRAM settings so that rEFInd will start the next time you boot. If you've booted to OS X or in non-Secure-Boot EFI mode to Linux on a UEFI-based PC, <tt>install.sh</tt> will probably do the right thing, so you can get by with the quick instructions. If your setup is unusual, if your computer uses Secure Boot, or if you want to create a USB flash drive with rEFInd on it, you should read the <a href="#extra_installsh">extra instructions</a> for this utility.</p>
171
172 <a name="quickstart">
173 <h3>Quick <tt>install.sh</tt> Instructions</h3>
174 </quickstart>
175
176 <p>Under Linux, the <tt>install.sh</tt> script installs rEFInd to your disk's ESP. Under Mac OS X, the script installs rEFInd to your current OS X boot partition by default; but you can install to your ESP instead by passing the script the <tt>--esp</tt> option. Under either OS, you can install to something other than the currently-running OS by using the <tt>--root <tt class="variable">/mountpoint</tt></tt> option. (See <a href="#table1">Table 1</a> for details.)</p>
177
178 <p>Before running this script under Linux, you should ensure that your ESP is mounted at <tt>/boot</tt> or <tt>/boot/efi</tt>, as described in more detail in the <a href="#linux">Installing rEFInd Manually Using Linux</a> section. (If you installed Linux in EFI mode, chances are your ESP is properly mounted.) This precaution isn't necessary under OS X. If you run <tt>install.sh</tt> from a BIOS/legacy-mode boot, particularly on a computer that also runs Windows, you should be aware that the tricks the script uses to install itself from BIOS mode are rather delicate. You can convert to a more conventional configuration using the <a href="#unhijack"><tt>refind-unhijack.sh</tt> script.</a></p>
179
180 <p>A sample run under Linux looks something like this:</p>
181
182 <pre class="listing">
183 # <tt class="userinput">./install.sh</tt>
184 Installing rEFInd on Linux....
185 ESP was found at /boot/efi using vfat
186 Installing driver for ext4 (ext4_x64.efi)
187 Copied rEFInd binary files
188
189 Copying sample configuration file as refind.conf; edit this file to configure
190 rEFInd.
191
192
193 Installation has completed successfully.</pre>
194
195 <p>The output under OS X is a bit different:</p>
196
197 <pre class="listing">
198 $ <tt class="userinput">./install.sh</tt>
199 Not running as root; attempting to elevate privileges via sudo....
200 Password:
201 Installing rEFInd on OS X....
202 Installing rEFInd to the partition mounted at '/'
203 Copied rEFInd binary files
204
205 Copying sample configuration file as refind.conf; edit this file to configure
206 rEFInd.
207
208
209 WARNING: If you have an Advanced Format disk, *DO NOT* attempt to check the
210 bless status with 'bless --info', since this is known to cause disk corruption
211 on some systems!!
212
213
214 Installation has completed successfully.</pre>
215
216 <p>In either case, the details of the output differ depending on your existing configuration and how you ran the program. Unless you see an obvious warning or error, you shouldn't be concerned about minor deviations from these examples. If you run into such a situation, or if you want to install in an unusual way, read on....</p>
217
218 <a name="extra_installsh">
219 <h3>Extra <tt>install.sh</tt> Instructions</h3>
220 </a>
221
222 <p>Some details that can affect how the script runs include the following:</p>
223
224 <ul>
225
226 <li>If you run the script as an ordinary user, it attempts to acquire
227 <tt>root</tt> privileges by using the <tt>sudo</tt> command. This works
228 on Mac OS X and some Linux installations (such as under Ubuntu or if
229 you've added yourself to the <tt>sudo</tt> users list), but on some
230 Linux installations this will fail. On such systems, you should run
231 <tt>install.sh</tt> as <tt>root</tt>.</li>
232
233 <li>Under OS X, you can run the script with a mouse by opening a Terminal
234 session and then dragging-and-dropping the <tt>install.sh</tt> file to
235 the Terminal window. You'll need to press the Return or Enter key to
236 run the script.</li>
237
238 <li>If you're using OS X 10.7's Whole Disk Encryption (WDE) feature, you
239 <i>must</i> install rEFInd to the ESP, so the <tt>--esp</tt> option to
240 <tt>install.sh</tt> is required. I'm still a little bit foggy about
241 what's required to boot the system once this is done; see <a
242 href="https://sourceforge.net/p/refind/discussion/general/thread/5c7d0195/">this
243 forum thread</a> for a discussion of the topic.</li>
244
245 <li>If you're replacing rEFIt with rEFInd on a Mac, there's a chance that
246 <tt>install.sh</tt> will warn you about the presence of a program
247 called <tt>/Library/StartupItems/rEFItBlesser</tt> and ask if you want
248 to delete it. This program is designed to keep rEFIt set as the boot
249 manager by automatically re-blessing it if the default boot manager
250 changes. This is obviously undesirable if you install rEFInd as your
251 primary boot manager, so it's generally best to remove this program. If
252 you prefer to keep your options open, you can answer <tt
253 class="userinput">N</tt> when <tt>install.sh</tt> asks if you want to
254 delete rEFItBlesser, and instead manually copy it elsewhere. If you
255 subsequently decide to go back to using rEFIt as your primary boot
256 manager, you can restore rEFItBlesser to its place.</li>
257
258 <li>If you're using OS X and an Advanced Format disk, heed the warning that
259 <tt>install.sh</tt> displays and <i><b>do not</b></i> use <tt>bless
260 --info</tt> to check your installation status; this combination has
261 been reported to cause disk corruption on some Macs!</li>
262
263 <li>If you intend to boot BIOS-based OSes on a UEFI-based PC, you
264 <i>must</i> edit the <tt>refind.conf</tt> file's <tt>scanfor</tt> line
265 to enable the relevant searches. This is <i>not</i> necessary on Macs,
266 though; because of the popularity of dual boots with Windows on Macs,
267 the BIOS/legacy scans are enabled by default on Macs.</li>
268
269 <li>On Linux, <tt>install.sh</tt> checks the filesystem type of the
270 <tt>/boot</tt> directory and, if a matching filesystem driver is
271 available, installs it. Note that the "<tt>/boot</tt> directory" may be
272 on a separate partition or it may be part of your root (<tt>/</tt>)
273 filesystem, in which case the driver for your root filesystem is
274 installed. If <tt>install.sh</tt> detects that the filesystem in
275 question is ext2fs or ext3fs, it installs the ext4fs driver, which can
276 handle all three of these filesystem types. This feature is unlikely to
277 work properly from an emergency system, although it might if you have a
278 separate <tt>/boot</tt> partition and if you mount that partition at
279 <tt>/boot</tt> in your emergency system, and the ESP at
280 <tt>/boot/efi</tt>.</li>
281
282 <li>If you run <tt>install.sh</tt> on Linux and if
283 <tt>/boot/refind_linux.conf</tt> doesn't already exist,
284 <tt>install.sh</tt> creates this file and populates it with a few
285 sample entries. If <tt>/boot</tt> is on a FAT partition (or HFS+ on a
286 Mac), or if it's on an ext2fs, ext3fs, ext4fs, ReiserFS, or HFS+
287 partition and you install an appropriate driver, the
288 result is that rEFInd will detect your kernel and will probably boot it
289 correctly. Some systems will require manual tweaking to
290 <tt>refind_linux.conf</tt>, though&mdash;for instance, to add
291 <tt>dolvm</tt> to the boot options on Gentoo systems that use LVM.</li>
292
293 </ul>
294
295 <p>In addition to these quirks, you should be aware of some options that <tt>install.sh</tt> supports to enable you to customize your installation in various ways. The syntax for <tt>install.sh</tt> is as follows:</p>
296
297 <pre class="listing">
298 install.sh [--esp | --usedefault <tt class="variable">device-file</tt> | --root <tt class="variable">mount-point</tt> ] \
299 [--nodrivers | --alldrivers] [--shim <tt class="variable">shim-filename</tt>] [--localkeys] [--yes]
300 </pre>
301
302 <p>The details of the options are summarized in <a href="#table1">Table 1.</a> Broadly speaking, they come in four classes: installation location options (<tt>--esp</tt>, <tt>--usedefault</tt>, and <tt>--root</tt>), driver options (<tt>--nodrivers</tt> and <tt>--alldrivers</tt>), Secure Boot options (<tt>--shim</tt> and <tt>--localkeys</tt>), and a user input option (<tt>--yes</tt>). Using some of these options in unusual conditions can generate warnings and prompts to confirm your actions. In particular, using <tt>--shim</tt> or <tt>--localkeys</tt> when you're <i>not</i> booted in Secure Boot mode, or failing to use <tt>--shim</tt> when you <i>are</i> booted in Secure Boot mode, will generate a query and a request to confirm your installation. Consult the <a href="secureboot.html">Managing Secure Boot</a> page for more on this topic.</p>
303
304 <table border="1" cellpadding="1" cellspacing="2" summary="Table 1: Options to <tt>install.sh</tt>"><a name="table1"><caption><b>Table 1: Options to <tt>install.sh</tt></b></caption></a>
305 <tr>
306 <th>Option</th>
307 <th>Explanation</th>
308 </tr>
309 <tr>
310 <td><tt>--esp</tt></td>
311 <td>This option tells <tt>install.sh</tt> to install rEFInd to the ESP of your computer. This option is only useful on OS X; on Linux, installing to the ESP is a practical necessity, so <tt>--esp</tt> is implicit on Linux. Be aware that some users have reported sluggish boots when installing rEFInd to the ESP on Macs. Installing rEFInd anywhere but the ESP makes little sense on UEFI-based PCs, except for the partial exception of removable boot media, which you can prepare with <tt>--usedefault</tt>.</td>
312 </tr>
313 <tr>
314 <td><tt>--usedefault <tt class="variable">device-file</tt></tt></td>
315 <td>You can install rEFInd to a disk using the default/fallback filename of <tt>EFI/BOOT/bootx64.efi</tt> (and <tt>EFI/BOOT/bootia32.efi</tt>, if the 32-bit build is available) using this option. The <tt class="variable">device-file</tt> should be an <i>unmounted</i> ESP, or at least a FAT partition, as in <tt>--usedefault /dev/sdc1</tt>. Your computer's NVRAM entries will <i>not</i> be modified when installing in this way. The intent is that you can create a bootable USB flash drive or install rEFInd on a computer that tends to "forget" its NVRAM settings with this option. This option is mutually exclusive with <tt>--esp</tt> and <tt>--root</tt> (except for implicit use of <tt>--esp</tt> on Linux).</td>
316 </tr>
317 <tr>
318 <td><tt>--root <tt class="variable">/mount-point</tt></tt></td>
319 <td>This option is intended to help install rEFInd from a "live CD" or other emergency system. To use it, you should mount your regular installation at <tt class="variable">/mount-point</tt>, including your <tt>/boot</tt> directory (if it's separate) at <tt class="variable">/mount-point</tt><tt>/boot</tt> and (on Linux) your ESP at that location or at <tt class="variable">/mount-point</tt><tt>/boot/efi</tt>. The <tt>install.sh</tt> script then installs rEFInd to the appropriate location&mdash;on Linux, <tt class="variable">/mount-point</tt><tt>/boot/EFI/refind</tt> or <tt class="variable">/mount-point</tt><tt>/boot/efi/EFI/refind</tt>, depending on where you've mounted your ESP; or on OS X, to <tt class="variable">/mount-point</tt><tt>/EFI/refind</tt>. The script also adds an entry to your NVRAM for rEFInd at this location. You cannot use this option with either <tt>--esp</tt> or <tt>--usedefault</tt>, except for implicit use of <tt>--esp</tt> on Linux. Note that this option is <i>not</i> needed when doing a dual-boot Linux/OS X installation; just install normally in OS X.</td>
320 </tr>
321 <tr>
322 <td><tt>--nodrivers</tt></td>
323 <td>Ordinarily <tt>install.sh</tt> attempts to install the driver required to read <tt>/boot</tt> on Linux. This attempt works only if you're using ext2fs, ext3fs, ext4fs, or ReiserFS on the relevant partition. If you want to forego this driver installation, pass the <tt>--nodrivers</tt> option. This option is the default on OS X or when you use <tt>--usedefault</tt>.</td>
324 </tr>
325 <tr>
326 <td><tt>--alldrivers</tt></td>
327 <td>When you specify this option, <tt>install.sh</tt> copies <i>all</i> the driver files for your architecture. You may want to remove unused driver files after you use this option, especially if your computer uses Secure Boot.</td>
328 </tr>
329 <tr>
330 <td><tt>--shim <tt class="variable">shim-filename</tt></tt></td>
331 <td>If you pass this option to <tt>install.sh</tt>, the script will copy the specified shim program file to the target directory, copy the <tt>MokManager.efi</tt> file from the shim program file's directory to the target directory, copy the 64-bit version of rEFInd as <tt>grubx64.efi</tt>, and register shim with the firmware. (If you also specify <tt>--usedefault</tt>, the NVRAM registration is skipped.) The intent is to simplify rEFInd installation on a computer that uses Secure Boot; when so set up, rEFInd will boot in Secure Boot mode, with one caveat: The first time you boot, MokManager will launch, and you must use it to locate and install a public key. This key file will be located in the rEFInd directory's <tt>keys</tt> subdirectory under the name <tt>refind.cer</tt>. Note that I'm not providing a shim binary myself, but you can download one from <a href="http://www.codon.org.uk/~mjg59/shim-signed/">here.</a> In the not-too-distant future, most distributions will provide their own shim programs, so you'll be able to point to them&mdash;for instance, in <tt>/boot/efi/EFI/fedora/shim.efi</tt>.</td>
332 </tr>
333 <tr>
334 <td><tt>--localkeys</tt></td>
335 <td>This option tells <tt>install.sh</tt> to generate a new Machine Owner Key (MOK), store it in <tt>/etc/refind.d/keys</tt> as <tt>refind_local.*</tt>, and re-sign all the 64-bit rEFInd binaries with this key before installing them. This is the preferable way to install rEFInd in Secure Boot mode, since it means your binaries will be signed locally rather than with my own key, which is used to sign many other users' binaries; however, this method requires that both the <tt>openssl</tt> and <tt>sbsign</tt> binaries be installed. The former is readily available in most distributions' repositories, but the latter is not, so this option is not the default.</td>
336 </tr>
337 <tr>
338 <td><tt>--yes</tt></td>
339 <td>This option causes the script to assume a <tt>Y</tt> input to every yes/no prompt that can be generated under certain conditions, such as if you specify <tt>--shim</tt> but <tt>install.sh</tt> detects no evidence of a Secure Boot installation. This option is intended mainly for use by scripts such as those that might be used as part of an installation via an RPM or Debian package. <b>Note:</b> I introduced this option with the 0.6.2-2 incremental release, which was primarily an update of the 0.6.2 RPM package; it's not yet available in the mainline 0.6.2 version.</td>
340 </tr>
341 </table>
342
343 <p>In any event, you should peruse the script's output to ensure that everything looks OK. <tt>install.sh</tt> displays error messages when it encounters errors, such as if the ESP is mounted read-only or if you run out of disk space. You may need to correct such problems manually and re-run the script. In some cases you may need to fall back on manual installation, which gives you better control over details such as which partition to use for installation.</p>
344
345 <a name="unhijack">
346 <h3>Using <tt>refind-unhijack.sh</tt></h3>
347 </a>
348
349 <p>Sometimes it's necessary to install rEFInd from a BIOS/legacy-mode boot. This can happen because you've accidentally installed Linux in this mode or because you're using a BIOS-mode emergency disc to do the installation, for instance. Ordinarily, such installations are unlikely to work, particularly if the computer already has an EFI-mode OS installed. Since version 0.6.3, though, rEFInd's <tt>install.sh</tt> script has attempted to install in one of three ways when run from BIOS mode:</p>
350
351 <ul>
352
353 <li>It attempts to locate existing rEFInd installations and upgrades
354 them.</li>
355
356 <li>It installs rEFInd as <tt>EFI/BOOT/bootx64.efi</tt> (and
357 <tt>EFI/BOOT/bootia32.efi</tt>), the default filenames for EFI-mode
358 booting if no entries exist in the computer's NVRAM.</li>
359
360 <li>It copies the Windows boot loader
361 (<tt>EFI/Microsoft/Boot/bootmgfw.efi</tt>), if present, down one level,
362 to <tt>EFI/Microsoft/bootmgfw.efi</tt>, and installs rEFInd as
363 <tt>EFI/Microsoft/Boot/bootmgfw.efi</tt>.</li>
364
365 </ul>
366
367 <p>The first two approaches are perfectly legitimate and are unlikely to cause problems, although they also might not work in all circumstances. The third approach is essentially an act of desperation, and it violates the usual rule that each OS should manage its own boot loader directory. It has the benefit of working, though; and in fact on some computers with buggy firmware, this approach may be the only way to get rEFInd (or any other non-Microsoft boot loader) to work. When <tt>install.sh</tt> uses this method, it notifies you of the fact:</p>
368
369 <pre class="listing">Running in BIOS mode with a suspected Windows installation; moving boot loader
370 files so as to install to /boot/efi/EFI/Microsoft/Boot.</pre>
371
372 <p>The <tt>install.sh</tt> script preserves the Windows boot loader, and rEFInd should continue to be able to boot Windows when installed in this way. It's possible, though, that Windows will notice the change and will attempt to "fix" the "damage," which will remove rEFInd from the boot process. To avoid this problem, you can run the <tt>refind-unhijack.sh</tt> script. This script moves the rEFInd installation files to a more appropriate location on the ESP (<tt>EFI/refind</tt>) and registers rEFInd with the EFI in the officially-sanctioned manner.</p>
373
374 <p>Unfortunately, on some systems you really should leave rEFInd installed as <tt>EFI/Microsoft/Boot/bootmgfw.efi</tt>; some EFIs have bugs that prevent them from launching any boot loader but that one. Thus, there are no hard-and-fast rules; you'll have to determine what works on your system and run <tt>refind-unhijack.sh</tt> or not as you deem best.</p>
375
376 <p>To run the script, type its name (and perhaps its path) as <tt>root</tt>. It will report on what it does:</p>
377
378 <pre class="listing"># <tt class="userinput">./refind-unhijack.sh</tt>
379 I'm not yet written!</pre>
380
381 <p>If you run this script on a system whose Windows boot loader has <i>not</i> been "hijacked" by rEFInd, no harm will come of it; the script only does its thing when it detects that rEFInd is installed where the Windows boot loader should be.</p>
382
383 <a name="manual">
384 <h2>Installing rEFInd Manually</h2>
385 </a>
386
387 <p>Sometimes the <tt>install.sh</tt> script just won't do the job, or you may need to install using an OS that it doesn't support, such as Windows. In these cases, you'll have to install rEFInd the old-fashioned way, using file-copying commands and utilities to add the program to your EFI's boot loader list. I describe how to do this with <a href="#linux">Linux</a>, <a href="#osx">OS X</a>, <a href="#windows">Windows</a>, and <a href="#efishell">the EFI shell.</a></p>
388
389 <a name="linux">
390 <h3>Installing rEFInd Manually Using Linux</h3>
391 </a>
392
393 <p>On a UEFI-based PC, you'll normally install rEFInd to the ESP, which is usually mounted at <tt>/boot/efi</tt>. You can verify that this is the case by using the <tt>df</tt> command:</p>
394
395 <pre class="listing">
396 $ <b>df /boot/efi</b>
397 Filesystem 1K-blocks Used Available Use% Mounted on
398 /dev/sda1 191284 16604 174681 9% /boot/efi
399 </pre>
400
401 <p class="sidebar"><b>Warning:</b> If you're running Linux on a Mac, I recommend you install rEFInd under OS X. The Mac's boot process deviates a bit from EFI standards, so you'll probably have to use a tool called <tt>bless</tt> under Mac OS to do the job. Alternatively, there's a new Linux program, <tt>hfs-bless</tt>, part of the <a href="http://www.codon.org.uk/~mjg59/mactel-boot/"><tt>mactel-boot</tt></a> package, that's supposed to work with <tt>efibootmgr</tt> to make a Mac HFS partition bootable. I've not yet tried it, though. There are also reports that the <tt>efibootmgr</tt> tool used under Linux can corrupt some Macs' firmware. Although I've seen some vague suggestions that this problem has been fixed under 3.<i>x</i> kernels, I haven't tested this claim.</p>
402
403 <p>This example shows that <tt>/dev/sda1</tt> is mounted at <tt>/boot/efi</tt>, which is a typical configuration. (The ESP can be on another disk or partition, but <tt>/dev/sda1</tt> is the most common place for an ESP.) If your output shows <tt>/boot</tt> or <tt>/</tt> under the <tt>Mounted on</tt> column, then your ESP isn't mounted. (An exception is if you're mounting the ESP at <tt>/boot</tt>. This is an unusual configuration. If you're using it, you can proceed, making suitable adjustments to subsequent commands.) If you get a <tt>df: `/boot/efi': No such file or directory</tt> error message, then the <tt>/boot/efi</tt> directory doesn't even exist. In such cases, you may need to jump through some extra hoops, as described on my <a href="http://www.rodsbooks.com/efi-bootloaders/installation.html">EFI Boot Loader Installation</a> page.</p>
404
405 <p>Assuming the ESP is mounted at <tt>/boot/efi</tt>, you can install the rEFInd files as follows (you must be <tt>root</tt> to issue these commands, or precede each of them with <tt><b>sudo</b></tt>):</p>
406
407 <ol>
408
409 <li>Type <tt><b>cp -r refind /boot/efi/EFI/</b></tt> from the <tt>refind-<i>version</i></tt> directory in which the <tt>refind</tt> directory exists. This copies all the files that rEFInd needs to work. Note that this includes <i>all</i> of rEFInd's drivers. This command also copies the rEFInd binaries as signed by me; if you prefer to re-sign the binaries yourself, you'll have to do so before or during the copy operation, as described on the <a href="secureboot.html">Managing Secure Boot</a> page.</li>
410
411 <li>Type <tt><b>cd /boot/efi/EFI/refind</b></tt> to change into rEFInd's new directory on the ESP.</li>
412
413 <li>Type <tt><b>rm refind_ia32.efi</b></tt> to remove the IA32 binary if you're using an <i>x</i>86-64 (64-bit) system; or type <tt><b>rm refind_x64.efi</b></tt> to remove the <i>x</i>86-64 binary if you're using an <i>x</i>86 (32-bit) system. You can optionally rename the binary you keep as <tt>refind.efi</tt>, but this isn't required. (Note that you must keep the version that's the correct bit width for your EFI; if you've installed a 32-bit Linux on a 64-bit PC with a 64-bit EFI, you'd keep <tt>refind_x64.efi</tt>.</li>
414
415 <li>Optionally, type <tt class="userinput">rm -r drivers_ia32</tt> to remove the <i>x</i>86 drivers from an <i>x</i>86-64 system, or <tt class="userinput">rm -r drivers_x64</tt> to remove the <i>x</i>86-64 drivers from a 32-bit <i>x</i>86 system. You may also want to remove some or all of the drivers for the architecture you are using. If you don't need them, they'll slow down the start process, and worse, if you're using Secure Boot, rEFInd can load just one shim/MOK-signed driver. See the <a href="drivers.html">page on drivers</a> for more on this topic.</li>
416
417 <li>Rename the configuration file by typing <tt><b>mv refind.conf-sample refind.conf</b></tt>. Consult the <a href="configfile.html">Editing the rEFInd Configuration File</a> page for information on how to adjust your options.</li>
418
419 <p class="sidebar"><b>Weird:</b> A <a href="http://mjg59.dreamwidth.org/20187.html">bug exists</a> in some Lenovo computers (and perhaps in some others, too) that causes the firmware's boot manager to refuse to boot any boot loader that doesn't have the name <tt>Windows Boot Manager</tt> or <tt>Red Hat Enterprise Linux</tt>. If you have such a system, you must pass one of those names (in quotes) rather than <tt>rEFInd</tt> to <tt>efibootmgr</tt> via its <tt>-L</tt> option. This bug was reported to Lenovo in mid-November 2012, so with any luck updated firmware without this bug will be available later this year or early in 2013. I can make no promises about this, though.</p>
420
421 <a name="efibootmgr">
422 <li>On a UEFI-based system, type <tt><b>efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFInd</b></tt> to add rEFInd to your EFI's list of available boot loaders, which it stores in NVRAM. Adjust the path to the binary as required if you install somewhere else. You may also need to include additional options if your ESP isn't on <tt>/dev/sda1</tt> or if your configuration is otherwise unusual; consult the <tt>efibootmgr</tt> man page for details. You may need to install this program on some systems; it's a standard part of most distributions' repositories. Also, if you're installing in Secure Boot mode, you must normally register <tt>shim.efi</tt> rather than the rEFInd binary, and rename <tt>refind_x64.efi</tt> to <tt>grubx64.efi</tt>.</li>
423 </a>
424
425 <li>If other boot loaders are already installed, you can use <tt>efibootmgr</tt> to adjust their boot order. For instance, <b><tt>efibootmgr -o 3,7,2</tt></b> sets the firmware to try boot loader #3 first, followed by #7, followed by #2. (The program should have displayed a list of boot loaders when you added yours in the preceding step.) Place rEFInd's number first to set it as the default boot program.</li>
426
427 </ol>
428
429 <p>Note the use of doubled-up backslashes (<tt>\\</tt>) rather than forward slashes (<tt>/</tt>) in the directory separators when using <tt>efibootmgr</tt>. This command will work on most systems that are already booted into EFI mode; however, it won't work if you're booted in BIOS mode. You may also need to add options if your ESP is in some unusual location or if your system is unusual in some way. Consult the <tt>efibootmgr</tt> man page if you need help.</p>
430
431 <p>On some systems, <tt>efibootmgr</tt> won't do what you expect. On such systems, you may have better luck renaming the rEFInd files, as described in the <a href="#naming">Alternative Naming Options</a> section.</p>
432
433 <a name="osx">
434 <h3>Installing rEFInd Manually Using Mac OS X</h3>
435 </a>
436
437 <p>Before installing rEFInd on a Mac, you must determine whether it uses a 32-bit or 64-bit EFI implementation. Most Intel-based Macs have 64-bit EFIs, so you should use the <tt>refind_x64.efi</tt> file with them; but very early Intel-based Macs have 32-bit EFIs (and sometimes 32-bit CPUs), which require the <tt>refind_ia32.efi</tt> file. You can determine whether your Mac needs the <i>x</i>86-64 or IA32 build by typing the following command in a Mac Terminal window:</p>
438
439 <pre class="listing">
440 $ <b>ioreg -l -p IODeviceTree | grep firmware-abi</b>
441 </pre>
442
443 <p>The result should include either <tt>EFI32</tt> or <tt>EFI64</tt>, indicating that you should use the <tt>refind_ia32.efi</tt> or <tt>refind_x64.efi</tt> binary, respectively.</p>
444
445 <p class="sidebar"><b>Warning:</b> Numerous rEFIt bug reports indicate disk corruption problems on disks over about 500 GiB. <a href="https://sourceforge.net/tracker/?func=detail&aid=3218104&group_id=161917&atid=821764">This</a> report on the problem, and particularly the post by mic-marchen, suggests that the problem is related to a bug in OS X's <tt>bless</tt> utility, and particularly its <tt>--info</tt> option, that causes it to corrupt data on disks with 4 KiB sectors. These <i>Advanced Format</i> disks are becoming increasingly common, particularly at larger disk sizes. Therefore, I <i>strongly</i> recommend that you <i>not</i> type <tt class="userinput">sudo bless --info</tt> to check the status of your installation if you have such a disk, or even if you suspect you might have such a disk. (I've seen Advanced Format disks as small as 320 GB.)</p>
446
447 <p>The procedure for installing rEFInd on a Mac is similar to that for installing it under Linux, except that you can (and probably should) install it to OS X's system partition or some other HFS+ partition rather than to the ESP, and you must use the <tt>bless</tt> utility rather than <tt>efibootmgr</tt>. To be precise, you should follow these steps:</p>
448
449 <ol>
450
451 <li>Open a Terminal window in which you'll type the following
452 commands.</li>
453
454 <li>If you want to install rEFInd on your ESP, you must first mount it. You
455 can do this by typing <b><tt>mkdir /Volumes/esp</tt></b> followed by
456 <b><tt>sudo mount -t msdos /dev/disk0s1 /Volumes/esp</tt></b>. Note
457 that this step is usually optional, and it makes the procedure a bit
458 more complex, so you might want to forego it. On the other hand,
459 installing to the ESP is required if you're using the whole-disk
460 encryption feature of OS X 10.7. Note that you may need to change
461 <tt>/dev/disk0s1</tt> to something else if your ESP is at an unusual
462 location. Use a tool such as my <a
463 href="http://www.rodsbooks.com/gdisk/">GPT fdisk (<tt>gdisk</tt>)</a>
464 to examine your partition table to find your ESP if necessary.</li>
465
466 <li>Type <b><tt>sudo mkdir -p /efi/refind</tt></b> to create a suitable
467 directory for rEFInd. If you want to place rEFInd on the ESP or some
468 other partition, you should adjust the pathname appropriately, as in
469 <tt>/Volumes/esp/efi/refind</tt>. Alternatively, you can use the Finder
470 to create the directory.</li>
471
472 <li>Copy the files in the <tt>refind</tt> subdirectory of the rEFInd binary
473 package to the like-named directory you've just created. You can do
474 this in the Finder or by typing <b><tt>sudo cp -r refind/*
475 /efi/refind/</tt></b> in your Terminal window after changing into the
476 rEFInd package's main directory.</li>
477
478 <li>Remove the file for the version of rEFInd you're not using, as in
479 <b><tt>sudo rm /efi/refind/refind_ia32.efi</tt></b> on a Mac with a
480 64-bit EFI or <b><tt>sudo rm /efi/refind/refind_x64.efi</tt></b> on a
481 Mac with a 32-bit EFI.</li>
482
483 <li>Optionally, remove the drivers directory for the architecture you're
484 not using&mdash;<tt>/efi/refind/drivers_ia32</tt> or
485 <tt>/efi/refind/drivers_x64</tt>, as appropriate. You may also want to
486 remove some or all of the drivers for the architecture you are using;
487 if you don't need them, they'll slow down the start process. See the <a
488 href="drivers.html">page on drivers</a> for more on this topic. Note
489 that Apple's firmware includes its own HFS+ driver, so the HFS+ driver
490 provided with rEFInd is useless on Macs.</li>
491
492 <li>If this is your first installation, type <b><tt>sudo mv
493 /efi/refind/refind.conf-sample /efi/refind/refind.conf</tt></b>
494 (adjusting the path as necessary) to rename the sample configuration
495 file so that it will serve as a real configuration file. (Again, you
496 can do this with the Finder, if you prefer.)</li>
497
498 <li>"Bless" rEFInd by typing one of the following two commands:
499 <ul>
500 <li>If you're installing rEFInd to an ordinary HFS+ volume, type <tt
501 class="userinput">sudo bless --setBoot --folder /efi/refind --file
502 /efi/refind/refind_x64.efi</tt>. (Adjust the path and filename as
503 necessary if you're placing rEFInd somewhere else or using the
504 32-bit version.)</li>
505 <li>If you're installing rEFInd on the ESP, type <tt
506 class="userinput">sudo bless --mount /Volumes/esp --setBoot --file
507 /Volumes/esp/efi/refind/refind_x64.efi</tt>, adjusting the mount
508 point and exact path to the file as appropriate for your
509 installation.</li>
510 </ul>
511 As per the Warning earlier, <i>do not</i> use <tt>bless</tt>'s
512 <tt>--info</tt> option to try to confirm the change to the boot status
513 unless you're certain you do <i>not</i> have an Advanced Format hard
514 disk.</li>
515
516 <li>If you don't want to reboot immediately after installing rEFInd, you
517 may optionally unmount the ESP by typing <tt class="userinput">sudo
518 umount /dev/disk0s1</tt> or <tt class="userinput">sudo umount
519 /Volumes/esp</tt>. This step isn't strictly required, but if you want
520 to keep the ESP out of your directory tree, it can be useful.</li>
521
522 </ol>
523
524 <p>When you reboot, your Mac should bring up the rEFInd menu, and should continue to do so thereafter. If you make changes that break this association, you can re-run the <tt>bless</tt> command (if necessary, restoring the rEFInd files first). This might be necessary after installing system updates from Apple or if you upgrade rEFInd to a newer version.</p>
525
526 <p>If you're replacing rEFIt, you may discover that rEFInd works on the first boot, but the system reverts back to rEFIt or a direct boot to OS X on the second boot. To fix this problem, you can remove the rEFItBlesser program, which is located at <tt>/Library/StartupItems/rEFItBlesser</tt>. This program attempts to keep rEFIt set as the default boot loader, but it also has the purpose of protecting the computer from launching the wrong OS after waking from sleep. If you want that protection, my suggestion is to install rEFIt and rEFItBlesser and then replace the <tt>refit.efi</tt> file with <tt>refind_x64.efi</tt> or <tt>refind_ia32.efi</tt> (renaming it to <tt>refit.efi</tt>. Used in this way, rEFInd will still look for its own configuration file, <tt>refind.conf</tt>, so you'll need to move it but <i>not</i> rename it. If you don't move the icons from the rEFInd package, your icons will continue to look like rEFIt icons, and you'll be missing the new icons for specific Linux distributions that rEFInd provides. One final caveat: It's conceivable that rEFItBlesser is what's causing filesystem corruption for some users, so if you've been having this problem with rEFIt, it might be worth disabling this program and not using it with rEFInd.</p>
527
528 <p>If you want to remove rEFInd from your system, you can delete its files. The Mac will revert to booting using whatever standard boot loader it can find. Alternatively, you can use <tt>bless</tt> to bless another EFI boot loader. The GUI Startup Disk utility in System Preferences provides a simplified interface that enables you to select which OS X installation to boot, but it doesn't look for non-Apple boot loaders, so you can't use it to enable rEFInd.</p>
529
530 <a name="windows">
531 <h3>Installing rEFInd Manually Using Windows</h3>
532 </a>
533
534 <p class="sidebar"><b>Warning:</b> Windows 8 implements a fast shutdown feature that helps speed up shutdown and startup operations on a single-boot computer. Unfortunately, this feature can cause filesystem corruption if it's used on a multi-boot computer. You can disable the feature by launching an Administrator Command Prompt window and typing <tt class="userinput">powercfg /h off</tt> in it.</p>
535
536 <p>To install rEFInd under Windows, you must first find a way to access the ESP, which Windows normally hides from view. One way to accomplish this goal, and to proceed forward once the ESP is accessible, is as follows:</p>
537
538 <ol>
539
540 <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>
541
542 <li>Type <b><tt>mountvol S: /S</tt></b> in the Administrator Command Prompt window. This makes the ESP accessible as drive <tt>S:</tt> from that window. (You can use a drive identifier other than <tt>S:</tt> if you like.)</li>
543
544 <li>Change into the main rEFInd package directory, so that the <tt>refind</tt> subdirectory is visible when you type <b><tt>dir</tt></b>.</li>
545
546 <li>Type <b><tt>xcopy /E refind S:\EFI\refind\</tt></b> to copy the <tt>refind</tt> directory tree to the ESP's <tt>EFI</tt> directory. If you omit the trailing backslash from this command, <tt>xcopy</tt> will ask if you want to create the <tt>refind</tt> directory. Tell it to do so.</li>
547
548 <li>Type <b><tt>cd S:</tt></b> to change to the ESP.</li>
549
550 <li>Type <b><tt>cd EFI\refind</tt></b> to change into the <tt>refind</tt> subdirectory</li>
551
552 <li>Type <b><tt>del refind_ia32.efi</tt></b> to delete the unused 32-bit version of rEFInd. (Windows only supports EFI boots on 64-bit EFI implementations and in 64-bit versions of Windows.)</li>
553
554 <li>Optionally type <tt class="userinput">rd /s drivers_ia32</tt> to delete the <tt>drivers_ia32</tt> directory and its contents. You may also want to selectively delete some of the drivers in the <tt>drivers_x64</tt> directory, depending on your needs. Unnecessary drivers may slow the rEFInd start process. See the <a href="drivers.html">page on drivers</a> for more on this topic.</li>
555
556 <li>Type <b><tt>rename refind.conf-sample refind.conf</tt></b> to rename rEFInd's configuration file.</li>
557
558 <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.</li>
559
560 <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>
561
562 </ol>
563
564 <p>At this point, when you reboot, rEFInd should appear as your new default boot program. One caveat: My only EFI Windows installation uses UEFI DUET, which "forgets" its boot options upon reboot. Thus, I'm unable to test the last two steps (which were provided by a helpful user) myself. If it doesn't work for you, you have several other options, such as:</p>
565
566 <ul>
567
568 <li>You can rename files on the ESP. as described in the next section, <a href="#naming">Alternative Naming Options.</a></li>
569
570 <li>You can boot from an optical disc into an emergency OS to do the job. Ubuntu, for instance, provides an EFI-bootable installer with a "try before installation" mode. You'll need to type <b><tt>sudo apt-get install efibootmgr</tt></b> to install <tt>efibootmgr</tt>, but you can then use that program as described <a href="#efibootmgr">earlier</a>. (If you're using Ubuntu, you'll need to precede the command with <b><tt>sudo</tt></b>.</li>
571
572 <li>You may be able to use rEFInd's bootable CD image to use rEFInd to boot an OS that's been installed but rendered inoperable because of changes to your boot order. You can then use <tt>efibootmgr</tt>, <tt>bless</tt>, or some other tool to restore rEFInd as the default boot loader.</li>
573
574 </ul>
575
576 <a name="efishell">
577 <h3>Installing rEFInd Manually Using an EFI Shell</h3>
578 </a>
579
580 <p>If you can't currently boot any OS (say, because a firmware update has wiped your NVRAM entries), you may find it convenient to install rEFInd using an EFI version 2 shell. Unfortunately, the <tt>bcfg</tt> command described here is not available in the EFI version 1 shell, and the version 2 shell is unusable on many firmware implementations prior to 2.3.1. Thus, this procedure won't work for all systems.</p>
581
582 <p>In addition to emergency situations, using <tt>bcfg</tt> can be desirable if <tt>efibootmgr</tt> or other OS-hosted tools don't do the job. This happens under VirtualBox, for instance. An alternative in such cases can be to use <a href="#naming">alternative names for rEFInd.</a></p>
583
584 <p>To begin, you must have a way to launch your shell. Unfortunately, this can pose a dilemma, since without rEFInd or some other boot manager, many EFI implementations lack the means to launch a shell. Some will do so, though, if the shell is stored as <tt>shellx64.efi</tt> (for <i>x</i>86-64) or <tt>shellia32.efi</tt> (for <i>x</i>86) in the root directory of the ESP. Thus, you can try copying your shell file there. You can obtain EFI 2 shells here:</p>
585
586 <ul>
587
588 <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>
589
590 <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>
591
592 </ul>
593
594 <p>Note that the shell included in rEFInd's CD-R image version is a version 1 shell, so you can't use it for this purpose. You can, however, copy rEFInd's files from the CD-R. You can even launch the version 1 shell included with rEFInd and then use that to launch a version 2 shell. Once you've booted the shell, you can proceed as follows:</p>
595
596 <ol>
597
598 <li>If you haven't installed rEFInd previously, unpack its zip file to a
599 FAT partition. This can be the ESP itself or another partition, such as
600 a USB flash drive. If you're simply repairing a lost NVRAM entry, you
601 needn't move your existing rEFInd files.</li>
602
603 <li>Identify your filesystems, which are labelled with the form <tt>fs<tt
604 style="variable">n</tt>:</tt>, as in <tt>fs0:</tt> for the first
605 filesystem, <tt>fs1:</tt> for the second, and so on. Type the
606 filesystem number followed by the Enter key to begin using it. You can
607 then type <tt class="userinput">ls</tt> or <tt
608 class="userinput">dir</tt> to see the contents of the filesystem.
609 Chances are your ESP will be <tt>fs0:</tt>, but it could be something
610 else. (The following steps assume your ESP is <tt>fs0:</tt>; you'll
611 need to adjust them if it's not.) If rEFInd's source files are on
612 another device, you must identify it, too.</li>
613
614 <p class="sidebar"><b>Note:</b> Skip ahead to step #9 if you're merely re-activating an already-installed rEFInd binary. If an entry exists but it's no longer the primary one, you can skip ahead to step #14.</p>
615
616 <li>If necessary, create a directory for rEFInd by typing <tt
617 class="userinput">mkdir fs0:\EFI\refind</tt>. (If the <tt>fs0:\EFI</tt>
618 directory doesn't already exist, you must create it first,
619 though.)</li>
620
621 <li>Change to the directory in which rEFInd's files exist.</li>
622
623 <li>Type <tt class="userinput">cp refind_x64.efi fs0:\EFI\refind</tt> to
624 copy the rEFInd binary file. (Adjust the name if you're using a 32-bit
625 computer.)</li>
626
627 <li>Type <tt class="userinput">cp refind.conf-sample
628 fs0:\EFI\refind\refind.conf</tt> to copy and rename the sample rEFInd
629 configuration file.</li>
630
631 <li>Type <tt class="userinput">cp -r icons fs0:\EFI\refind\</tt> to copy
632 rEFInd's icons.</li>
633
634 <li>Optionally, type <tt class="userinput">cp -r drivers_x64
635 fs0:\EFI\refind\</tt> to copy rEFInd's 64-bit drivers. (You could
636 instead copy the 32-bit drivers or limit yourself to just the drivers
637 you need, of course.)</li>
638
639 <li>Type <tt class="userinput">fs0:</tt>, if necessary, to change to the
640 ESP.</li>
641
642 <li>Type <tt class="userinput">cd \EFI\refind</tt> to change to rEFInd's
643 installation directory.</li>
644
645 <li>If you want to edit rEFInd's options, type <tt class="userinput">edit
646 refind.conf</tt> and use the shell's built-in text editor to do so.
647 Press F2 followed by the Enter key to save your changes and F3 to
648 exit.</li>
649
650 <li>Type <tt class="userinput">bcfg boot dump -b</tt> to see a list of
651 existing NVRAM entries. Pay attention to their numbers (labelled
652 <tt>Option:</tt> and <tt>Variable:</tt>, with the latter number
653 preceded by the string <tt>Boot</tt>, as in <tt>Boot0007</tt>). You'll
654 want to create a boot entry for rEFInd using a number that's not in
655 use.</li>
656
657 <li>Type <tt class="userinput">bcfg boot add 3
658 fs0:\EFI\refind\refind_x64.efi "rEFInd"</tt>, adjusting the number
659 (<tt>3</tt> in this example), filesystem (<tt>fs0:</tt>), and filename
660 (<tt>\EFI\refind\refind_x64.efi</tt>) as necessary for your system. If
661 you're used to Linux, be sure to use backslashes (<tt>\</tt>), not
662 Linux-style forward slashes (<tt>/</tt>) as directory separators. Note
663 that some shells may ignore the number you entered and use another one,
664 so watch for this possibility.</li>
665
666 <li>Type <tt class="userinput">bcfg boot mv <i>3</i> 0</tt>, substituting
667 the option number for the entry you created for <tt
668 class="variable">3</tt>. This moves rEFInd to the top of the boot
669 order.</li>
670
671 <li>Type <tt class="userinput">reset</tt> to reboot the computer.</li>
672
673 </ol>
674
675 <p>With any luck, rEFInd will start up at this point. If not, you can check your settings using a shell or an emergency system for your OS of choice. In an EFI shell, you might type <tt class="userinput">bcfg boot dump -b</tt> to view your boot loader entries and verify that rEFInd appears at the top of the list. Be sure to check the pathname for typos. If you continue to have problems, you might look into giving rEFInd a <a href="#naming">fallback filename</a> that your firmware will recognize.</p>
676
677 <a name="naming">
678 <h2>Alternative Naming Options</h2>
679 </a>
680
681 <p>Some EFI implementations do a poor job of honoring the boot options set via Linux's <tt>efibootmgr</tt> or other tools. You may also lack access to such utilities, such as if you must install rEFInd in Windows. In such cases, you may need to change the boot loader's name so that the EFI will see it as the default boot loader. rEFInd should then boot when your NVRAM lacks information on specific boot loaders to use. To do this, follow these steps:</p>
682
683 <ol>
684
685 <li>Access your ESP and install rEFInd to it, as described in earlier sections.</li>
686
687 <li>Look for an existing directory called <tt>EFI/BOOT</tt> or <tt>EFI/Microsoft/BOOT</tt>. If neither of these directories exist, skip the next step. (Note that FAT is case-insensitive, so the name may vary in case.)</li>
688
689 <li>Rename the existing directory or boot loader file to something else. For <tt>EFI/BOOT</tt>, try renaming it to <tt>EFI/Oldboot</tt>. For <tt>EFI/Microsoft/BOOT</tt>, move or rename the <tt>bootmgfw.efi</tt> file it contains. For instance, you can move it to <tt>EFI/Microsoft</tt>. This will keep the boot loader accessible to rEFInd's menu, while preventing the firmware from launching it automatically.</li>
690
691 <li>Rename/move your <tt>EFI/refind</tt> directory to <tt>EFI/BOOT</tt>. If you're working from <tt>EFI/Microsoft/BOOT</tt>, you should move the contents of your rEFInd directory to <tt>EFI/Microsoft/BOOT</tt>.</li>
692
693 <li>Rename <tt>EFI/BOOT/refind_x64.efi</tt> to the name of the boot loader it's replacing&mdash;it should become <tt>EFI/BOOT/bootx64.efi</tt> or <tt>EFI/Microsoft/BOOT/bootmgfw.efi</tt>.</li>
694
695 </ol>
696
697 <p>When you reboot, rEFInd should come up. With any luck, it will detect your old boot loader as an option, if one was installed before.</p>
698
699 <a name="upgrading">
700 <h2>Upgrading rEFInd</h2>
701 </a>
702
703 <p>If you've installed an earlier version of rEFInd, you can upgrade a bit more easily than you can install directly:</p>
704
705 <ul>
706
707 <li>On a UEFI-based PC, under any OS, you should be able to replace your
708 old rEFInd file with the new one. Make sure that the new rEFInd has the
709 same name as the old one, and that it's for the correct CPU type. Since
710 UEFI launches boot programs by filename, a simple file replacement will
711 suffice to launch the new version. If the new version includes new
712 icons, you may want to copy some or all of them.</li>
713
714 <li>On a Mac, you can copy over the old rEFInd binary file <i>from
715 Linux</i> and it will usually work, provided you copy <i>directly</i>
716 over the old file (rather than rename or delete the old file and then
717 copy the new one in its place). The same caveats about icons as apply
718 to UEFI-based PCs apply in this case. This method requires an extra
719 step in Mac OS X, though....</li>
720
721 <li>In OS X, if you copy over the original file with the new one, you'll
722 probably have to re-bless it to make it work.</li>
723
724 <li>Under Linux or OS X, you can re-run the <tt>install.sh</tt> script. In
725 most cases this works fine, but you'll end up with a duplicate of the
726 icons directory (<tt>icons-backup</tt>, which holds the original icons,
727 whereas <tt>icons</tt> holds the icons from the new package). Normally
728 this just wastes some disk space; but if you've customized your icons,
729 you'll need to copy your altered icons back.</li>
730
731 </ul>
732
733 <p>In all cases, if the new version includes new or altered configuration file options, you may need to manually update your configuration file. Alternatively, if you've used the default configuration file, you can replace your working <tt>refind.conf</tt> with <tt>refind.conf-sample</tt> from the rEFInd zip file. (When using <tt>install.sh</tt>, this file will be copied to rEFInd's installation directory under its original name, so you can rename it within that directory to replace the old file.</p>
734
735 <p>If you're upgrading to rEFInd from rEFIt, you can simply run the <tt>install.sh</tt> script as described earlier or perform a manual installation. Once installed, rEFInd will take over boot manager duties. You'll still be able to launch rEFIt from rEFInd; a rEFIt icon will appear in rEFInd's menu. You can eliminate this option by removing the rEFIt files, which normally reside in <tt>/EFI/refit</tt>.</p>
736
737 <a name="addons">
738 <h2>Installing Additional Components</h2>
739 </a>
740
741 <p>rEFInd includes the ability to launch any EFI program; however, rEFInd detects only certain programs. These include boot loaders in traditional locations and a handful of other programs. To launch these other programs, you must download and install them separately from rEFInd:</p>
742
743 <ul>
744
745 <li><b><a
746 href="http://tianocore.git.sourceforge.net/git/gitweb.cgi?p=tianocore/edk2;a=blob_plain;f=EdkShellBinPkg/FullShell/X64/Shell_Full.efi;hb=HEAD"><tt>shell.efi</tt></a></b>&mdash;This
747 file, placed in the ESP's <tt>efi/tools</tt> directory, adds the
748 ability to launch a text-mode EFI shell from rEFInd. Note that the
749 download link is to a 64-bit binary that must be renamed before rEFInd
750 will recognize it. Additional shell download links appear on the <a
751 href="https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#UEFI_Shell_download_links">Arch
752 Linux wiki,</a> and on other sites; try a Web search if the shell you
753 find doesn't work to your satisfaction.</li>
754
755 <li><b><tt>gptsync.efi</tt></b>&mdash;This program creates a <a
756 href="http://www.rodsbooks.com/gdisk/hybrid.html">hybrid MBR</a> from
757 your regular GPT disk. A hybrid MBR is a dangerous hack that enables
758 Windows and OS X to coexist on a Macintosh disk. If you're using a
759 UEFI-based PC, a hybrid MBR will be useless at best, so you shouldn't
760 create one, and it's safest to not install <tt>gptsync.efi</tt>. If
761 you're using a hybrid MBR to enable dual-booting Windows and OS X on a
762 Mac, though, placing this program file in the ESP's or Mac boot
763 partition's <tt>efi/tools</tt> directory will enable you to regenerate
764 your hybrid MBR should some other tool convert the MBR to a standard
765 protective MBR. You can obtain the file from the <a
766 href="http://refit.sourceforge.net">original rEFIt package.</a></li>
767
768 <li><b>Drivers</b>&mdash;You can install drivers to extend the capabilities
769 of the EFI. rEFInd ships with filesystem drivers for ext2fs and
770 ReiserFS, which can enable you to boot a Linux kernel with EFI stub
771 support from an ext2fs, ext3fs, ext4fs, or ReiserFS partition. (rEFInd also
772 provides ISO-9660 and HFS+ drivers.) You can find additional drivers
773 from other sources, although they're still on the scarce side. See the
774 <a href="drivers.html">Using EFI Drivers</a> page for more on this
775 topic.</li>
776
777 <li><b>Secure Boot files</b>&mdash;If you're running on a system that
778 supports Secure Boot, chances are you'll need extra support files, such
779 as <tt>shim.efi</tt> and <tt>MokManager.efi</tt>. I describe these in
780 detail on the <a href="secureboot.html">Managing Secure Boot</a>
781 page.</li>
782
783 </ul>
784
785 <p>I've seen links to other versions of these tools from time to time on the Web, so if you try one of these programs and it crashes or behaves strangely, try performing a Web search; you may turn up something that works better for you than the one to which I've linked.</p>
786
787 <a name="sluggish">
788 <h2>Fixing a Sluggish Macintosh Boot</h2>
789 </a>
790
791 <p>I've received a few reports of a sluggish boot process (a delay of about 30 seconds before starting rEFInd) on some Macs after installing rEFInd. I've been unable to replicate this problem myself, and its true cause remains mysterious to me. I have found <a href="http://ubuntuforums.org/showpost.php?p=12256273&postcount=200">a Web forum post</a> describing a possible fix. Be aware, though, that this procedure involves using the <tt>efibootmgr</tt> utility on Macs, which has been known to damage the firmware on some Macs. Other reports indicate that this problem has been fixed with 3.3.0 and later kernels. Thus, I present this information cautiously and with a strong "use at your own risk" warning. If you care to proceed, I recommend you update your Linux kernel to the latest possible version and then proceed as follows:</p>
792
793 <ol>
794
795 <li>Boot into Linux.</li>
796
797 <li>Type <tt class="userinput">efibootmgr</tt> as <tt>root</tt> to obtain a list of your boot loader entries. Each entry includes a boot number, as in <tt>Boot0003</tt> or <tt>Boot0027</tt>.</li>
798
799 <li>Remove all of the boot loader entries <i>except</i> rEFInd's by using <tt>efibootmgr</tt>'s <tt>-b <tt class="variable">bootnum</tt></tt> option to specify the boot entry and <tt>-B</tt> to delete it. For instance, typing <tt class="userinput">efibootmgr -b 0027 -B</tt> as <tt>root</tt> deletes boot entry <tt>Boot0027</tt>. Issue a separate <tt>efibootmgr</tt> command for each boot entry.</li>
800
801 <li>Re-install rEFInd using the install script. It's unclear from the original post if this meant installing from Linux or from OS X.</li>
802
803 </ol>
804
805 <p>Some sources suggest that delayed launches of rEFInd on Macs are more common when installing rEFInd to the ESP, so if you've done this, you could try re-installing it to your OS X boot partition.</p>
806
807 <a name="uninstalling">
808 <h2>Uninstalling rEFInd</h2>
809 </a>
810
811 <p>If you decide you don't want to keep rEFInd, you can uninstall it. Doing so is a matter of removing the rEFInd files from your ESP (or from your OS X boot partition, if you installed the program there). In Linux, a command like the following, typed as <tt>root</tt>, should do the trick:</p>
812
813 <pre class="listing">
814 # <tt class="userinput">rm -r /boot/efi/EFI/refind</tt>
815 </pre>
816
817 <p>This example assumes that your ESP is mounted at <tt>/boot/efi</tt> and that rEFInd is installed in <tt>EFI/refind</tt> on that partition. If you've mounted your ESP elsewhere, or installed rEFInd elsewhere, you should adjust the command appropriately.</p>
818
819 <p>The same procedure works in OS X, with the caveat that the ESP isn't normally mounted in OS X and rEFInd is installed to the OS X boot partition by default. You'll also need to use <tt>sudo</tt> to acquire <tt>root</tt> privileges. Thus, you'd probably use a command like the following in OS X:</p>
820
821 <pre class="listing">
822 $ <tt class="userinput">sudo rm -r /EFI/refind</tt>
823 </pre>
824
825 <p>Many variants of both of these commands are possible on both OS X and Linux. For instance, you'd probably use <tt>sudo</tt> on Ubuntu; and if you installed rEFInd to your ESP on a Mac, you'd need to first mount the ESP and include its path in the <tt>rm</tt> command.</p>
826
827 <p>From Windows, you must reverse the directions for <a href="#windows">installing in Windows</a>&mdash;type <tt class="userinput">mountvol S: /S</tt> to mount your ESP as <tt>S:</tt>, then navigate to the <tt>S:\EFI</tt> directory and delete the <tt>refind</tt> subdirectory.</p>
828
829 <p>In any of these cases, when the computer boots and cannot find the rEFInd files, it should move on to the next boot loader in its list. In my experience, some EFI firmware implementations remove boot loaders they can't find from their NVRAM lists, so nothing else will be required, provided you have another working boot loader in your firmware's list. If your firmware doesn't automatically clean up its NVRAM entries, rEFInd's entry will do little harm; however, you can delete it with the <tt>efibootmgr</tt> utility in Linux:</p>
830
831 <pre class="listing">
832 # <tt class="userinput">efibootmgr --verbose</tt>
833 Timeout: 10 seconds
834 BootOrder: 0000,0007
835 Boot0000* rEFInd HD(2,1b8,64000,f1b7598e-baa8-16ea-4ef6-3ff3b606ac1e)File(\EFI\refind\refind.efi)
836 Boot0007* CD/DVD Drive BIOS(3,0,00)PATA: HP DVD Writer 1040r .
837 # <tt class="userinput">efibootmgr --delete-bootnum --bootnum 0000</tt>
838 Timeout: 10 seconds
839 BootOrder: 0007
840 Boot0007* CD/DVD Drive</pre>
841
842 <p class="sidebar"><b>Warning:</b> As noted earlier, <tt>efibootmgr</tt> has been linked to firmware corruption on some Macs, at least with pre-3.0 Linux kernels. Therefore, I don't recommend using <tt>efibootmgr</tt> on Macs.</p>
843
844 <p>This example shows use of <tt>efibootmgr</tt>'s <tt>--verbose</tt> (<tt>-v</tt>) option to display boot loaders so as to identify which one is rEFInd, followed by <tt>--delete-bootnum</tt> (<tt>-B</tt>) to delete a boot program and <tt>--bootnum</tt> (<tt>-b</tt>) to identify which one to delete. Of course, in this example there's not much else left, so you'd presumably want to install another boot loader at this point! If you already have another one installed, you may want to check the <tt>BootOrder</tt> line to determine which one will take precedence when you reboot. If you don't like what it shows, you can adjust it with the <tt>--bootorder</tt> (<tt>-o</tt>) option; consult <tt>efibootmgr</tt>'s <tt>man</tt> page for details.</p>
845
846 <p>If you're not using Linux, you may be able to find a utility that serves a similar function. The OS X <tt>bless</tt> utility (or its GUI equivalent, the Startup Disk item in System Preferences) should do the trick; but Macs pick up standard OS X boot loaders when they boot and find that a configured non-standard boot loader is missing, so this shouldn't be necessary on Macs. Under Windows, the <tt>bcdedit</tt> command, described in the <a href="#windows">section on installing rEFInd under Windows,</a> may work, although I've not attempted this.</p>
847
848 <hr />
849
850 <p>copyright &copy; 2012 by Roderick W. Smith</p>
851
852 <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>
853
854 <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>
855
856 <p><a href="index.html">Go to the main rEFInd page</a></p>
857
858 <p><a href="using.html">Learn how to use rEFInd</a></p>
859
860 <p><a href="http://www.rodsbooks.com/">Return</a> to my main Web page.</p>
861 </body>
862 </html>