]> git.proxmox.com Git - pve-docs.git/blame - system-booting.adoc
cert management: move some headings a level up for better visibility
[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
69055103 15[[sysboot_installer_part_scheme]]
62de1c14
SI
16Partitioning scheme used by the installer
17~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18
19The {pve} installer creates 3 partitions on the bootable disks selected for
20installation. The bootable disks are:
21
22* For Installations with `ext4` or `xfs` the selected disk
23
24* For ZFS installations all disks belonging to the first `vdev`:
25** The first disk for RAID0
26** All disks for RAID1, RAIDZ1, RAIDZ2, RAIDZ3
27** The first two disks for RAID10
28
29The created partitions are:
30
31* a 1 MB BIOS Boot Partition (gdisk type EF02)
32
33* a 512 MB EFI System Partition (ESP, gdisk type EF00)
34
35* a third partition spanning the set `hdsize` parameter or the remaining space
36 used for the chosen storage type
37
38`grub` in BIOS mode (`--target i386-pc`) is installed onto the BIOS Boot
39Partition of all bootable disks for supporting older systems.
40
41
69055103 42[[sysboot_grub]]
62de1c14
SI
43Grub
44~~~~
45
46`grub` has been the de-facto standard for booting Linux systems for many years
47and is quite well documented
48footnote:[Grub Manual https://www.gnu.org/software/grub/manual/grub/grub.html].
49
50The kernel and initrd images are taken from `/boot` and its configuration file
51`/boot/grub/grub.cfg` gets updated by the kernel installation process.
52
53Configuration
54^^^^^^^^^^^^^
55Changes to the `grub` configuration are done via the defaults file
56`/etc/default/grub` or config snippets in `/etc/default/grub.d`. To regenerate
57the `/boot/grub/grub.cfg` after a change to the configuration run:
58
59----
60`update-grub`.
61----
62
69055103 63[[sysboot_systemd_boot]]
62de1c14
SI
64Systemd-boot
65~~~~~~~~~~~~
66
67`systemd-boot` is a lightweight EFI bootloader. It reads the kernel and initrd
68images directly from the EFI Service Partition (ESP) where it is installed.
69The main advantage of directly loading the kernel from the ESP is that it does
70not need to reimplement the drivers for accessing the storage. In the context
71of ZFS as root filesystem this means that you can use all optional features on
72your root pool instead of the subset which is also present in the ZFS
73implementation in `grub` or having to create a separate small boot-pool
74footnote:[Booting ZFS on root with grub https://github.com/zfsonlinux/zfs/wiki/Debian-Stretch-Root-on-ZFS].
75
76In setups with redundancy (RAID1, RAID10, RAIDZ*) all bootable disks (those
77being part of the first `vdev`) are partitioned with an ESP. This ensures the
78system boots even if the first boot device fails. The ESPs are kept in sync by
79a kernel postinstall hook script `/etc/kernel/postinst.d/zz-pve-efiboot`. The
80script copies certain kernel versions and the initrd images to `EFI/proxmox/`
81on the root of each ESP and creates the appropriate config files in
300655b3
FG
82`loader/entries/proxmox-*.conf`. The `pve-efiboot-tool` script assists in
83managing both the synced ESPs themselves and their contents.
62de1c14
SI
84
85The following kernel versions are configured by default:
86
87* the currently running kernel
88* the version being newly installed on package updates
8152d9b6
FG
89* the two latest already installed kernels
90* the latest version of the second-to-last kernel series (e.g. 4.15, 5.0), if applicable
91* any manually selected kernels (see below)
62de1c14
SI
92
93The ESPs are not kept mounted during regular operation, in contrast to `grub`,
94which keeps an ESP mounted on `/boot/efi`. This helps to prevent filesystem
95corruption to the `vfat` formatted ESPs in case of a system crash, and removes
96the need to manually adapt `/etc/fstab` in case the primary boot device fails.
97
69055103 98[[sysboot_systemd_boot_config]]
62de1c14
SI
99Configuration
100^^^^^^^^^^^^^
101
102`systemd-boot` is configured via the file `loader/loader.conf` in the root
103directory of an EFI System Partition (ESP). See the `loader.conf(5)` manpage
104for details.
105
106Each bootloader entry is placed in a file of its own in the directory
107`loader/entries/`
108
109An example entry.conf looks like this (`/` refers to the root of the ESP):
110
111----
112title Proxmox
113version 5.0.15-1-pve
114options root=ZFS=rpool/ROOT/pve-1 boot=zfs
115linux /EFI/proxmox/5.0.15-1-pve/vmlinuz-5.0.15-1-pve
116initrd /EFI/proxmox/5.0.15-1-pve/initrd.img-5.0.15-1-pve
117----
118
119
120.Manually keeping a kernel bootable
121
122Should you wish to add a certain kernel and initrd image to the list of
f11fb629 123bootable kernels use `pve-efiboot-tool kernel add`.
62de1c14 124
1722c45b
FG
125For example run the following to add the kernel with ABI version `5.0.15-1-pve`
126to the list of kernels to keep installed and synced to all ESPs:
62de1c14 127
1722c45b
FG
128----
129pve-efiboot-tool kernel add 5.0.15-1-pve
130----
131
132`pve-efiboot-tool kernel list` will list all kernel versions currently selected
133for booting:
134
135----
136# pve-efiboot-tool kernel list
137Manually selected kernels:
1385.0.15-1-pve
139
140Automatically selected kernels:
1415.0.12-1-pve
1424.15.18-18-pve
143----
62de1c14 144
1722c45b
FG
145Run `pve-efiboot-tool remove` to remove a kernel from the list of manually
146selected kernels, for example:
62de1c14
SI
147
148----
1722c45b 149pve-efiboot-tool kernel remove 5.0.15-1-pve
62de1c14
SI
150----
151
b74373e4
TL
152NOTE: It's required to run `pve-efiboot-tool refresh` to update all EFI System
153Partitions (ESPs) after a manual kernel addition or removal from above.
1722c45b 154
0daaddbd
FG
155[[sysboot_systemd_boot_setup]]
156.Setting up a new partition for use as synced ESP
157
158To format and initialize a partition as synced ESP, e.g., after replacing a
159failed vdev in an rpool, or when converting an existing system that pre-dates
160the sync mechanism, `pve-efiboot-tool` from `pve-kernel-helpers` can be used.
161
162WARNING: the `format` command will format the `<partition>`, make sure to pass
163in the right device/partition!
164
165For example, to format an empty partition `/dev/sda2` as ESP, run the following:
166
167----
168pve-efiboot-tool format /dev/sda2
169----
170
171To setup an existing, unmounted ESP located on `/dev/sda2` for inclusion in
3fe127c7 172{pve}'s kernel update synchronization mechanism, use the following:
0daaddbd
FG
173
174----
175pve-efiboot-tool init /dev/sda2
176----
177
178Afterwards `/etc/kernel/pve-efiboot-uuids` should contain a new line with the
179UUID of the newly added partition. The `init` command will also automatically
180trigger a refresh of all configured ESPs.
62de1c14 181
69055103 182[[sysboot_systemd_boot_refresh]]
62de1c14
SI
183.Updating the configuration on all ESPs
184
0daaddbd 185To copy and configure all bootable kernels and keep all ESPs listed in
b74373e4
TL
186`/etc/kernel/pve-efiboot-uuids` in sync you just need to run:
187
188----
189 pve-efiboot-tool refresh
190----
f11fb629 191(The equivalent to running `update-grub` on systems being booted with `grub`).
62de1c14 192
0daaddbd 193This is necessary should you make changes to the kernel commandline, or want to
0aebb0d9
SR
194sync all kernels and initrds.
195
196NOTE: Both `update-initramfs` and `apt` (when necessary) will automatically
197trigger a refresh.
62de1c14 198
69055103 199[[sysboot_edit_kernel_cmdline]]
62de1c14
SI
200Editing the kernel commandline
201~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202
203You can modify the kernel commandline in the following places, depending on the
f11fb629 204bootloader used:
62de1c14
SI
205
206.Grub
207
208The kernel commandline needs to be placed in the variable
209`GRUB_CMDLINE_LINUX_DEFAULT` in the file `/etc/default/grub`. Running
210`update-grub` appends its content to all `linux` entries in
211`/boot/grub/grub.cfg`.
212
213.Systemd-boot
214
0aebb0d9 215The kernel commandline needs to be placed as one line in `/etc/kernel/cmdline`.
ab2bc36e 216To apply your changes, run `pve-efiboot-tool refresh`, which sets it as the
0aebb0d9 217`option` line for all config files in `loader/entries/proxmox-*.conf`.