]>
Commit | Line | Data |
---|---|---|
1 | [[sysboot]] | |
2 | Host Bootloader | |
3 | --------------- | |
4 | ifdef::wiki[] | |
5 | :pve-toplevel: | |
6 | endif::wiki[] | |
7 | ||
8 | {pve} currently uses one of two bootloaders depending on the disk setup | |
9 | selected in the installer. | |
10 | ||
11 | For EFI Systems installed with ZFS as the root filesystem `systemd-boot` is | |
12 | used. All other deployments use the standard `grub` bootloader (this usually | |
13 | also applies to systems which are installed on top of Debian). | |
14 | ||
15 | [[sysboot_determine_bootloader_used]] | |
16 | Determine which bootloader is used | |
17 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
18 | ||
19 | [thumbnail="screenshot/boot-grub.png", float="left"] | |
20 | ||
21 | The simplest and most reliable way to determine which bootloader is used, is to | |
22 | watch the boot process of the {pve} node. | |
23 | ||
24 | You will either see the blue box of `grub` or the simple black on white | |
25 | `systemd-boot`. | |
26 | ||
27 | [thumbnail="screenshot/boot-systemdboot.png"] | |
28 | ||
29 | Determining the bootloader from a running system might not be 100% accurate. The | |
30 | safest way is to run the following command: | |
31 | ||
32 | ||
33 | ---- | |
34 | # efibootmgr -v | |
35 | ---- | |
36 | ||
37 | If it returns a message that EFI variables are not supported, `grub` is used in | |
38 | BIOS/Legacy mode. | |
39 | ||
40 | If the output contains a line that looks similar to the following, `grub` is | |
41 | used in UEFI mode. | |
42 | ||
43 | ---- | |
44 | Boot0005* proxmox [...] File(\EFI\proxmox\grubx64.efi) | |
45 | ---- | |
46 | ||
47 | If the output contains a line similar to the following, `systemd-bood` is used. | |
48 | ||
49 | ---- | |
50 | Boot0006* Linux Boot Manager [...] File(\EFI\systemd\systemd-bootx64.efi) | |
51 | ---- | |
52 | ||
53 | ||
54 | [[sysboot_installer_part_scheme]] | |
55 | Partitioning scheme used by the installer | |
56 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
57 | ||
58 | The {pve} installer creates 3 partitions on the bootable disks selected for | |
59 | installation. The bootable disks are: | |
60 | ||
61 | * For Installations with `ext4` or `xfs` the selected disk | |
62 | ||
63 | * For ZFS installations all disks belonging to the first `vdev`: | |
64 | ** The first disk for RAID0 | |
65 | ** All disks for RAID1, RAIDZ1, RAIDZ2, RAIDZ3 | |
66 | ** The first two disks for RAID10 | |
67 | ||
68 | The created partitions are: | |
69 | ||
70 | * a 1 MB BIOS Boot Partition (gdisk type EF02) | |
71 | ||
72 | * a 512 MB EFI System Partition (ESP, gdisk type EF00) | |
73 | ||
74 | * a third partition spanning the set `hdsize` parameter or the remaining space | |
75 | used for the chosen storage type | |
76 | ||
77 | `grub` in BIOS mode (`--target i386-pc`) is installed onto the BIOS Boot | |
78 | Partition of all bootable disks for supporting older systems. | |
79 | ||
80 | ||
81 | [[sysboot_grub]] | |
82 | Grub | |
83 | ~~~~ | |
84 | ||
85 | `grub` has been the de-facto standard for booting Linux systems for many years | |
86 | and is quite well documented | |
87 | footnote:[Grub Manual https://www.gnu.org/software/grub/manual/grub/grub.html]. | |
88 | ||
89 | The kernel and initrd images are taken from `/boot` and its configuration file | |
90 | `/boot/grub/grub.cfg` gets updated by the kernel installation process. | |
91 | ||
92 | Configuration | |
93 | ^^^^^^^^^^^^^ | |
94 | Changes to the `grub` configuration are done via the defaults file | |
95 | `/etc/default/grub` or config snippets in `/etc/default/grub.d`. To regenerate | |
96 | the `/boot/grub/grub.cfg` after a change to the configuration run: | |
97 | ||
98 | ---- | |
99 | `update-grub`. | |
100 | ---- | |
101 | ||
102 | [[sysboot_systemd_boot]] | |
103 | Systemd-boot | |
104 | ~~~~~~~~~~~~ | |
105 | ||
106 | `systemd-boot` is a lightweight EFI bootloader. It reads the kernel and initrd | |
107 | images directly from the EFI Service Partition (ESP) where it is installed. | |
108 | The main advantage of directly loading the kernel from the ESP is that it does | |
109 | not need to reimplement the drivers for accessing the storage. In the context | |
110 | of ZFS as root filesystem this means that you can use all optional features on | |
111 | your root pool instead of the subset which is also present in the ZFS | |
112 | implementation in `grub` or having to create a separate small boot-pool | |
113 | footnote:[Booting ZFS on root with grub https://github.com/zfsonlinux/zfs/wiki/Debian-Stretch-Root-on-ZFS]. | |
114 | ||
115 | In setups with redundancy (RAID1, RAID10, RAIDZ*) all bootable disks (those | |
116 | being part of the first `vdev`) are partitioned with an ESP. This ensures the | |
117 | system boots even if the first boot device fails. The ESPs are kept in sync by | |
118 | a kernel postinstall hook script `/etc/kernel/postinst.d/zz-pve-efiboot`. The | |
119 | script copies certain kernel versions and the initrd images to `EFI/proxmox/` | |
120 | on the root of each ESP and creates the appropriate config files in | |
121 | `loader/entries/proxmox-*.conf`. The `pve-efiboot-tool` script assists in | |
122 | managing both the synced ESPs themselves and their contents. | |
123 | ||
124 | The following kernel versions are configured by default: | |
125 | ||
126 | * the currently running kernel | |
127 | * the version being newly installed on package updates | |
128 | * the two latest already installed kernels | |
129 | * the latest version of the second-to-last kernel series (e.g. 4.15, 5.0), if applicable | |
130 | * any manually selected kernels (see below) | |
131 | ||
132 | The ESPs are not kept mounted during regular operation, in contrast to `grub`, | |
133 | which keeps an ESP mounted on `/boot/efi`. This helps to prevent filesystem | |
134 | corruption to the `vfat` formatted ESPs in case of a system crash, and removes | |
135 | the need to manually adapt `/etc/fstab` in case the primary boot device fails. | |
136 | ||
137 | [[sysboot_systemd_boot_config]] | |
138 | Configuration | |
139 | ^^^^^^^^^^^^^ | |
140 | ||
141 | `systemd-boot` is configured via the file `loader/loader.conf` in the root | |
142 | directory of an EFI System Partition (ESP). See the `loader.conf(5)` manpage | |
143 | for details. | |
144 | ||
145 | Each bootloader entry is placed in a file of its own in the directory | |
146 | `loader/entries/` | |
147 | ||
148 | An example entry.conf looks like this (`/` refers to the root of the ESP): | |
149 | ||
150 | ---- | |
151 | title Proxmox | |
152 | version 5.0.15-1-pve | |
153 | options root=ZFS=rpool/ROOT/pve-1 boot=zfs | |
154 | linux /EFI/proxmox/5.0.15-1-pve/vmlinuz-5.0.15-1-pve | |
155 | initrd /EFI/proxmox/5.0.15-1-pve/initrd.img-5.0.15-1-pve | |
156 | ---- | |
157 | ||
158 | ||
159 | .Manually keeping a kernel bootable | |
160 | ||
161 | Should you wish to add a certain kernel and initrd image to the list of | |
162 | bootable kernels use `pve-efiboot-tool kernel add`. | |
163 | ||
164 | For example run the following to add the kernel with ABI version `5.0.15-1-pve` | |
165 | to the list of kernels to keep installed and synced to all ESPs: | |
166 | ||
167 | ---- | |
168 | pve-efiboot-tool kernel add 5.0.15-1-pve | |
169 | ---- | |
170 | ||
171 | `pve-efiboot-tool kernel list` will list all kernel versions currently selected | |
172 | for booting: | |
173 | ||
174 | ---- | |
175 | # pve-efiboot-tool kernel list | |
176 | Manually selected kernels: | |
177 | 5.0.15-1-pve | |
178 | ||
179 | Automatically selected kernels: | |
180 | 5.0.12-1-pve | |
181 | 4.15.18-18-pve | |
182 | ---- | |
183 | ||
184 | Run `pve-efiboot-tool remove` to remove a kernel from the list of manually | |
185 | selected kernels, for example: | |
186 | ||
187 | ---- | |
188 | pve-efiboot-tool kernel remove 5.0.15-1-pve | |
189 | ---- | |
190 | ||
191 | NOTE: It's required to run `pve-efiboot-tool refresh` to update all EFI System | |
192 | Partitions (ESPs) after a manual kernel addition or removal from above. | |
193 | ||
194 | [[sysboot_systemd_boot_setup]] | |
195 | .Setting up a new partition for use as synced ESP | |
196 | ||
197 | To format and initialize a partition as synced ESP, e.g., after replacing a | |
198 | failed vdev in an rpool, or when converting an existing system that pre-dates | |
199 | the sync mechanism, `pve-efiboot-tool` from `pve-kernel-helpers` can be used. | |
200 | ||
201 | WARNING: the `format` command will format the `<partition>`, make sure to pass | |
202 | in the right device/partition! | |
203 | ||
204 | For example, to format an empty partition `/dev/sda2` as ESP, run the following: | |
205 | ||
206 | ---- | |
207 | pve-efiboot-tool format /dev/sda2 | |
208 | ---- | |
209 | ||
210 | To setup an existing, unmounted ESP located on `/dev/sda2` for inclusion in | |
211 | {pve}'s kernel update synchronization mechanism, use the following: | |
212 | ||
213 | ---- | |
214 | pve-efiboot-tool init /dev/sda2 | |
215 | ---- | |
216 | ||
217 | Afterwards `/etc/kernel/pve-efiboot-uuids` should contain a new line with the | |
218 | UUID of the newly added partition. The `init` command will also automatically | |
219 | trigger a refresh of all configured ESPs. | |
220 | ||
221 | [[sysboot_systemd_boot_refresh]] | |
222 | .Updating the configuration on all ESPs | |
223 | ||
224 | To copy and configure all bootable kernels and keep all ESPs listed in | |
225 | `/etc/kernel/pve-efiboot-uuids` in sync you just need to run: | |
226 | ||
227 | ---- | |
228 | pve-efiboot-tool refresh | |
229 | ---- | |
230 | (The equivalent to running `update-grub` on systems being booted with `grub`). | |
231 | ||
232 | This is necessary should you make changes to the kernel commandline, or want to | |
233 | sync all kernels and initrds. | |
234 | ||
235 | NOTE: Both `update-initramfs` and `apt` (when necessary) will automatically | |
236 | trigger a refresh. | |
237 | ||
238 | [[sysboot_edit_kernel_cmdline]] | |
239 | Editing the kernel commandline | |
240 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
241 | ||
242 | You can modify the kernel commandline in the following places, depending on the | |
243 | bootloader used: | |
244 | ||
245 | .Grub | |
246 | ||
247 | The kernel commandline needs to be placed in the variable | |
248 | `GRUB_CMDLINE_LINUX_DEFAULT` in the file `/etc/default/grub`. Running | |
249 | `update-grub` appends its content to all `linux` entries in | |
250 | `/boot/grub/grub.cfg`. | |
251 | ||
252 | .Systemd-boot | |
253 | ||
254 | The kernel commandline needs to be placed as one line in `/etc/kernel/cmdline`. | |
255 | To apply your changes, run `pve-efiboot-tool refresh`, which sets it as the | |
256 | `option` line for all config files in `loader/entries/proxmox-*.conf`. |