Skip to content

Commit

Permalink
Enable LVM autoextend and set default value to 90 for thin_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
fepitre committed Jun 5, 2021
1 parent ea5f370 commit 605cb47
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rpm_spec/core-dom0-linux.spec.in
Expand Up @@ -192,6 +192,28 @@ if [ $1 -ge 2 ]; then
fi
fi

# setup thinpool autoextend
if [ -e /etc/lvm/lvm.conf ]; then
tpool_threshold_line_value=$(grep -n -Po '^[^#]thin_pool_autoextend_threshold[ \t]*=[ \t]*\K\d+' /etc/lvm/lvm.conf)
if [ -n "$tpool_threshold_line_value" ]; then
tpool_threshold_line="$(echo "$tpool_threshold_line_value" | cut -d':' -f1)"
tpool_threshold_value="$(echo "$tpool_threshold_line_value" | cut -d':' -f2)"

prev_line="$(sed -n "$((tpool_threshold_line-1))p" /etc/lvm/lvm.conf)"
qubes_comment='# QUBES OS: Custom value detected, not enforcing default. Recommended value: 90'

if [ "$tpool_threshold_value" == 100 ]; then
sed -i 's|^\([^#]thin_pool_autoextend_threshold\)[ \t]*=.*|\1 = 90|' /etc/lvm/lvm.conf

systemctl restart lvm2-monitor
else
if [ "$tpool_threshold_value" != 90 ] && [ "$prev_line" != "$qubes_comment" ]; then
sed -i "${tpool_threshold_line}i $qubes_comment" /etc/lvm/lvm.conf
fi
fi
fi
fi

%preun
if [ "$1" = 0 ] ; then
# no more packages left
Expand Down

0 comments on commit 605cb47

Please sign in to comment.