*: refactor
Documentation will be rewritten and added later.
This commit is contained in:
34
hook/lvm/lvm
Normal file
34
hook/lvm/lvm
Normal file
@ -0,0 +1,34 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# https://shellcheck.net/wiki/SC2154
|
||||
# shellcheck disable=2154
|
||||
|
||||
[ "$hostonly" ] &&
|
||||
for _mod in \
|
||||
dm-log dm-cache dm-mirror \
|
||||
dm-snapshot dm-multipath dm-thin-pool
|
||||
do
|
||||
copy_kmod "$_mod"
|
||||
done
|
||||
|
||||
copy_exec lvm
|
||||
|
||||
_config='
|
||||
devices {
|
||||
write_cache_state = 0
|
||||
}
|
||||
backup {
|
||||
backup = 0
|
||||
archive = 0
|
||||
}
|
||||
global {
|
||||
use_lvmetad = 0
|
||||
}'
|
||||
|
||||
mkdir -p "${tmpdir}/etc/lvm"
|
||||
|
||||
lvm config \
|
||||
--config "$_config" \
|
||||
${lvm_config:+--mergedconfig} \
|
||||
> "${tmpdir}/etc/lvm/lvm.conf"
|
30
hook/lvm/lvm.init
Normal file
30
hook/lvm/lvm.init
Normal file
@ -0,0 +1,30 @@
|
||||
# vim: set ft=sh:
|
||||
# shellcheck shell=sh
|
||||
#
|
||||
# https://shellcheck.net/wiki/SC2154
|
||||
# shellcheck disable=2154
|
||||
|
||||
mkdir -p /run/lvm /run/lock/lvm
|
||||
|
||||
set -- --sysinit -qq -aay ${lvm_discard:+--config=devices\{issue_discards=1\}}
|
||||
|
||||
if [ "$lvm_group" ] && [ "$lvm_name" ]; then
|
||||
set -- lvchange "$@" "${lvm_group}/${lvm_name}"
|
||||
elif [ "$lvm_group" ]; then
|
||||
set -- vgchange "$@" "$lvm_group"
|
||||
elif [ "$lvm_tag" ]; then
|
||||
set -- lvchange "$@" "@${lvm_tag}"
|
||||
else
|
||||
set -- vgchange "$@"
|
||||
fi
|
||||
|
||||
_count=0
|
||||
|
||||
# Handle race condition.
|
||||
while ! DM_DISABLE_UDEV=1 lvm "$@"; do
|
||||
if [ "$((_count += 1))" = 10 ]; then
|
||||
panic "failed to trigger LVM"
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user