]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/90btrfs/module-setup.sh
Merge pull request #317 from dracut-mailing-devs/20171212142718.11451-1-carlo@caione.org
[thirdparty/dracut.git] / modules.d / 90btrfs / module-setup.sh
1 #!/bin/bash
2
3 # called by dracut
4 check() {
5 local _rootdev
6 # if we don't have btrfs installed on the host system,
7 # no point in trying to support it in the initramfs.
8 require_binaries btrfs || return 1
9
10 [[ $hostonly ]] || [[ $mount_needs ]] && {
11 for fs in "${host_fs_types[@]}"; do
12 [[ "$fs" == "btrfs" ]] && return 0
13 done
14 return 255
15 }
16
17 return 0
18 }
19
20 # called by dracut
21 depends() {
22 echo udev-rules
23 return 0
24 }
25
26 # called by dracut
27 installkernel() {
28 instmods btrfs
29 # Make sure btfs can use fast crc32c implementations where available (bsc#1011554)
30 instmods crc32c-intel
31 }
32
33 # called by dracut
34 install() {
35 if ! inst_rules 64-btrfs.rules; then
36 inst_rules "$moddir/80-btrfs.rules"
37 case "$(btrfs --help)" in
38 *device\ ready*)
39 inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished ;;
40 *)
41 inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished ;;
42 esac
43 fi
44
45 if ! dracut_module_included "systemd"; then
46 inst_hook initqueue/timeout 10 "$moddir/btrfs_timeout.sh"
47 fi
48
49 inst_multiple -o btrfsck btrfs-zero-log
50 inst $(command -v btrfs) /sbin/btrfs
51 }
52