]> git.ipfire.org Git - thirdparty/dracut.git/blame - 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
95d2dabc 1#!/bin/bash
95d2dabc 2
8bcfd683 3# called by dracut
95d2dabc 4check() {
a5e33c7d 5 # if we don't have btrfs installed on the host system,
95d2dabc 6 # no point in trying to support it in the initramfs.
30e6e809 7 require_binaries btrfs || return 1
95d2dabc 8
1b7fd0fa 9 [[ $hostonly ]] || [[ $mount_needs ]] && {
3721635b 10 for fs in "${host_fs_types[@]}"; do
75d758e8 11 [[ $fs == "btrfs" ]] && return 0
480d772f 12 done
d351541e 13 return 255
480d772f 14 }
95d2dabc
HH
15
16 return 0
17}
18
8bcfd683 19# called by dracut
95d2dabc
HH
20depends() {
21 echo udev-rules
22 return 0
23}
24
2b47a2ef
AAF
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
8bcfd683 32# called by dracut
a5e33c7d 33installkernel() {
3de6001e 34 instmods btrfs
7ed765dd 35 printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf"
a5e33c7d
WW
36}
37
8bcfd683 38# called by dracut
95d2dabc 39install() {
f12f6943
HH
40 if ! inst_rules 64-btrfs.rules; then
41 inst_rules "$moddir/80-btrfs.rules"
42 case "$(btrfs --help)" in
43 *device\ ready*)
9a52c3fd
HH
44 inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished
45 ;;
f12f6943 46 *)
9a52c3fd
HH
47 inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
48 ;;
f12f6943 49 esac
d4caa86a
HH
50 else
51 inst_rules 64-btrfs-dm.rules
f12f6943
HH
52 fi
53
24d00950 54 if ! dracut_module_included "systemd"; then
50f5bbbb 55 inst_hook initqueue/timeout 10 "$moddir/btrfs_timeout.sh"
24d00950
HH
56 fi
57
af119460 58 inst_multiple -o btrfsck btrfs-zero-log
640458bb 59 inst "$(command -v btrfs)" /sbin/btrfs
95d2dabc 60}