File: USAGE.md

package info (click to toggle)
efibootguard 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 796 kB
  • sloc: ansic: 7,805; makefile: 405; python: 326; sh: 84
file content (171 lines) | stat: -rw-r--r-- 4,473 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Installation AND Usage #

In order to use `efibootguard` one needs to
* have a valid disk partitioning scheme
* have the bootloader binary installed in the proper place
* have valid configuration files
* configure the UEFI boot sequence (may be optional)

## Creating a valid partitioning scheme ##

UEFI by default supports FAT file systems, which are used to store
configuration data for `efibootguard`. The following partition type GUIDS are
supported for GPT partition entries:

GUID                                 | description
-------------------------------------|----------------------------------
EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 | Microsoft default data partition
C12A7328-F81F-11D2-BA4B-00A0C93EC93B | EFI System partition

For robustness of the fail-safe mechanism, each configuration file revision is
stored into a separate FAT partition. The following example shows how to create a
new GPT using `parted`:

**IMPORTANT**: Replace `/dev/sdX` with the correct block device.

* Start `parted` for block device `/dev/sdX` and create an EFI system partition

```
# parted /dev/sdX
(parted) mklabel GPT
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? fat32
Start? 0%
End? 20%
(parted) toggle 1
Flag to Invert? ESP
```

* Create two config partitions

```
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? fat16
Start? 20%
End? 40%
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? fat16
Start? 40%
End? 60%
```

* Create two root partitions and leave `parted`

```
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? ext4
Start? 60%
End? 80%
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? ext4
Start? 80%
End? 100%
(parted) q
```

* Create all file systems

```
# mkfs.fat /dev/sdX1
# mkfs.fat -F 16 /dev/sdX2
# mkfs.fat -F 16 /dev/sdX3
# mkfs.ext4 /dev/sdX4
# mkfs.ext4 /dev/sdX5
```

*NOTE*: `FAT16`, as specified by `-F 16` is usefull for smaller partitions
(i.e. 500 MB). `FAT12` and `FAT32` is also supported.

## Install the boot loader binary file ##

This example is for an `x64` architecture.

```
# mount /dev/sdX1 /mnt
# mkdir -p /mnt/EFI/boot
# cp efibootguardx64.efi /mnt/EFI/boot/bootx64.efi
# umount /mnt
```

## Create a default configuration ##

This step first creates a custom label contained in `EFILABEL`, which is later
used to specify the kernel location.

```
# mount /dev/sdX2 /mnt
# echo -n "KERNEL1" | iconv -f ascii -t UTF-16LE > /mnt/EFILABEL
# bg_setenv -f /mnt -r 1 --kernel="C:KERNEL1:vmlinuz-linux" --args="root=/dev/sdX4 noinitrd"
# umount /mnt
# mount /dev/sdX3 /mnt
# echo -n "KERNEL2" | iconv -f ascii -t UTF-16LE > /mnt/EFILABEL
# bg_setenv -f /mnt -r 2 --kernel="C:KERNEL2:vmlinuz-linux" --args="root=/dev/sdX5 noinitrd"
# umount /mnt
```

## Configuring UEFI boot sequence (Optional) ##

UEFI compliant firmwares fall back to a standard search path for the boot loader binary. This is

```
/EFI/BOOT/BOOT<arch>.EFI
```

In some cases, if the system does not select the correct `bootx64.efi` for
booting automatically, use the `efibootmgr` user space tool to setup the boot
sequence configuration.

Another possibility is to boot into `UEFI shell` and use the `bcfg` command.

Issue the following command to list the currently configured boot sequence:

```
bcfg boot dump
```

The following command deletes item number `n`:

```
bcfg boot rm `n`
```

The following command create an entry for `bootx64.efi`:

```
bcfg boot add 0 fs0:\efi\boot\bootx64.efi "efi boot guard"
```

where the binary is on drive `fs0:`.

Exit `UEFI shell` with the `reset` command.

## Kernel Location ##

If you just specify a file name as `--kernelfile`, `efibootguard` loads the
kernel from the same FAT partition as the boot loader binary itself.

To load the kernel from a different FAT partition than `efibootguard`, there are
two possible mechanisms. One directly uses the label of the FAT partition,
created with `dosfslabel`:

```
./bg_setenv -u --kernel="L:FATLABEL:kernelfile"
```

where `FATLABEL` is the label of the FAT partition. On some older UEFI
implementations, the label is not supported properly and a user defined label
can be created instead, which is a file named `EFILABEL` in the root directory
of the corresponding FAT partition. This file contains an UTF-16le encoded
partition name and can be used as follows:

```
./bg_setenv -u --kernel="C:USERLABEL:kernelfile"
```

*NOTE*: Do not mix-up the file system label and the GPT entry label.