Skip to content

Commit 0979051

Browse files
zdykstraahesfordericonr
committed
Add documentation for generate-zbm, its config and initramfs options
Master documents reside in the `pod` subdirectory (except for `generate-zbm.8`, which is inlined in `bin/generate-zbm` and may be converted to man pages by running, from the repository root, the helper `releng/pod2man.sh`. The `releng/tag-release.sh` helper will convert the docs as part of the release process. Co-authored-by: Zach Dykstra <[email protected]> Co-authored-by: Andrew J. Hesford <[email protected]> Co-authored-by: Érico Rolim <[email protected]>
1 parent ee1d9d8 commit 0979051

File tree

9 files changed

+1026
-98
lines changed

9 files changed

+1026
-98
lines changed

README.md

Lines changed: 15 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
zfsbootmenu is implemented as a Dracut module to provide an experience similar to FreeBSD's bootloader, for Linux distributions. In broad strokes, it works as follows:
88

9-
* Via GRUB, direct EFI booting, etc, boot a Linux kernel along with an initramfs containing ZFS Boot Menu
9+
* Via GRUB, direct EFI booting, etc, boot a Linux kernel along with an initramfs containing ZFSBootMenu
1010
* Look for `zfsbootmenu` on the kernel command line
1111
* Optionally specify a default pool (if multiple are present)
1212
* Find all healthy pools and then import them
@@ -30,7 +30,7 @@ This tool makes uses of the following additional software:
3030
* [Linux Kernel](https://www.kernel.org)
3131
* [ZFS on Linux](https://zfsonlinux.org)
3232
* [dracut](https://github.com/dracutdevs/dracut)
33-
33+
3434
ZFSBootMenu has been tested successfully with Kernel 5.7.13, Dracut 050 and ZFS On Linux 0.8.4.
3535

3636
# System prereqs
@@ -53,7 +53,7 @@ NAME PROPERTY VALUE SOURCE
5353
zroot bootfs zroot/ROOT/void.2019.11.01 local
5454
```
5555

56-
On start, ZFS Boot Menu will find the highest versioned kernel in `zroot/ROOT/void.2019.11.01/boot`, confirm that a matching initramfs is present, and default to booting the OS with that.
56+
On start, ZFSBootMenu will find the highest versioned kernel in `zroot/ROOT/void.2019.11.01/boot`, confirm that a matching initramfs is present, and default to booting the OS with that.
5757

5858
# Installation
5959

@@ -69,7 +69,7 @@ Because ZFS properties are inherited by default, it is possible to set the `org.
6969

7070
## EFI
7171

72-
ZFS Boot Menu integrates nicely with an EFI system. There will be two key things to configure here.
72+
ZFSBootMenu integrates nicely with an EFI system. There will be two key things to configure here.
7373

7474
* The mountpoint of the EFI partition and it's contents
7575
* The mountpoint of the boot environment `/boot` and it's contents
@@ -90,7 +90,7 @@ vmlinuz-5.4.6_1
9090
```
9191

9292

93-
Once `/boot` is backed by ZFS in a boot environment, you'll need to install the boot menu files. Typically, EFI partitions are mounted to `/boot/efi`, and contain a number of sub-directories. In this example, `/boot/efi/EFI/void` holds the ZFS Boot Menu kernel and initramfs.
93+
Once `/boot` is backed by ZFS in a boot environment, you'll need to install the boot menu files. Typically, EFI partitions are mounted to `/boot/efi`, and contain a number of sub-directories. In this example, `/boot/efi/EFI/void` holds the ZFSBootMenu kernel and initramfs.
9494

9595
```
9696
# lsblk -f /dev/sda
@@ -122,7 +122,7 @@ If you are using a pre-built kernel and initramfs downloaded from the releases p
122122
efibootmgr --disk /dev/sda \
123123
--part 1 \
124124
--create \
125-
--label "ZFS Boot Menu" \
125+
--label "ZFSBootMenu" \
126126
--loader /vmlinuz-0.7.5 \
127127
--unicode 'root=zfsbootmenu:POOL=zroot ro initrd=\EFI\void\initramfs-0.7.5.img quiet spl_hostid=a8c0a2a8' \
128128
--verbose
@@ -134,7 +134,7 @@ Each time the bootmenu is updated, a new EFI entry will need to be manually adde
134134

135135
### rEFInd
136136

137-
`rEFInd` is considerably easier to install and manage. Refer to your distributions packages for installation. Once rEFInd has been installed, you can create `refind_linux.conf` in the directory holding the ZFS Boot Menu files (`/boot/efi/EFI/void` in our example):
137+
`rEFInd` is considerably easier to install and manage. Refer to your distributions packages for installation. Once rEFInd has been installed, you can create `refind_linux.conf` in the directory holding the ZFSBootMenu files (`/boot/efi/EFI/void` in our example):
138138

139139
```
140140
"Boot Default BE" "ro quiet loglevel=0 timeout=0 zfsbootmenu:POOL= spl_hostid="
@@ -144,32 +144,15 @@ Each time the bootmenu is updated, a new EFI entry will need to be manually adde
144144

145145
As with the efibootmgr section, the `zfsbootmenu:POOL=` and `spl_hostid=` options need to be configured to match your environment.
146146

147-
This file will configure `rEFInd` to create two entries for each kernel and initrams pair it finds. The first will directly boot into the environment set via the `bootfs` pool property. The second will force ZFS Boot Menu to display an environment / kernel / snapshot selection menu, allowing you to boot alternate environments, kernels and snapshots.
148-
149-
# Command line options
147+
This file will configure `rEFInd` to create two entries for each kernel and initrams pair it finds. The first will directly boot into the environment set via the `bootfs` pool property. The second will force ZFSBootMenu to display an environment / kernel / snapshot selection menu, allowing you to boot alternate environments, kernels and snapshots.
150148

151-
ZFS Boot Menu currently understands the following options:
149+
# Kernel command-line options
152150

153-
* `spl_hostid=` used to set the system hostid if you are using a pre-built initramfs from the release page.
154-
* `force_import=0|1` set to `1` to attempt to force import all pools on the system. Use with caution!
155-
* `read_write=0|1` set to `1` to enable writes to pools when importing. Pools are imported read-only by default as a safety precaution.
156-
* `timeout=`
157-
* A value of `0` will result in the system immediately booting from the pool configured in the `bootfs` pool property
158-
* A value of `-1` will result in the system displaying a boot menu.
159-
* Any other positive value will show a countdown timer to boot the environment configured under `bootfs`, otherwise it will default to a boot menu.
160-
* `""|zfsbootmenu|zfsbootmenu:|zfsbootmenu:POOL=zroot` The first three values are functionally identical. The fourth can be used to prefer a pool if multiple are present in the system.
151+
The [zfsbootmenu(7)](pod/zfsbootmenu.7.pod#cli-parameters) manual page describes command-line options for ZFSBootMenu kernels in detail.
161152

162153
# ZFS properties
163154

164-
The following properties can be set at whatever level of the pool you'd prefer to control the boot behavior.
165-
166-
* `org.zfsbootmenu:kernel` this can be a partial kernel name `(5.4)` or an explicit name `(vmlinuz-5.6.11_1)`.
167-
* `org.zfsbootmenu:commandline` set the list of kernel commandline options to be passed to the final OS. Do not set `root=`, this is set for you.
168-
* `org.zfsbootmenu:active` controls whether boot environments appear in or are hidden from ZFS Boot Menu:
169-
- If a boot environment has the property `mountpoint=/`, set `org.zfsbootmenu:active=off` to *hide* the environment. For any other value, including not set, the boot environment will be shown.
170-
- If a boot environment has the property `mountpoint=legacy`, set `org.zfsbootmenu:active=on` to *show* the environment. For any other value, including not set, the boot environment will be hidden. **Note**: Not all Linux distributions support booting from filesystems with `mountpoint=legacy`.
171-
* `org.zfsbootmenu:rootprefix` controls the prefix added to the ZFS filesystem provided as the root to kernels booted by ZFSBootMenu. For example, the command-line argument `root=zfs:zroot/ROOT/void` has the root prefix `root=zfs:`, which is the default value unless the boot environment appears to be Arch Linux; for Arch, the default root prefix is `zfs=`. Set `org.zfsbootmenu:rootprefix` on any boot environment or its parent to override this default. Remember to include the `root=` component if necessary and any delimiters like `:` or `=` that separate the prefix from the root filesystem.
172-
155+
The [zfsbootmenu(7)](pod/zfsbootmenu.7.pod#zfs-properties) manual page describes ZFS properties interpreted by ZFSBootMenu.
173156

174157
# initramfs creation
175158

@@ -189,59 +172,11 @@ Your distribution should have packages for these already.
189172

190173
## config.yaml
191174

192-
The YAML file `/etc/zfsbootmenu/config.yaml` is used to control the behavior of `generate-zbm`. An example YAML configuration file follows:
193-
194-
```
195-
Global:
196-
ManageImages: false
197-
BootMountPoint: /boot/efi
198-
DracutConfDir: /etc/zfsbootmenu/dracut.conf.d
199-
Components:
200-
ImageDir: /boot/efi/EFI/void
201-
Versions: false
202-
Enabled: false
203-
syslinux:
204-
Config: /boot/syslinux/syslinux.cfg
205-
Enabled: false
206-
EFI:
207-
ImageDir: /boot/efi/EFI/void
208-
Versions: 2
209-
Enabled: false
210-
Kernel:
211-
CommandLine: ro quiet loglevel=0
212-
```
213-
214-
### Global
215-
* `ManageImages` Set this to 1 to allow `generate-zbm` to perform any actions (creation, removal of old files, etc)
216-
* `DracutConfDir` Set this to the location of the dracut configuration director for ZFS Boot Menu. This *CAN NOT* be the same location as the system `dracut.conf.d`, as the configuration files there directly conflict with the creation of the bootmenu initramfs.
217-
* `BootMountPoint` Generally, set this to the location of your ESP. `generate-zbm` will ensure that this is mounted when images are created and, if `generate-zbm` does the mounting, will unmount this filesystem on exit. If you wish to avoid the mount checks, remove this parameter.
218-
* `Version` A specific ZFS Boot Menu version string to use in producing images. In the string, the value `%{current}` will be replaced with the release version of ZFS Boot Menu. The default value is simply the current release version.
219-
220-
### Kernel
221-
* `CommandLine` If you're making a unified EFI file or a syslinux configuration, this is the command line passed to the boot image. Refer to [Command line options](README.md#command-line-options).
222-
* `Path` The full path to a specific kernel to use when making the boot images. If not specified, `generate-zbm` will try to pick a reasonable kernel.
223-
* `Version` A specific kernel version to use. The value "%{current}" will be replaced with the output of `uname -r`; the braces can be omitted if `%current` ends on a word bounary. If not set, `generate-zbm` will try to parse the path of the selected kernel for a version.
224-
* `Prefix` The prefix to use for the names of ZFS Boot Menu images. By default, the prefix is extracted from the input kernel name.
225-
226-
### Components
227-
* `ImageDir` This is the destination directory for the initramfs and kernel.
228-
* `Enabled` Set to `true` to enable creation of separate ZFS Boot Menu kernel and initramfs images. The default value is `false`.
229-
* `Versions` Set to `false` or `0` to disable image versioning; `generate-zbm` will not use its `Global.Version` parameter to name outputs, and will keep exactly one backup copy of every image it produces. Set to `true` (which behaves as `1`) or a positive integer to enable image versioning; `generate-zbm` will append the value of `Global.Version` to every image it produces, followed by a revision as `_$revision`. `generate-zbm` will save `Config.Versions` *revisions* of all images that match the current value of `Global.Versions`. In addition, `generate-zbm` will save the *highest* revision of the most recent `Config.Versions` other image versions found.
230-
231-
### Components.syslinux
232-
* `Enabled` Set to `true` to enable syslinux configuration generation. The default value is `false`.
233-
* `Config` Set to the path of the syslinux configuration file to produce.
234-
235-
### EFI
236-
* `ImageDir` This is the destination directory for the unified EFI file.
237-
* `Enabled` Set to `true` to enable creation of unified UEFI bundles. The default value is `false`.
238-
* `Versions` Behaves similarly to `Components.Versions`, but acts on files matching the UEFI bundle naming scheme.
239-
* `Stub` This is the path to the stub loader used to boot the unified EFI image. If not set, a default of `/usr/lib/gummiboot/linuxx64.efi.stub` is assumed.
240-
175+
[config.yaml](pod/generate-zbm.5.pod) is used to control the operation of [generate-zbm](bin/generate-zbm).
241176

242177
## Conversion of legacy configurations
243178

244-
In prior versions of ZFS Boot Menu, an INI format was used for configuration. In general, migration to the new format is not automatic, but `generate-zbm` can perform the migration if your distribution package has not done it for you. To migrate an existing configuration, just run
179+
In prior versions of ZFSBootMenu, an INI format was used for configuration. In general, migration to the new format is not automatic, but `generate-zbm` can perform the migration if your distribution package has not done it for you. To migrate an existing configuration, just run
245180

246181
```
247182
generate-zbm --migrate [ini-config] [--config yaml-config]
@@ -257,7 +192,7 @@ Whenever `generate-zbm` attempts to migrate configuraton files, it will exit imm
257192

258193
# Native encryption
259194

260-
ZFS Boot Menu can import pools or filesystems with native encryption enabled. If your boot environments are not encrypted but say /home is, you will not receive a decryption prompt. To ensure that you can decrypt your pool to load the kernel and initramfs, you'll need to you have the filesystem parameters configured correctly.
195+
ZFSBootMenu can import pools or filesystems with native encryption enabled. If your boot environments are not encrypted but say /home is, you will not receive a decryption prompt. To ensure that you can decrypt your pool to load the kernel and initramfs, you'll need to you have the filesystem parameters configured correctly.
261196

262197
```
263198
zfs get all zroot | egrep '(encryption|keylocation|keyformat)'
@@ -274,4 +209,4 @@ For Dracut-based systems, this can be done by creating `/etc/dracut.conf.d/zol.c
274209
install_items+=" /etc/zfs/zroot.key "
275210
```
276211

277-
It's critical that you do not put this key file into the ZFS Boot Menu initramfs, since that file exists on an unencrypted volume - leaving your pool essentially wide-open.
212+
It's critical that you do not put this key file into the ZFSBootMenu initramfs, since that file exists on an unencrypted volume - leaving your pool essentially wide-open.

bin/generate-zbm

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use File::Path qw(make_path remove_tree);
1616
use File::Glob qw(:globally :nocase);
1717
use Sort::Versions;
1818

19+
use Pod::Usage qw(pod2usage);
20+
1921
use Data::Dumper;
2022
$Data::Dumper::Indent = 1;
2123
$Data::Dumper::Sortkeys = 1;
@@ -67,20 +69,7 @@ GetOptions(
6769
"migrate|m:s" => \$runConf{migrate},
6870
"config|c=s" => \$runConf{config},
6971
"help|h" => sub {
70-
my $bin = basename($0);
71-
my $help = << "EOF";
72-
Usage: $bin [options]
73-
-v|--version Manually set the version
74-
-k|--kernel Manually set the path to the kernel
75-
-K|--kver Manually set the kernel version
76-
-p|--prefix Manually set the output kernel prefix
77-
-b|--bootdir Manually set the location to search for kernel files
78-
-C|--confd Manually set the Dracut configuration directory
79-
-c|--config Manually set the configuration file
80-
-l|--cmdline Manually set the kernel command line
81-
-m|--migrate Migrate legacy INI file to new YAML format
82-
EOF
83-
print $help;
72+
pod2usage( -verbose => 2 );
8473
exit;
8574
},
8675
);
@@ -266,7 +255,7 @@ unless ( nonempty $runConf{kernel_prefix} and nonempty $runConf{kernel_version}
266255
}
267256
}
268257

269-
printf "Creating ZFS Boot Menu %s from kernel %s\n", $runConf{version}, $runConf{kernel};
258+
printf "Creating ZFSBootMenu %s from kernel %s\n", $runConf{version}, $runConf{kernel};
270259

271260
# Create a unified kernel/initramfs/command line EFI file
272261
if ( enabled $config{EFI} ) {
@@ -399,7 +388,7 @@ EOF
399388
my $kernel = basename($entry);
400389
my ( undef, $version ) = split( '-', $kernel );
401390
my $label = "ZFSBootMenu-$version";
402-
my $menu_label = "ZFS Boot Menu $version";
391+
my $menu_label = "ZFSBootMenu $version";
403392

404393
if ($add_default) {
405394
print CFG "DEFAULT $label\n\n";
@@ -705,3 +694,68 @@ sub convertImageConfig {
705694
delete $section->{Versioned};
706695
delete $section->{Copies};
707696
}
697+
698+
699+
__END__
700+
701+
=head1 NAME
702+
703+
B<generate-zbm> - ZFSBootMenu initramfs generator
704+
705+
=head1 SYNOPSIS
706+
707+
B<generate-zbm> [options]
708+
709+
=head1 OPTIONS
710+
711+
Where noted, command-line options supersede options in the B<generate-zbm>(5) configuration file.
712+
713+
=over 4
714+
715+
=item B<--version|-v> I<zbm-version>
716+
717+
Override the ZFSBootMenu version; supersedes I<Global.Version>
718+
719+
=item B<--kernel|-k> I<kernel-path>
720+
721+
Manually specify a specific kernel; supersedes I<Kernel.Path>
722+
723+
=item B<--kver|-K> I<kernel-version>
724+
725+
Manually specify a specific kernel version; supersedes I<Kernel.Version>
726+
727+
=item B<--prefix|-p> I<image-prefix>
728+
729+
Manually specify the output image prefix; supersedes I<Kernel.Prefix>
730+
731+
=item B<--confd|-C> I<confd-path>
732+
733+
Specify the dracut configuration directory; supersedes I<Global.DracutConfDir>
734+
735+
=item B<--cmdline|-l> I<options>
736+
737+
Override the kernel command line; supersedes I<Kernel.CommandLine>
738+
739+
=item B<--bootdir|-b> I<boot-path>
740+
741+
Specify the path to search for kernel files; default: I</boot>
742+
743+
=item B<--config|-c> I<conf-file>
744+
745+
Specify the path to a configuration file; default: I</etc/zfsbootmenu/config.yaml>
746+
747+
=item B<--migrate|-m> [I<ini-config>]
748+
749+
Migrate a legacy INI file to the new YAML format, writing the converted file to the path specified by B<--config>. If I<ini-config> is not specified, a default path is chosen by removing any I<.yaml> suffix in the B<--config> path and appending a I<.ini> suffix.
750+
751+
=back
752+
753+
=head1 SEE ALSO
754+
755+
B<generate-zbm>(5) B<zfsbootmenu>(7)
756+
757+
=head1 AUTHOR
758+
759+
ZFSBootMenu Team L<https://github.com/zdykstra/zfsbootmenu>
760+
761+
=cut

0 commit comments

Comments
 (0)