]> git.ipfire.org Git - thirdparty/dracut.git/blame_incremental - modules.d/90btrfs/module-setup.sh
fix(btrfs): do not require module via cmdline when --no-kernel
[thirdparty/dracut.git] / modules.d / 90btrfs / module-setup.sh
... / ...
CommitLineData
1#!/bin/bash
2
3# called by dracut
4check() {
5 # if we don't have btrfs installed on the host system,
6 # no point in trying to support it in the initramfs.
7 require_binaries btrfs || return 1
8
9 [[ $hostonly ]] || [[ $mount_needs ]] && {
10 for fs in "${host_fs_types[@]}"; do
11 [[ $fs == "btrfs" ]] && return 0
12 done
13 return 255
14 }
15
16 return 0
17}
18
19# called by dracut
20depends() {
21 echo udev-rules
22 return 0
23}
24
25# called by dracut
26cmdline() {
27 # Hack for slow machines
28 # see https://github.com/dracutdevs/dracut/issues/658
29 printf " rd.driver.pre=btrfs"
30}
31
32# called by dracut
33installkernel() {
34 instmods btrfs
35 printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf"
36}
37
38# called by dracut
39install() {
40 if ! inst_rules 64-btrfs.rules; then
41 inst_rules "$moddir/80-btrfs.rules"
42 case "$(btrfs --help)" in
43 *device\ ready*)
44 inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished
45 ;;
46 *)
47 inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
48 ;;
49 esac
50 else
51 inst_rules 64-btrfs-dm.rules
52 fi
53
54 if ! dracut_module_included "systemd"; then
55 inst_hook initqueue/timeout 10 "$moddir/btrfs_timeout.sh"
56 fi
57
58 inst_multiple -o btrfsck btrfs-zero-log
59 inst "$(command -v btrfs)" /sbin/btrfs
60}