[pve-devel] [PATCH manager] pve8to9: check for settings in /etc/sysctl.conf

Stoiko Ivanov s.ivanov at proxmox.com
Mon Aug 4 12:23:28 CEST 2025


The procps package removed `/etc/sysctl.conf` in version 2:4.0.4-7
[0], as the shipped settings have moved to `linux-sysctl-defaults`[1]
and snippet files in /etc/sysctl.d/ have been favored for a while
now.  Setting them is done by systemd-sysctl.service(8) which only
mentions the snippet-directories (/etc/sysctl.d/*.conf).

Upon upgrading the settings are not set anymore (but are preserved
under /etc/sysctl.conf.dpkg-bak).

As `/etc/sysctl.conf` has been around for a long time (and is present
in most Unixoid systems), and is the default place where e.g. ansible
places settings[2] a warning about lost settings makes sense.

[0] https://metadata.ftp-master.debian.org/changelogs//main/p/procps/procps_4.0.4-9_changelog
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1074156
[2] https://docs.ansible.com/ansible/latest/collections/ansible/posix/sysctl_module.html
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
this caught me by surprise for a system where I had set
`net.ipv6.conf.all.accept_ra=2`
in /etc/sysctl.conf

 PVE/CLI/pve8to9.pm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/PVE/CLI/pve8to9.pm b/PVE/CLI/pve8to9.pm
index 8c26ddbd..112a9f44 100644
--- a/PVE/CLI/pve8to9.pm
+++ b/PVE/CLI/pve8to9.pm
@@ -2069,6 +2069,33 @@ sub check_legacy_ipam_files {
     }
 }
 
+sub check_legacy_sysctl_conf {
+    my $fn = "/etc/sysctl.conf";
+    if (!-f $fn) {
+        log_pass("Legacy file '$fn' is not present.");
+        return;
+    } elsif ($upgraded) {
+        log_skip("System upgraded '$fn' will not be removed anymore.");
+        return;
+    }
+    my $raw = eval { PVE::Tools::file_get_contents($fn); };
+    if ($@) {
+        log_fail("Failed to read '$fn' - $@");
+        return;
+    }
+
+    my @lines = split(/\n/, $raw);
+    for my $line (@lines) {
+        if ($line !~ /^[\s]*(:?$|[#;].*$)/m) {
+            log_warn(
+                "Deprecated config '$fn' contains settings - move them to a dedicated file in '/etc/sysctl.d/'."
+            );
+            return;
+        }
+    }
+    log_pass("No settings in '$fn'");
+}
+
 sub check_misc {
     print_header("MISCELLANEOUS CHECKS");
     my $ssh_config = eval { PVE::Tools::file_get_contents('/root/.ssh/config') };
@@ -2164,6 +2191,7 @@ sub check_misc {
     check_lvm_autoactivation();
     check_rrd_migration();
     check_legacy_ipam_files();
+    check_legacy_sysctl_conf();
 }
 
 my sub colored_if {
-- 
2.39.5





More information about the pve-devel mailing list