mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-27 11:46:44 +00:00
postinst: set custom LVM settings
now that we no longer ship our own LVM packages, set the relevant filtering options here if they are missing. for an upgrade from PVE 6.x, the following two scenarios are likely: A: user edited config provided by our old lvm2 package. it likely contains our (or a modified) global_filter, but the old scan_lvs default. in this case we ignore global_filter as long as it contains our 'don't scan zvols' entry, and set scan_lvs to false. B: config provided by our old lvm2 package was taken over by default config from stock lvm2 package. scan_lvs defaults to false already, but global_filter is unset (scan everything), so we need to set our own global_filter excluding zvols. other combinations should be handled fine as well. for new installs (installer, install on top of Debian Bullseye) we are always in scenario B. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
48197df2b9
commit
c690885959
56
debian/postinst
vendored
56
debian/postinst
vendored
@ -8,6 +8,60 @@ set -e
|
||||
# done its automatic conffile handling, and all the packages we depend
|
||||
# of are already fully installed and configured.
|
||||
|
||||
set_lvm_conf() {
|
||||
LVM_CONF_MARKER="# added by pve-manager to avoid scanning"
|
||||
|
||||
# only do these changes once
|
||||
# keep user changes afterwards provided marker is still there..
|
||||
if ! grep -qLF "$LVM_CONF_MARKER" /etc/lvm/lvm.conf; then
|
||||
OLD_VALUE="$(lvmconfig --typeconfig full devices/global_filter)"
|
||||
NEW_VALUE='global_filter=["r|/dev/zd.*|"]'
|
||||
|
||||
export LVM_SUPPRESS_FD_WARNINGS=1
|
||||
|
||||
# check global_filter
|
||||
# keep previous setting from our custom packaging if it is still there
|
||||
if echo "$OLD_VALUE" | grep -qvF 'r|/dev/zd.*|'; then
|
||||
SET_FILTER=1
|
||||
BACKUP=1
|
||||
fi
|
||||
# should be the default since bullseye
|
||||
if lvmconfig --typeconfig full devices/scan_lvs | grep -qv 'scan_lvs=0'; then
|
||||
SET_SCAN_LVS=1
|
||||
BACKUP=1
|
||||
fi
|
||||
if test -n "$BACKUP"; then
|
||||
echo "Backing up lvm.conf before setting pve-manager specific settings.."
|
||||
cp -vb /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
|
||||
fi
|
||||
if test -n "$SET_FILTER"; then
|
||||
echo "Setting 'global_filter' in /etc/lvm/lvm.conf to prevent zvols from being scanned:"
|
||||
echo "$OLD_VALUE => $NEW_VALUE"
|
||||
# comment out existing setting
|
||||
sed -i -e 's/^\([[:space:]]*global_filter[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
|
||||
# add new section with our setting
|
||||
cat >> /etc/lvm/lvm.conf <<EOF
|
||||
devices {
|
||||
$LVM_CONF_MARKER ZFS zvols
|
||||
$NEW_VALUE
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
if test -n "$SET_SCAN_LVS"; then
|
||||
echo "Adding scan_lvs=0 setting to /etc/lvm/lvm.conf to prevent LVs from being scanned."
|
||||
# comment out existing setting
|
||||
sed -i -e 's/^\([[:space:]]*scan_lvs[[:space:]]*=\)/#\1/' /etc/lvm/lvm.conf
|
||||
# add new section with our setting
|
||||
cat >> /etc/lvm/lvm.conf <<EOF
|
||||
devices {
|
||||
$LVM_CONF_MARKER LVM volumes
|
||||
scan_lvs=0
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
triggered)
|
||||
# We don't print a status message here, as dpkg already said
|
||||
@ -109,6 +163,8 @@ case "$1" in
|
||||
fi
|
||||
fi
|
||||
|
||||
set_lvm_conf
|
||||
|
||||
if test ! -e /proxmox_install_mode; then
|
||||
# modeled after code generated by dh_start
|
||||
for unit in ${UNITS}; do
|
||||
|
Loading…
Reference in New Issue
Block a user