Skip to content

Commit b7c40f6

Browse files
committed
Enable LVM autoextend and set default value to 90 for thin_pool
Fixes QubesOS/qubes-issues#5826
1 parent ea5f370 commit b7c40f6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

rpm_spec/core-dom0-linux.spec.in

+25
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ if ! grep -q ^qubes: /etc/group ; then
179179
fi
180180

181181
%post
182+
set -eo pipefail
182183

183184
/usr/lib/qubes/patch-dnf-yum-config
184185

@@ -192,6 +193,30 @@ if [ $1 -ge 2 ]; then
192193
fi
193194
fi
194195

196+
# setup thinpool autoextend
197+
if [ -e /etc/lvm/lvm.conf ]; then
198+
tpool_threshold_line_value=$(grep -n -Po '^[^#]thin_pool_autoextend_threshold[ \t]*=[ \t]*\K\d+' /etc/lvm/lvm.conf)
199+
if [ -n "$tpool_threshold_line_value" ]; then
200+
tpool_threshold_line="$(echo "$tpool_threshold_line_value" | cut -d':' -f1)"
201+
tpool_threshold_value="$(echo "$tpool_threshold_line_value" | cut -d':' -f2)"
202+
203+
if [ -n "$tpool_threshold_line" ] && [ -n "$tpool_threshold_value" ]; then
204+
prev_line="$(sed -n "$((tpool_threshold_line-1))p" /etc/lvm/lvm.conf)"
205+
qubes_comment='# QUBES OS: Custom value detected, not enforcing default. Recommended value: 90'
206+
207+
if [ "$tpool_threshold_value" == 100 ]; then
208+
sed -i 's|^\([^#]thin_pool_autoextend_threshold\)[ \t]*=.*|\1 = 90|' /etc/lvm/lvm.conf
209+
210+
systemctl restart lvm2-monitor
211+
else
212+
if [ "$tpool_threshold_value" != 90 ] && [ "$prev_line" != "$qubes_comment" ]; then
213+
sed -i "${tpool_threshold_line}i $qubes_comment" /etc/lvm/lvm.conf
214+
fi
215+
fi
216+
fi
217+
fi
218+
fi
219+
195220
%preun
196221
if [ "$1" = 0 ] ; then
197222
# no more packages left

0 commit comments

Comments
 (0)