From 7fb7030ef7b7c7332074afb76dd257e1992ca86c Mon Sep 17 00:00:00 2001 From: srs5694 Date: Wed, 2 Jan 2013 22:08:29 -0500 Subject: [PATCH 1/1] Improvements to installation script. --- docs/refind/installing.html | 139 +++++++++++++++++++++++------------- install.sh | 2 +- mkdistrib | 4 +- refind.spec | 8 ++- 4 files changed, 99 insertions(+), 54 deletions(-) diff --git a/docs/refind/installing.html b/docs/refind/installing.html index 05ebb41..5fd14bb 100644 --- a/docs/refind/installing.html +++ b/docs/refind/installing.html @@ -114,8 +114,6 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

  • Extra install.sh Instructions
  • -
  • Using refind-unhijack.sh
  • -
  • Installing rEFInd Manually @@ -130,7 +128,15 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

  • Installing rEFInd Manually Using an EFI Shell
  • -
  • Alternative Naming Options
  • +
  • Alternative Naming Options + +
  • Upgrading rEFInd
  • @@ -158,7 +164,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

    Either command produces output similar to that described for using the install.sh script, 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.

    -

    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 install.sh uses might not last for long. You might therefore want to run the refind-unhijack.sh script after you boot Linux in EFI mode for the first time.

    +

    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 install.sh uses might not last for long. You might therefore want to use mvrefind.sh to move your rEFInd installation to another name after you boot Linux for the first time from rEFInd.

    Since version 0.6.2-2, my package files have installed the rEFInd binaries to /usr/share/refind-version, the documentation to /usr/share/doc/refind-version, and a few miscellaneous files elsewhere. Upon installation, the package runs the install.sh script to copy the files to the ESP. This enables you to re-install rEFInd after the fact by running install.sh, should some other tool or OS wipe the ESP or should the installation go awry. In such cases you can use install.sh or install manually.

    @@ -175,7 +181,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

    Under Linux, the install.sh 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 --esp option. Under either OS, you can install to something other than the currently-running OS by using the --root /mountpoint option. (See Table 1 for details.)

    -

    Before running this script under Linux, you should ensure that your ESP is mounted at /boot or /boot/efi, as described in more detail in the Installing rEFInd Manually Using Linux 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 install.sh 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 refind-unhijack.sh script.

    +

    Before running this script under Linux, you should ensure that your ESP is mounted at /boot or /boot/efi, as described in more detail in the Installing rEFInd Manually Using Linux 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 install.sh 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 mvrefind.sh script.

    A sample run under Linux looks something like this:

    @@ -342,44 +348,6 @@ install.sh [--esp | --usedefault device-file | --root

    In any event, you should peruse the script's output to ensure that everything looks OK. install.sh 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.

    - -

    Using refind-unhijack.sh

    -
    - -

    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 install.sh script has attempted to install in one of three ways when run from BIOS mode:

    - - - -

    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 install.sh uses this method, it notifies you of the fact:

    - -
    Running in BIOS mode with a suspected Windows installation; moving boot loader
    -files so as to install to /boot/efi/EFI/Microsoft/Boot.
    - -

    The install.sh 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 refind-unhijack.sh script. This script moves the rEFInd installation files to a more appropriate location on the ESP (EFI/refind) and registers rEFInd with the EFI in the officially-sanctioned manner.

    - -

    Unfortunately, on some systems you really should leave rEFInd installed as EFI/Microsoft/Boot/bootmgfw.efi; 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 refind-unhijack.sh or not as you deem best.

    - -

    To run the script, type its name (and perhaps its path) as root. It will report on what it does:

    - -
    # ./refind-unhijack.sh
    -I'm not yet written!
    - -

    If you run this script on a system whose Windows boot loader has not 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.

    -

    Installing rEFInd Manually

    @@ -678,19 +646,83 @@ $ ioreg -l -p IODeviceTree | grep firmware-abi

    Alternative Naming Options

    +

    Some EFI implementations do a poor job of honoring the boot options set via Linux's efibootmgr 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. Broadly speaking, there are two alternative names that are most useful:

    + + + +

    If you need to use one of these names, or something more exotic, you can do so in either of two ways: You can use the mvrefind.sh script to move your installation in one step, or you can move and rename your files manually.

    + + +

    Using mvrefind.sh

    +
    + +

    The easiest way to move a rEFInd installation, at least in Linux, is to use the mvrefind.sh script. If you installed from one of my RPM or Debian packages, this script should be installed in /usr/sbin, so you can use it like a regular Linux command; otherwise you'll need to install it to your path yourself or type its complete path. Either way, it works much like the Linux mv command, but you pass it the directory in which a rEFInd installation appears and a target location:

    + +
    +# mvrefind.sh /boot/efi/EFI/BOOT /boot/efi/EFI/refind
    +
    + +

    This example moves rEFInd from /boot/efi/EFI/BOOT to /boot/efi/EFI/refind. It differs from mv in several ways: + +

    + +

    The mvrefind.sh script is likely to be useful in resolving boot problems—if your system won't boot, you can try copying the installation to /boot/efi/EFI/BOOT, /boot/efi/EFI/Microsoft/Boot, and /boot/efi/EFI/refind in turn, testing the boot process after each attempt. (These filenames all assume your ESP is mounted at /boot/efi.) You could also copy a BIOS-mode install from /boot/efi/EFI/BOOT or /boot/efi/EFI/Microsoft/Boot to /boot/efi/EFI/refind to make it more robust against Windows repairs (assuming your firmware isn't broken).

    + + +

    Renaming Files Manually

    +
    +

    Some EFI implementations do a poor job of honoring the boot options set via Linux's efibootmgr 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:

    1. Access your ESP and install rEFInd to it, as described in earlier sections.
    2. -
    3. Look for an existing directory called EFI/BOOT or EFI/Microsoft/BOOT. If neither of these directories exist, skip the next step. (Note that FAT is case-insensitive, so the name may vary in case.)
    4. +
    5. Look for an existing directory called EFI/BOOT or EFI/Microsoft/Boot. If neither of these directories exist, skip the next step. (Note that FAT is case-insensitive, so the name may vary in case.)
    6. -
    7. Rename the existing directory or boot loader file to something else. For EFI/BOOT, try renaming it to EFI/Oldboot. For EFI/Microsoft/BOOT, move or rename the bootmgfw.efi file it contains. For instance, you can move it to EFI/Microsoft. This will keep the boot loader accessible to rEFInd's menu, while preventing the firmware from launching it automatically.
    8. +
    9. Rename the existing directory or boot loader file to something else. For EFI/BOOT, try renaming it to EFI/Oldboot. For EFI/Microsoft/Boot, move or rename the bootmgfw.efi file it contains. For instance, you can move it to EFI/Microsoft. This will keep the boot loader accessible to rEFInd's menu, while preventing the firmware from launching it automatically.
    10. -
    11. Rename/move your EFI/refind directory to EFI/BOOT. If you're working from EFI/Microsoft/BOOT, you should move the contents of your rEFInd directory to EFI/Microsoft/BOOT.
    12. +
    13. Rename/move your EFI/refind directory to EFI/BOOT. If you're working from EFI/Microsoft/Boot, you should move the contents of your rEFInd directory to EFI/Microsoft/Boot.
    14. -
    15. Rename EFI/BOOT/refind_x64.efi to the name of the boot loader it's replacing—it should become EFI/BOOT/bootx64.efi or EFI/Microsoft/BOOT/bootmgfw.efi.
    16. +
    17. Rename EFI/BOOT/refind_x64.efi to the name of the boot loader it's replacing—it should become EFI/BOOT/bootx64.efi or EFI/Microsoft/Boot/bootmgfw.efi.
    @@ -726,7 +758,16 @@ $ ioreg -l -p IODeviceTree | grep firmware-abi icons directory (icons-backup, which holds the original icons, whereas icons holds the icons from the new package). Normally this just wastes some disk space; but if you've customized your icons, - you'll need to copy your altered icons back. + you'll need to copy your altered icons back. Since version 0.6.2, + install.sh has searched for rEFInd in several locations on the + ESP, and will upgrade whatever it finds. + +
  • Under an RPM- or Debian-based Linux distribution, you can use your + package system to install a newer version of the RPM or Debian package + that I provide. This will upgrade the files in your Linux filesystem + and re-run the install.sh script, so as with the previous + options, you'll waste a little disk space on duplicated icons, but the + process should otherwise work quite well.
  • @@ -824,6 +865,8 @@ $ sudo rm -r /EFI/refind

    Many variants of both of these commands are possible on both OS X and Linux. For instance, you'd probably use sudo 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 rm command.

    +

    If you installed via an RPM or Debian package in Linux, using your package manager will remove the package files, but not the files that the installer places on your ESP. Thus, you must uninstall those files manually, as just described. To complete the job, you'll also have to remove /boot/refind_linux.conf, and perhaps the /etc/refind.d directory.

    +

    From Windows, you must reverse the directions for installing in Windows—type mountvol S: /S to mount your ESP as S:, then navigate to the S:\EFI directory and delete the refind subdirectory.

    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 efibootmgr utility in Linux:

    diff --git a/install.sh b/install.sh index 91e66a4..2aa1491 100755 --- a/install.sh +++ b/install.sh @@ -589,7 +589,7 @@ FindLinuxESP() { exit 1 fi echo "ESP was found at $InstallDir using $EspFilesystem" -} # MountLinuxESP +} # FindLinuxESP # Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM. # If this fails, sets Problems=1 diff --git a/mkdistrib b/mkdistrib index 47942b2..972d74e 100755 --- a/mkdistrib +++ b/mkdistrib @@ -47,7 +47,7 @@ make clean # Prepare a place and copy files there.... mkdir -p ../snapshots/$1/refind-$1/icons cp --preserve=timestamps icons/*icns ../snapshots/$1/refind-$1/icons/ -cp -a docs images keys include EfiLib libeg mok refind filesystems refind.spec install.sh mkrlconf.sh CREDITS.txt NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Makefile refind.conf-sample ../snapshots/$1/refind-$1 +cp -a docs images keys include EfiLib libeg mok refind filesystems refind.spec install.sh mkrlconf.sh mvrefind.sh CREDITS.txt NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Makefile refind.conf-sample ../snapshots/$1/refind-$1 # Go there and prepare a souce code zip file.... cd ../snapshots/$1/ @@ -84,7 +84,7 @@ else cp refind/refind_x64.efi refind-bin-$1/refind/refind_x64.efi fi cp refind-bin-$1/refind/refind_x64.efi $StartDir -cp -a docs keys COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt install.sh mkrlconf.sh refind-bin-$1 +cp -a docs keys COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt install.sh mkrlconf.sh mvrefind.sh refind-bin-$1 # Prepare the final .zip file zip -9r ../refind-bin-$1.zip refind-bin-$1 diff --git a/refind.spec b/refind.spec index b0ca30e..ff88327 100644 --- a/refind.spec +++ b/refind.spec @@ -1,7 +1,7 @@ Summary: EFI boot manager software Name: refind -Version: 0.6.2 -Release: 4%{?dist} +Version: 0.6.2.1 +Release: 1%{?dist} License: GPLv3 URL: http://www.rodsbooks.com/refind/ Group: System Environment/Base @@ -89,9 +89,10 @@ install -Dp -m0644 NEWS.txt COPYING.txt LICENSE.txt README.txt CREDITS.txt $RPM_ mkdir -p $RPM_BUILD_ROOT/etc/refind.d/keys install -Dp -m0644 keys/* $RPM_BUILD_ROOT/etc/refind.d/keys -# Copy mkrlconf.sh to /usr/sbin +# Copy scripts to /usr/sbin mkdir -p $RPM_BUILD_ROOT/usr/sbin install -Dp -m0755 mkrlconf.sh $RPM_BUILD_ROOT/usr/sbin/ +install -Dp -m0755 mvrefind.sh $RPM_BUILD_ROOT/usr/sbin/ %clean rm -rf $RPM_BUILD_ROOT @@ -100,6 +101,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root -) %doc /usr/share/doc/refind-%{version} /usr/sbin/mkrlconf.sh +/usr/sbin/mvrefind.sh /usr/share/refind-%{version} /etc/refind.d/ -- 2.39.2