1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00
freebsd/contrib/dracut
Savyasachee Jha 44b0380a35 Make better use of dracut functions when building initramfs
Setting up the module involves multiple redundant calls to a bunch of
dracut functions wheich can be combined into one. Additionally, the mass
of code required to load libgcc_s.so* can be replaced with one dracut
function. This has the additional effect of removing errors involving
the non-installation of libgcc_s.so* which are seen on debian bullseye
when using version 2.1.2-1~bpo11+1 from the backports repository.

The systemd binaries are separated out into their own `dracut_install`
function call so they do not get pulled in when dracut does not load the
systemd module.

Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Andrew J. Hesford <ajh@sideband.org>
Signed-off-by: Savyasachee Jha <hi@savyasacheejha.com>
Closes #13010
2022-02-16 15:23:30 -08:00
..
02zfsexpandknowledge Add --enable=all to ShellCheck by default 2022-02-07 11:59:09 -08:00
90zfs Make better use of dracut functions when building initramfs 2022-02-16 15:23:30 -08:00
Makefile.am contrib: rename initrd READMEs to README.md 2022-02-11 11:44:27 -08:00
README.md contrib: rename initrd READMEs to README.md 2022-02-11 11:44:27 -08:00

Basic setup

  1. Install zfs-dracut
  2. Set mountpoint=/ for your root dataset (for compatibility, legacy also works, but is not recommended for new installations):
    zfs set mountpoint=/ pool/dataset
    
  3. Either (a) set bootfs= on the pool to the dataset:
    zpool set bootfs=pool/dataset pool
    
  4. Or (b) append root=zfs:pool/dataset to your kernel cmdline.
  5. Re-generate your initrd and update it in your boot bundle

Encrypted datasets have keys loaded automatically or prompted for.

If the root dataset contains children with mountpoint=s of /etc, /bin, /lib*, or /usr, they're mounted too.

cmdline

  1. root= Root dataset is… Pools imported
    (empty) the first bootfs= after zpool import -aN all
    zfs:AUTO (as above, but overriding other autoselection methods) all
    ZFS=pool/dataset pool/dataset pool
    zfs:pool/dataset (as above) pool

    All +es are replaced with spaces (i.e. to boot from root pool/data set, pass root=zfs:root+pool/data+set).

    The dataset can be at any depth, including being the pool's root dataset (i.e. root=zfs:pool).

  2. spl_hostid: passed to zgenhostid -f, useful to override the /etc/hostid file baked into the initrd.

  3. bootfs.snapshot, bootfs.snapshot=snapshot-name: enables zfs-snapshot-bootfs.service, which creates a snapshot $root_dataset@$(uname -r) (or, in the second form, $root_dataset@snapshot-name) after pool import but before the rootfs is mounted. Failure to create the snapshot is noted, but booting continues.

  4. bootfs.rollback, bootfs.rollback=snapshot-name: enables zfs-snapshot-bootfs.service, which -Rf rolls back to $root_dataset@$(uname -r) (or, in the second form, $root_dataset@snapshot-name) after pool import but before the rootfs is mounted. Failure to roll back will fall down to the rescue shell. This has obvious potential for data loss: make sure your persistent data is not below the rootfs and you don't care about any intermediate snapshots.

  5. If both bootfs.snapshot and bootfs.rollback are set, bootfs.rollback is ordered after bootfs.snapshot.

  6. zfs_force, zfs.force, zfsforce: add -f to all zpool import invocations. May be useful. Use with caution.