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