summarylogtreecommitdiffstats
path: root/lvm2_hook
blob: 1786fb585f8169cc5f77e5751367e87093154ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/ash

run_earlyhook() {
    mkdir /run/lvm
    lvmetad
}

run_hook() {
    lvm vgchange -a y
}

# We are suffering a race condition in non-systemd initramfs: If lvmetad is
# killed before pvscan processes finish we have stale processes and
# uninitialized physical volumes. So wait for pvscan processes to finish.
# Break after 10 seconds (50*0.2s) to avaid infinite loop.
run_latehook() {
    local i=50

    while pgrep -f pvscan >/dev/null 2>/dev/null && [ $i -gt 0 ]; do
        sleep 0.2
        i=$((i - 1))
    done
}

run_cleanuphook() {
    kill $(cat /run/lvmetad.pid)
}

# vim: set ft=sh ts=4 sw=4 et: