- EFI system partition (Русский)
- Contents
- Создание раздела
- Разметка дисков GPT
- Разметка дисков MBR
- Форматирование раздела
- Монтирование раздела
- Известные вопросы
- ESP на RAID
- Советы и хитрости
- Использование bind монтирования
- EFISTUB
- Contents
- Preparing for EFISTUB
- Booting EFISTUB
- Using a boot manager
- Using UEFI directly
- efibootmgr
- efibootmgr with .efi file
- kesboot
- More tools
- Using UEFI Shell
- Using a startup.nsh script
- Troubleshooting
- Cannot create a new boot entry with efibootmgr
- Newly created boot entries are removed
- EFISTUB does not work on some Dell systems
- EFI system partition
- Contents
- Check for an existing partition
- Create the partition
- GPT partitioned disks
- MBR partitioned disks
- Format the partition
- Mount the partition
- Typical mount points
- Alternative mount points
- Using bind mount
- Using systemd
- Using filesystem events
- Using mkinitcpio hook
- Using mkinitcpio preset
- Using pacman hook
- Troubleshooting
- ESP on software RAID1
EFI system partition (Русский)
Системный раздел EFI (также называемый ESP или EFISYS) представляет собой физический раздел в формате FAT32 (в основной таблице разделов диска, а не под LVM или программным RAID и т.д.), откуда прошивка UEFI запускает загрузчик и приложение UEFI.
Это независимый от ОС раздел, который служит местом хранения загрузочных устройств EFI и приложений, которые будут запускаться с помощью прошивки EFI. Это необходимо для загрузки UEFI.
Contents
Создание раздела
В следующих двух разделах показано, как создать системный раздел EFI (ESP).
Рекомендуется сохранять размер ESP на 512 Мбайт, хотя меньшие/большие размеры тоже приветствуются. [1]
Согласно примечанию Microsoft[2], минимальный размер для системного раздела EFI (ESP) будет составлять 100 МБ, хотя это не указано в спецификации UEFI. Обратите внимание, что для дисков расширенный формат 4K Native drives (4 КБ на сектор) размер составляет не менее 256 Мбайт, поскольку это минимальный размер раздела дисков FAT32 (рассчитанный как размер сектора (4 КБ) x 65527 = 256 Мбайт), из-за ограничений файловой системы FAT32.
Разметка дисков GPT
Выберите один из следующих способов создания ESP для диска GPT с разделами:
- fdisk/gdisk: Создайте раздел с типом раздела EFI System ( EFI System в fdisk или EF00 в gdisk). Перейдите к разделу #Форматирование раздела ниже.
- GNU Parted: Создайте раздел FAT32 и в Parted установите/активируйте флаг boot (не флаг legacy_boot ) на этом разделе. Перейдите к разделу #Монтирование раздела ниже.
Разметка дисков MBR
Создайте раздел с типом раздела EFI System, используя fdisk. Перейдите к #Форматирование раздела.
Форматирование раздела
После создания ESP вы должны форматировать его как FAT32:
Если вы использовали GNU Parted выше, тогда раздел уже должен быть отформатирован.
Если вы получили сообщение WARNING: Not enough clusters for a 32 bit FAT! , уменьшите размер кластера с помощью команды mkfs.fat -s2 -F32 . или -s1 ; иначе раздел может быть нечитаемым UEFI.
Монтирование раздела
This article or section needs expansion.
В случае EFISTUB файлы ядра и initramfs должны храниться в системном разделе EFI. Для простоты вы также можете использовать ESP в качестве самого раздела /boot вместо отдельного раздела /boot для загрузки EFISTUB. Другими словами, после создания и форматирования системного раздела EFI, как указано выше, просто смонтируйте на /boot .
Известные вопросы
ESP на RAID
Можно сделать часть ESP массива RAID1, но при этом возникает риск повреждения данных, и при создании ESP необходимо учитывать дополнительные соображения. Для получения допольнительной информации смотрите [3] и [4].
Советы и хитрости
Использование bind монтирования
Вместо того, чтобы устанавливать ESP на /boot , вы можете подключить каталог ESP к /boot с помощью bind монтирования (смотрите mount(8) ). Это позволяет pacman обновлять ядро напрямую, сохраняя при этом организацию ESP по своему вкусу.
Как и в EFISTUB#Альтернативные точки монтирования для ESP [ссылка недействительна: раздел не найден] , скопируйте все загрузочные файлы в каталог вашего ESP, но смонтируйте ESP вне /boot (например, /esp ). Затем привяжите смонтированный раздел к каталогу:
После проверки успеха отредактируйте свой Fstab, чтобы изменения были постоянными:
Источник
EFISTUB
The Linux kernel supports EFISTUB booting which allows EFI firmware to load the kernel as an EFI executable. The option is enabled by default on Arch Linux kernels, or if compiling the kernel one can activate it by setting CONFIG_EFI_STUB=y in the Kernel configuration. See The EFI Boot Stub for more information.
With EFISTUB a kernel can be booted directly by a UEFI motherboard or indirectly using a boot loader. Using a boot loader is recommended if you have multiple kernel/initramfs pairs and your motherboard’s UEFI boot menu is not easy to use.
Contents
Preparing for EFISTUB
First, you must create an EFI system partition and choose how it is mounted. See EFI system partition#Mount the partition for all available ESP mounting options.
Booting EFISTUB
Using a boot manager
This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.
There are several UEFI boot managers which can provide additional options or simplify the process of UEFI booting — especially if you have multiple kernels/operating systems. See Arch boot process#Boot loader for more information.
Using UEFI directly
UEFI is designed to remove the need for an intermediate bootloader such as GRUB. If your motherboard has a good UEFI implementation, it is possible to embed the kernel parameters within a UEFI boot entry and for the motherboard to boot Arch directly. You can use efibootmgr or UEFI Shell v2 to modify your motherboard’s boot entries.
efibootmgr
To create a boot entry with efibootmgr that will load the kernel:
or create a boot entry with efibootmgr and hibernation on swap partition:
Where /dev/sdX and Y are the drive and partition number where the ESP is located. Change the root= and resume= parameters to reflect your Linux root and swap partitions, see kernel parameters for supported device name formats, and persistent block device naming for how to obtain the corresponding value. If omitted, then the first partition on /dev/sda is used as the ESP.
Note that the -u / —unicode argument in quotes is just the list of kernel parameters, so you may need to add additional parameters (e.g. for suspend to disk or microcode).
After adding the boot entry, you can verify the entry was added properly with:
To set the boot order:
Where XXXX is the number that appears in the output of efibootmgr command against each entry.
efibootmgr with .efi file
This article or section is a candidate for merging with systemd-boot#Preparing a unified kernel image.
If using cryptboot AUR and sbupdate-git AUR to generate your own keys for Secure Boot and sign the initramfs and kernel then create a bootable .efi image, efibootmgr can be used directly to boot the .efi file:
See efibootmgr(8) for an explanation of the options. To include microcode in a unified kernel image, concatenate it with the initramfs and use the resultant image with objtool.
Some UEFI implementations make it difficult to modify the NVRAM successfully using efibootmgr. If efibootmgr cannot successfully create an entry, you can use the bcfg command in UEFI Shell v2 (i.e., from the Arch Linux live iso).
First, find out the device number where your ESP resides with:
In this example, 1 is used as the device number. To list the contents of the ESP:
To view the current boot entries:
To add an entry for your kernel, use:
Where N is the location where the entry will be added in the boot menu. 0 is the first menu item. Menu items already existing will be shifted in the menu without being discarded.
Add the necessary kernel options by creating a file on your ESP:
In the file, add the boot line. For example:
Press F2 to save and then F3 to exit.
Add these options to your previous entry:
Repeat this process for any additional entries.
To remove a previously added item do:
kesboot
You can also simplify and automate the work with EFISTUB using a script from the kesboot-git AUR package. It also contains a pacman hook that can add and remove EFI variables during actions with packages.
First, install the package, and then configure the /etc/kesboot.conf file:
The package also contains a program for the initial configuration of the EFI boot. After mounting the ESP directory, run
More tools
This section is being considered for removal.
Some of the tools above, and more, are briefly discussed in rEFInd#Tools.
Using UEFI Shell
If you do not want to create a permanent boot entry it is possible to launch the kernel from UEFI Shell as if it is a normal UEFI application:
In this case, the kernel parameters are passed as normal parameters to the launched EFISTUB kernel file.
To avoid needing to remember all of your kernel parameters every time, you can save the executable command to a shell script such as archlinux.nsh on your UEFI System Partition, then run it with:
Using a startup.nsh script
Some UEFI implementations do not retain EFI variables between cold boots (e.g. VirtualBox before version 6.1) and anything set through the UEFI firmware interface is lost on poweroff.
The UEFI Shell Specification 2.0 establishes that a script called startup.nsh at the root of the ESP partition will always be interpreted and can contain arbitrary instructions; among those you can set a bootloading line. Make sure you mount the ESP partition on /boot and create a startup.nsh script that contains a kernel bootloading line. For example:
This method will work with almost all UEFI firmware versions you may encounter in real hardware, you can use it as last resort. The script must be a single long line. Sections in brackets are optional and given only as a guide. Shell style linebreaks are for visual clarification only. FAT filesystems use the backslash as path separator and in this case, the backslash declares the initramfs is located in the root of the ESP partition. Only Intel microcode is loaded in the booting parameters line; AMD microcode is read from disk later during the boot process; this is done automatically by the kernel.
Troubleshooting
Cannot create a new boot entry with efibootmgr
This article or section is a candidate for moving to Unified Extensible Firmware Interface#Troubleshooting.
Some kernel and efibootmgr version combinations might refuse to create new boot entries. This could be due to lack of free space in the NVRAM. You can try deleting any EFI dump files:
Or, as a last resort, boot with the efi_no_storage_paranoia kernel parameter. You can also try to downgrade your efibootmgr install to version 0.11.0. This version works with Linux version 4.0.6. See the bug discussion FS#34641, in particular the closing comment, for more information.
Newly created boot entries are removed
The factual accuracy of this article or section is disputed.
Some motherboards may remove boot entries after a couple of boots. This could be due to lack of free space in the NVRAM. To prevent this from occurring, it may help to reduce the amount of Linux boot entries being added by efibootmgr by minimizing your entry creation process, as well as reducing the amount of automatic drive boot entries by the Compatibility Support Module (CSM) by disabling it from your UEFI settings.
EFISTUB does not work on some Dell systems
Several generation Dell BIOSes are wrongly passing the arguments to the bootloader, thus making EFISTUB parse a null command line which normally means unbootable system (see the complete linux-efi thread).
A workaround has been found since Linux 5.10 to correct this behavior (see this commit ). For Linux See also
Источник
EFI system partition
The EFI system partition (also called ESP) is an OS independent partition that acts as the storage place for the EFI bootloaders, applications and drivers to be launched by the UEFI firmware. It is mandatory for UEFI boot.
This article or section is a candidate for moving to Unified Extensible Firmware Interface#UEFI drivers.
The UEFI specification mandates support for the FAT12, FAT16, and FAT32 file systems (see UEFI specification version 2.8, section 13.3.1.1), but any conformant vendor can optionally add support for additional file systems; for example, the firmware in Apple Macs supports the HFS+ file system.
Contents
Check for an existing partition
If you are installing Arch Linux on an UEFI-capable computer with an installed operating system, like Windows 10 for example, it is very likely that you already have an EFI system partition.
To find out the disk partition scheme and the system partition, use fdisk as root on the disk you want to boot from:
The command returns:
- The disk’s partition table: it indicates Disklabel type: gpt if the partition table is GPT or Disklabel type: dos if it is MBR.
- The list of partitions on the disk: Look for the EFI system partition in the list, it is usually at least 100 MiB in size and has the type EFI System or EFI (FAT-12/16/32) . To confirm this is the ESP, mount it and check whether it contains a directory named EFI , if it does this is definitely the ESP.
If you found an existing EFI system partition, simply proceed to #Mount the partition. If you did not find one, you will need to create it, proceed to #Create the partition.
Create the partition
The following two sections show how to create an EFI system partition (ESP).
To provide adequate space for storing boot loaders and other files required for booting, and to prevent interoperability issues with other operating systems[1][2] the partition should be at least 260 MiB. For early and/or buggy UEFI implementations the size of at least 512 MiB might be needed.[3]
GPT partitioned disks
EFI system partition on a GUID Partition Table is identified by the partition type GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B .
Choose one of the following methods to create an ESP for a GPT partitioned disk:
- fdisk: Create a partition with partition type EFI System .
- gdisk: Create a partition with partition type EF00 .
- GNU Parted: Create a partition with fat32 as the file system type and set the esp flag on it.
Proceed to #Format the partition section below.
MBR partitioned disks
EFI system partition on a Master Boot Record partition table is identified by the partition type ID EF .
Choose one of the following methods to create an ESP for a MBR partitioned disk:
- fdisk: Create a primary partition with partition type EFI (FAT-12/16/32) .
- GNU Parted: Create a primary partition with fat32 as the file system type and set the esp flag on it.
Proceed to #Format the partition section below.
Format the partition
The UEFI specification mandates support for the FAT12, FAT16, and FAT32 file systems[4]. To prevent potential issues with other operating systems and also since the UEFI specification only mandates supporting FAT16 and FAT12 on removable media[5], it is recommended to use FAT32.
After creating the partition, format it as FAT32. To use the mkfs.fat utility, install dosfstools .
If you get the message WARNING: Not enough clusters for a 32 bit FAT! , reduce cluster size with mkfs.fat -s2 -F32 . or -s1 ; otherwise the partition may be unreadable by UEFI. See mkfs.fat(8) for supported cluster sizes.
Mount the partition
The kernels, initramfs files, and, in most cases, the processor’s microcode, need to be accessible by the boot loader or UEFI itself to successfully boot the system. Thus if you want to keep the setup simple, your boot loader choice limits the available mount points for EFI system partition.
Typical mount points
The simplest scenarios for mounting EFI system partition are:
- mount ESP to /efi and use a boot loader which is capable of accessing the kernel(s) and initramfs image(s) that are stored elsewhere (typically /boot). See Arch boot process#Boot loader for more information on boot loader requirements and capabilities.
- mount ESP to /boot . This is the preferred method when directly booting an EFISTUB kernel from UEFI or booting it via a boot manager like systemd-boot.
- mount ESP to /efi and additionally mount an «Extended Boot Loader Partition» (XBOOTLDR) to /boot . This can be useful when a previously created ESP is too small to hold multiple boot loaders and/or kernels but the ESP cannot be easily resized (such as when installing Linux after Windows to dual boot). This method is supported by at least systemd-boot.
Alternative mount points
If you do not use one of the simple methods from #Typical mount points, you will need to copy your boot files to ESP (referred to hereafter as esp ).
Furthermore, you will need to keep the files on the ESP up-to-date with later kernel updates. Failure to do so could result in an unbootable system. The following sections discuss several mechanisms for automating it.
Using bind mount
Instead of mounting the ESP itself to /boot , you can mount a directory of the ESP to /boot using a bind mount (see mount(8) ). This allows pacman to update the kernel directly while keeping the ESP organized to your liking.
Just like in #Alternative mount points, copy all boot files to a directory on your ESP, but mount the ESP outside /boot . Then bind mount the directory:
After verifying success, edit your Fstab to make the changes persistent:
Using systemd
Systemd features event triggered tasks. In this particular case, the ability to detect a change in path is used to sync the EFISTUB kernel and initramfs files when they are updated in /boot/ . The file watched for changes is initramfs-linux-fallback.img since this is the last file built by mkinitcpio, to make sure all files have been built before starting the copy. The systemd path and service files to be created are:
Then enable and start efistub-update.path .
Using filesystem events
Filesystem events can be used to run a script syncing the EFISTUB Kernel after kernel updates. An example with incron follows.
In order to use this method, enable the incrond.service .
Using mkinitcpio hook
Mkinitcpio can generate a hook that does not need a system level daemon to function. It spawns a background process which waits for the generation of vmlinuz , initramfs-linux.img , and initramfs-linux-fallback.img before copying the files.
Add efistub-update to the list of hooks in /etc/mkinitcpio.conf .
Using mkinitcpio preset
As the presets in /etc/mkinitcpio.d/ support shell scripting, the kernel and initramfs can be copied by just editing the presets.
Replacing the above mkinitcpio hook
Edit the file /etc/mkinitcpio.d/linux.preset :
To test that, just run:
Another example
Using pacman hook
A last option relies on the pacman hooks that are run at the end of the transaction.
The first file is a hook that monitors the relevant files, and it is run if they were modified in the former transaction.
The second file is the script itself. Create the file and make it executable:
Troubleshooting
ESP on software RAID1
It is possible to make the ESP part of a RAID1 array, but doing so brings the risk of data corruption, and further considerations need to be taken when creating the ESP. See [8] and [9] for details and UEFI booting and RAID1 for an in-depth guide with a solution.
The key part is to use —metadata 1.0 in order to keep the RAID metadata at the end of the partition, otherwise the firmware will not be able to access it:
Источник