Clover 四叶草引导工具科普

Home / Hackintosh MrLee 2015-9-3 11773

作为黑苹果常用的引导工具之一的Clover,简单科普一下吧!

基本概论

Clover支持两种启动方式,启动过程如下:
启动方式A: 基于BIOS的电脑(老式主板) BIOS>MBR>PBR>boot>CLOVERX64.efi>OSLoader
启动方式B: 基于UEFI的电脑(新式主板) UEFI>CLOVERX64.efi>OSLoader
Mac OS X的操作系统加载器(OSLoader)是boot.efi, Windows的则是bootmgr.efi。
两种启动方式所涉及到的文件或目录(即本章的内容)如下:

MBR 扇区

扇区位于存储设备(传统硬盘、固态硬盘、USB记忆棒、USB硬盘、DVD)的起始位置。前440个字节可能包含这些不同引导程序的的某一种:
  1. boot0 - 查找MBR中的活动分区并将控制权交给它的PBR扇区。也有可能是GPT和MBR的混合式布局。如果是纯GTP磁盘分区布局,那么控制权将交给EFI分区。进一步移交 boot0af (首先激活).
  2. boot0hfs - 查找第一个签名为0xAF的分区。如包含OS X的HFS+的分区,并将控制权交给它的PBR。按照这种方式系统将从以GPT磁盘分区架构设备的HFS+分区中启动,并且只能从第一个分区启动。进一步移交给 boot0ss (扫描签名).
  3. boot0ab - 查找签名为0xAB的分区 - Apple启动分区.
  4. boot0md - 结合所有情况查找多个设备上的HFS+分区, 并非主存储设备。

PBR 扇区

在一个存储设备的每个分区的起始位置有一个引导扇区。第二阶段的加载器存储在这里。它知道分区的文件系统并且能够找到 boot 文件,加载该文件并传递控制权。根据文件系统存在不同的引导程序:
  1. boot1h2 - 支持 HFS+ 文件系统,具有大小高达 472kb 的引导文件。与 "Chameleon" 捆绑在一起的老的 boot1h 引导文件只支持大小为 440kb 的引导文件(需要 472kb)。停顿两秒来提供切换加载器的选项。
  2. boot1h - 与上面相同,不包含停顿。
  3. boot1f32alt - 支持 FAT32。这个文件系统具有写入能力并且非常适合于安装启动加载器。可以将它用在一个EFI分区上或者用在 USB 闪存驱动器上,它通常销售时已经预先格式化为 FAT32。此引导程序也提供两秒的停顿。
  4. boot1f32 - 与上面相同,不包含停顿。
此外,它们还提供另一个有用的功能。在这两秒的停顿中可以按下键盘上的一个数字来启动一个特定的加载器。按下键 1 将启动文件 boot1 ,按下键 3 将启动文件 boot3 而且按下键 6 将启动文件 boot6 。这种方式可以在一个位置保存一组加载器。例如:
  1. boot - Clover,最新版本或者测试版本
  2. boot1 - Chameleon
  3. boot3 - Clover 32位,已测试并且工作的版本
  4. boot6 - Clover 64位,已测试并且工作的版本
  5. boot7 - Clover 64位,带有 BiosBlockIO 驱动,可以与 BIOS 支持的任一控制器工作。
除了这些引导程序,PBR 可能包含 Windows 引导管理器(能够处理 NTFS), GRUB (能够处理 EXT4)以及其它与 Clover 不相关引导程序 - 至少目前是这样。

Boot and CloverEFI

译注:这里的Boot指的是启动方式A中的第四步“boot”,这一步骤要运行一个启动引导程序(bootloader),它就是CloverEFI。
In Chameleon, the boot file is a whole bootloader. In Clover, however, it contains the whole EFI system and a boot service for passing control to the next phase (option A). Alternatively all this is supposed to be contained in the PC's ROM (option B). In reality, however, this is not always the case and some parts need to be loaded in addition. In contrast to earlier stages the boot file has different bit depths, i.e. different variants for 32-bit and 64-bit loading. Usually it is advised to chose 64-bit if the CPU supports this instruction set. If you work with a 32-bit OS, it makes sense to load via 32-bit EFI. It is 20% smaller, slightly faster, however not compatible with Windows 7 EFI - which is only compatible with 64-bit. In general the boot file is a modified variant of DUET with barely 1% of changes. Nonetheless, this 1% makes the big difference - Clover manages to do what it is designed for. If anyone should assume that adding AppleSim to DUET is enough, well, then good luck! This is by far not enough. DUET can be compiled for one specific computer defined by its PCD constants but Clover needs to work for everyone. I have no intention to explain the details, the work is already done. Further this program will be referred to as CloverEFI.

CloverIA32.efi and CloverX64.efi or CloverGUI

译注:CloverIA32.efi和CloverX64.efi统称为CloverGUI,即Clover的图形用户界面。
This file - available in two variants for two different bit depths - represents the graphical interface. It is used for choosing an operating system, for tweaking settings, for loading additional drivers and finally for loading an OS. Graphics and the menu are based on the rEFIt project, which is reflected on the according directory name and the About screen. Currently the original part (partially fixed) takes about 10% of the whole program.

目录结构

Clover启动程序(就是上文提到的CloverGUI)需要一些支持文件,它们的目录结构如下(as of v2k r2334):

Clover 四叶草引导工具百科全书 | 基本概论

Clover 四叶草引导工具百科全书 | 基本概论

Clover 四叶草引导工具百科全书 | 基本概论


也就是CloverX64.efi要放在/EFI/CLOVER/目录下,字体文件WoB_PTMono_10W_NA.png要放在/EFI/CLOVER/themes/black_green/目录下。通常类似的这些目录中还包含更多其它内容。各个文件的具体用途将在后面说明。
/EFI/CLOVER/OEM/目录的用途
这个目录用来存储不同的配置信息。典型的情况就是加载一个可启动的USB闪存驱动器。除了通用的配置文件/EFI/CLOVER/config.plist,还可以在OEM目录下包含针对特定机型的其它配置文件,比如: /EFI/CLOVER/OEM/Inspiron 1525/config.plist,或者 /EFI/CLOVER/OEM/H61M-S1/UEFI/config.plist外加自定义DSDT.aml
OEM目录下的子目录名称是根据SMBIOS得到的,可以在preboot.log日志文件中查到。当你在Clover启动界面按下F2时,日志文件preboot.log就会保存到/EFI/Clover/misc目录下。以下内容就是在Inspiron 1525上运行Clover r1709得到:
10:061 0:000 Clover revision: 1709 running on Inspiron 1525 10:061 0:000 ... with board 0U990C
如果是组装的台式电脑,显示信息会有点不同。以下内容是在技嘉Z68MX-UD2H-B3主板上(主板BIOS中没有定义SystemProductName)运行Clover r2334得到的:
0:100 0:000 Clover revision: 2334 running on To be filled by O.E.M. 0:100 0:000 ... with board Z68MX-UD2H-B3
第一行包含了系统名称(SystemProductName),第二行包含的是主板型号。笔记本可以由系统名称来识别,组装电脑可以由主板型号来识别。你可以选择任意一种识别方式,只要方便就行。另外可以在配置目录(/EFI/CLOVER/OEM/SystemProductName/)下包含一个UEFI目录来区分UEFI启动(选项A)和常规启动(选项B)。

EFI驱动程序

BIOS启动过程中(启动方式A)要用到drivers32或drivers64目录,UEFI启动过程中(启动方式B)则使用driversUEFI目录。它们的内容会根据配置和BIOS版本而有所不同。
必须要提的一点是这些驱动程序只在bootloader运行时有效,不会影响最终启动的操作系统。
至于到底要使用哪些驱动程序由用户来决定。
NTFS.efi NTFS文件系统驱动程序。用于启动Windows EFI系统。
HFSPlus.efi HFS+文件系统驱动程序。这个驱动对于通过启动方式B来启动Mac OS X是必须的。启动方式A中用到的启动程序(CloverEFI)已经包含了这个驱动。
VBoxHFS.efi HFSPlus.efi的替代品,性能要差一点。
VBoxExt2.efi EXT2/3文件系统驱动。用于启动Linux EFI系统。
VBoxExt4.efi EXT4文件系统驱动。用于启动Linux EFI系统。
FSInject.efi Takes control of the file system for the possibility to inject external kexts into the system. See WithKexts for a detailed explanation.
PartitionDxe.efi Already present in CloverEFI and in UEFI, however neither optimised for Apple partitions, nor for GPT/MBR. Most probably necessary for (option B).
OsxFatBinaryDrv.efi Enables starting of FAT modules like boot.efi. Necessary for (option B).
OsxAptioFixDrv.efi Fixes memory map created by AMI Aptio EFI. Booting OS X is impossible otherwise.
OswLowMemFix.efi Simplified variant of OsxAptioFixDrv. Do not use both simultaneously.
Usb*.efi, UHCI.efi, EHCI.efi, XHCI.efi Set of drivers for the case when built-in driver do not work well with (option B) because a dependancy might have been cut off.
PS2Mouse*.efi, PS2MouseAbsolute*.efi, UsbMouse*.efi Set of drivers for mouse/trackpad/touchpad support in CloverGUI. They have no effect on the OS.
DataHubDxe.efi Already present in CloverEFI and possibly in UEFI. The recommendation is to use anyway, no conflict will arise.
CsmVideoDxe.efi Video driver for providing a wider set of resolutions than the ones present in UEFI for (option B).

本文链接:https://www.it72.com/5462.htm

推荐阅读
最新回复 (0)
返回