]> git.proxmox.com Git - pve-docs.git/blame - system-booting.adoc
Add documentation on bootloaders (systemd-boot)
[pve-docs.git] / system-booting.adoc
CommitLineData
62de1c14
SI
1[[system_booting]]
2Bootloaders
3-----------
4ifdef::wiki[]
5:pve-toplevel:
6endif::wiki[]
7
8{pve} uses one of two bootloaders depending on the disk setup selected in the
9installer.
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
15[[installer_partitioning_scheme]]
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
42Grub
43~~~~
44
45`grub` has been the de-facto standard for booting Linux systems for many years
46and is quite well documented
47footnote:[Grub Manual https://www.gnu.org/software/grub/manual/grub/grub.html].
48
49The kernel and initrd images are taken from `/boot` and its configuration file
50`/boot/grub/grub.cfg` gets updated by the kernel installation process.
51
52Configuration
53^^^^^^^^^^^^^
54Changes to the `grub` configuration are done via the defaults file
55`/etc/default/grub` or config snippets in `/etc/default/grub.d`. To regenerate
56the `/boot/grub/grub.cfg` after a change to the configuration run:
57
58----
59`update-grub`.
60----
61
62Systemd-boot
63~~~~~~~~~~~~
64
65`systemd-boot` is a lightweight EFI bootloader. It reads the kernel and initrd
66images directly from the EFI Service Partition (ESP) where it is installed.
67The main advantage of directly loading the kernel from the ESP is that it does
68not need to reimplement the drivers for accessing the storage. In the context
69of ZFS as root filesystem this means that you can use all optional features on
70your root pool instead of the subset which is also present in the ZFS
71implementation in `grub` or having to create a separate small boot-pool
72footnote:[Booting ZFS on root with grub https://github.com/zfsonlinux/zfs/wiki/Debian-Stretch-Root-on-ZFS].
73
74In setups with redundancy (RAID1, RAID10, RAIDZ*) all bootable disks (those
75being part of the first `vdev`) are partitioned with an ESP. This ensures the
76system boots even if the first boot device fails. The ESPs are kept in sync by
77a kernel postinstall hook script `/etc/kernel/postinst.d/zz-pve-efiboot`. The
78script copies certain kernel versions and the initrd images to `EFI/proxmox/`
79on the root of each ESP and creates the appropriate config files in
80`loader/entries/proxmox-*.conf`.
81
82The following kernel versions are configured by default:
83
84* the currently running kernel
85* the version being newly installed on package updates
86* the two latest kernels
87* the latest version of each kernel series (e.g. 4.15, 5.0).
88
89The ESPs are not kept mounted during regular operation, in contrast to `grub`,
90which keeps an ESP mounted on `/boot/efi`. This helps to prevent filesystem
91corruption to the `vfat` formatted ESPs in case of a system crash, and removes
92the need to manually adapt `/etc/fstab` in case the primary boot device fails.
93
94[[systemd_boot_config]]
95Configuration
96^^^^^^^^^^^^^
97
98`systemd-boot` is configured via the file `loader/loader.conf` in the root
99directory of an EFI System Partition (ESP). See the `loader.conf(5)` manpage
100for details.
101
102Each bootloader entry is placed in a file of its own in the directory
103`loader/entries/`
104
105An example entry.conf looks like this (`/` refers to the root of the ESP):
106
107----
108title Proxmox
109version 5.0.15-1-pve
110options root=ZFS=rpool/ROOT/pve-1 boot=zfs
111linux /EFI/proxmox/5.0.15-1-pve/vmlinuz-5.0.15-1-pve
112initrd /EFI/proxmox/5.0.15-1-pve/initrd.img-5.0.15-1-pve
113----
114
115
116.Manually keeping a kernel bootable
117
118Should you wish to add a certain kernel and initrd image to the list of
119bootable kernels you need to:
120
121* create a directory on the ESP (e.g. `/EFI/personalkernel`)
122* copy the kernel and initrd image to that directory
123* create a entry for this kernel in `/loader/entries/*.conf`
124
125NOTE: do not use `/EFI/proxmox` as directory since all entries there can be
126removed by `/etc/kernel/postinst.d/zz-pve-efiboot`
127
128Example (keeping kernel 5.0.15-1-pve and copying to an ESP mounted on
129`/mnt/esp`):
130
131----
132mkdir /mnt/esp/EFI/preferred-kernel
133cp /boot/initrd.img-5.0.15-1-pve /boot/vmlinuz-5.0.15-1-pve /mnt/esp/EFI/preferred-kernel
134echo -n "title Preferred Kernel
135version 5.0.15-1-pve
136linux /mnt/esp/EFI/preferred-kernel/vmlinuz-5.0.15-1-pve
137initrd /mnt/esp/EFI/preferred-kernel/initrd.img-5.0.15-1-pve
138options " > /mnt/esp/loader/entries/preferred.conf
139cat /etc/kernel/cmdline >> /mnt/esp/loader/entries/preferred.conf
140----
141
142
143[[systemd-boot-refresh]]
144.Updating the configuration on all ESPs
145
146To copy and configure all bootable kernels and keep all ESPs in sync you just
147need to run the kernel hook script `/etc/kernel/postinst.d/zz-pve-efiboot`.
148(The equivalent to running `update-grub` on Systems being booted with `grub`).
149
150This is necessary should you make changes to the kernel commandline, or if you
151want to add another ESP (e.g. when replacing a failed disk in a redundant ZFS
152pool).
153
154[[edit_kernel_cmdline]]
155Editing the kernel commandline
156~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157
158You can modify the kernel commandline in the following places, depending on the
159bootloarder used:
160
161.Grub
162
163The kernel commandline needs to be placed in the variable
164`GRUB_CMDLINE_LINUX_DEFAULT` in the file `/etc/default/grub`. Running
165`update-grub` appends its content to all `linux` entries in
166`/boot/grub/grub.cfg`.
167
168.Systemd-boot
169
170The kernel commandline needs to be placed as line in `/etc/kernel/cmdline`
171Running `/etc/kernel/postinst.d/zz-pve-efiboot` sets it as `option` line for
172all config files in `loader/entries/proxmox-*.conf`.
173
174