From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 80F3474EFA for ; Wed, 23 Jun 2021 11:00:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 75C1783B6 for ; Wed, 23 Jun 2021 11:00:34 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id A71F3838E for ; Wed, 23 Jun 2021 11:00:32 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 37D5645BCE for ; Wed, 23 Jun 2021 11:00:32 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Wed, 23 Jun 2021 11:00:25 +0200 Message-Id: <20210623090025.2994983-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.511 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager] postinst: set custom LVM settings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 09:00:34 -0000 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 --- Notes: once other difference between our old config and the stock one is that we had 'issue_discards' enabled. we could either put this in the release notes, or also enable it here automatically - but it is less straight-forward since the default is not "almost certainly wrong" like for the filtering options.. we could drop the "check for marker" and just do this once on initial install and upgrades from 6.x, but since the fallout from not having these in place can be data corruption (activating multiple VGs with same name, using one from a guest on the host!) I'd rather play it safe.. v2: - move more variables into if branch - export env variable to suppress LVM warnings (thanks Thomas) - fix grep for marker ("any lines that don't match" vs "no lines that match") debian/postinst | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/debian/postinst b/debian/postinst index 85f2a70a..0f6296c3 100755 --- a/debian/postinst +++ b/debian/postinst @@ -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 <> /etc/lvm/lvm.conf <