Efibootmgr

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Efibootmgr and the translation is 17% complete.
Outdated translations are marked like this.

efibootmgr è un programma per la gestione delle voci di avvio UEFI

Esso non è un bootloader. E' uno strumento che interagisce con il firmware UEFI del sistema, che a sua volta agisce come un bootloader. Utilizzando efibootmgr le voci di avvio possono essere create, rimescolate, editate e rimosse.

Kernel

CONFIG_EFIVAR_FS support needs to be enabled.

Nota
It is not possible to use efivarfs without the EFI runtime services, which (in case they have been disabled by default, i.e. CONFIG_EFI_DISABLE_RUNTIME=y) can also be enabled by the kernel command-line option efi=runtime.

Emerge

Il pacchetto sys-boot/efibootmgr non ha nessuna USE flags. Quello che è necessario è soltanto installarlo:

root #emerge --ask sys-boot/efibootmgr

Configurazione

Variabili EFI

Per utilizzare con successo efibootmgr, le variabili del filesystem EFI devono essere accessibili. Questo richiede che il sistema sia stato avviato in modalità EFI (e non attraverso la modalità di firmware MBR) altrimenti le variabili EFI non possono essere accessibili. Se il sistema è in modalità MBR, riavviarlo in modalità EFI. Usualmente questo coinvolge o la modifica di un'opzione nelle impostazioni del firmware o la selezione di una voce di avvio EFI nel menu di avvio del sistema.

Quando il sistema è in modalita EFI, eseguire il seguente comando per verificare l'esistenza di efivarfs:

root #mount | grep efivars
efivarfs on /sys/firmware/efi/efivars type efivarfs (ro,relatime)

Viene montato ro tramite lo script init sysfs), quindi deve essere rimontato rw manualmente utilizzando il seguente comando:

root #mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars

Precondizioni

Se una EFI System Partition (ESP) non esiste, bisogna crearne una, vedere EFI System Partition

Utilizzo

Elencare le voci di avvio

Per elencare le voci di avvio correnti utilizzare l'opzione --verbose (-v):

root #efibootmgr -v
BootCurrent: 0002
Timeout: 3 seconds
BootOrder: 0003,0003,0002,0000,0004
Boot0000* CD/DVD Drive  BIOS(3,0,00)
Boot0001* Hard Drive    BIOS(2,0,00)
Boot0002* Gentoo        HD(1,800,61800,6d98f360-cb3e-4727-8fed-5ce0c040365d)File(\EFI\boot\bootx64.efi)
Boot0003* Hard Drive    BIOS(2,0,00)P0: ST1500DM003-9YN16G

Creare una voce di avvio

Per creare una voce di avvio EFI, devono essere passati a efibootmgr un paio di argomenti:

  • --create (-c) per creare una nuova voce;
  • --part (-p) seguito dal numero di partizione nella quale la EFI System Partition è ospitata;
  • --disk (-d) seguito dal disco nel quale la Partizone di Sistema EFI è ospitata;
  • --label (-L) seguito dall'etichetta da utilizzare come voce di avvio;
  • --loader (-l) seguito dal percorso dell'immagine EFI da avviare
Importante
l percorso dell'immagine EFI da avviare deve utilizzare \ (backslash) invece di / (forward slash) come separatore di percorso.
Importante
Additionally, if the ESP was already created by another OS, it might be named differently than /efi/EFI. If an ESP was created by another OS, begin the EFI Boot entry using this directory name, which immediately follows /efi.

Below are some examples of how a UEFI entry can be created. If this is the folder structure:

root #tree /efi/ -L 3
/efi/
└── EFI
    ├── Grub
    │   └── grubx64.efi
    └── Gentoo
        └── bzImage.efi

then the loader paths will be:

root #efibootmgr -c -L "Grub" -l '\EFI\Grub\grubx64.efi'
root #efibootmgr -c -L "Gentoo" -l '\EFI\Gentoo\bzImage.efi'

Per esempio:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l "\efi\boot\bootx64.efi"

It is also possible to add parameters – maybe not supported by all UEFI implementations[1] - to the kernel's command line:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l '\efi\boot\bootx64.efi' -u 'root=/dev/sda3 initrd=\efi\boot\initramfs.img quiet'

Facoltativamente, è possibile installare kernel aggiuntivi e renderli noti al firmware UEFI. Ciò è particolarmente utile quando si desidera testare più kernel o eseguire il dual-boot con un altro sistema operativo. Questi verranno mostrati nel prompt di selezione di avvio, normalmente dopo che un tasto di scelta rapida della tastiera è stato premuto al momento giusto durante l'inizializzazione del sistema. L'ultima voce aggiunta ottiene sempre la massima priorità di avvio, quindi sarà l'impostazione predefinita. Se la combinazione di tasti di scelta rapida è sconosciuta, cerca la documentazione ufficiale del produttore del computer. Queste informazioni di solito non sono difficili da trovare.

Cancellare una voce di avvio

Prima di cancellare una voce, capire qual'è l'ID di tale voce.

Per cancellare una voce di Gentoo come mostrato sopra (che ha Boot0002 come identificatore), chiedere a efibootmgr di cancellare la voce con id 2, passando l'argomento --bootnum (-b) come identificatore, e --delete-bootnum (-B) per cancellare la voce:

root #efibootmgr -b 2 -B

Removable media

EFI bootloaders on removable media are not configured as boot entries, so tools like efibootmgr are not required. Instead the computer firmware identifies removable boot options by looking for a predefined file name unique to the system architecture in use, in a predefined path.[2]

Some (U)EFI implementations support the use of the removable media boot path as a fallback on internal drives.[3] This is against specification and should be avoided, but may help on a system with a buggy (U)EFI. Only one such fallback bootloader is possible on a specific system (i.e. architecture), due to the standardized boot path and file names.

Architecture Abbreviation File name PE executable machine type
x86 32-bit IA-32 \efi\boot\bootia32.efi 0x14c
x86-64 x64 \efi\boot\bootx64.efi 0x8664
Itanium IA-64 \efi\boot\bootia64.efi 0x200
ARM 32-bit AArch32 \efi\boot\bootarm.efi 0x01c2
ARM 64-bit AArch64 \efi\boot\bootaa64.efi 0xAA64
RISC-V 32-bit \efi\boot\bootriscv32.efi 0x5032
RISC-V 64-bit \efi\boot\bootriscv64.efi 0x5064
RISC-V 128-bit \efi\boot\bootriscv128.efi 0x5128
Loongson 32-bit LoongArch32 \efi\boot\bootloongarch32.efi 0x6232
Loongson 64-bit LoongArch64 \efi\boot\bootloongarch64.efi 0x6264
Nota
To boot from removable media, the firmware has to look for compatible bootloaders on supported devices, which can be configured in the firmware setup. Like most firmwares, (U)EFI provides a hotkey to show a boot selection (formally known as "BIOS Boot Selection" or BBS), otherwise (U)EFI will use the configured default boot entry. However, a buggy (U)EFI may default to the removable media boot path even on internal drives.

To use the removable media boot path it is sufficient to copy the EFI bootloader to the required path and file name. Should the firmware make use of this fallback, this may also remove the ability to select between configured boot entries, meaning that boot options (as listed with efibootmgr) through (U)EFI will not work. Even though every EFI bootloader can be used as fallback, it may be advisable to use a boot manager that itself has the ability to select between boot options, such as GRUB. From the above example for x64 (amd64):

root #cp /efi/EFI/Grub/grubx64.efi /efi/EFI/boot/bootx64.efi
Nota
The FAT file system of the EFI System Partition is not case-sensitive, but case-preserving (VFAT), while Unix and Linux is strictly case-sensitive at all times. Because of this, the path /efi/EFI/boot/bootx64.efi may not work on all systems, as it could be using capital letters, e.g. /efi/EFI/BOOT or /efi/EFI/Boot; the same goes for bootx64.efi. Running tree -L 3 /efi, when the ESP is mounted under /efi, will show the names in use on the individual system, to which the above command has to be changed accordingly.
Importante
The fallback bootloader is not automatically updated! Every time e.g. GRUB is re-installed (like after a version update, which may contain security fixes), it has to be copied to the fallback boot path again, overwriting (updating) the previous version!

The boot manager included in systemd, systemd-boot (formally Gummiboot), will automatically install to the removable media boot path. When sys-apps/systemd with the boot USE flag is updated, it is necessary to run bootctl again in order to update both bootloader files.

root #bootctl update

Rimozione

Unmerge

root #emerge --ask --depclean --verbose sys-boot/efibootmgr

Vedere anche

  • rEFInd — a boot manager for EFI and UEFI platforms forked from and successor to rEFIt.
  • EFI stub kernel spiega come configurare il kernel Linux per abilitarlo ad esser avviato direttamente da EFI
  • Alternative 2: efibootmgr nell'Handbook di Gentoo

References