]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: allow default storage mode to be configured
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Nov 2025 14:43:34 +0000 (15:43 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 Nov 2025 23:08:31 +0000 (00:08 +0100)
So far the idea was that the default is 'auto', and if appropriate, the
distribution will create /var/log/journal/ to tell journald to use persistent
mode. This doesn't work well with factory resets, because after a factory reset
obviously /var/log is gone. That old default was useful when journald was new
and people were reluctant to enable persistent mode and instead relied on
rsyslog and such for the persistent storage. But nowadays that is rarer, and
anyway various features like user journals only work with persistent storage,
so we want people to enable this by default. Add an option to flip the default
and distributions can opt in. The default default value remains unchanged.

(I also tested using tmpfiles to instead change this, since we already set
access mode for /var/log/journal through tmpfiles. Unfortunately, tmpfiles runs
too late, after journald has already started, so if tmpfiles creates the
directory, it'll only be used after a reboot. This probably could be made to
work by adding a new service to flush the journal, but that becomes complicated
and we lose the main advantage of simplicity.)

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1387796.

man/custom-entities.ent.in
man/journald.conf.xml
meson.build
meson_options.txt
src/journal/journald-config.c
src/journal/journald.conf.in

index 6338ad13f967a227ae0aec122b3bc713886ef3e6..1f3ecefe61416f4890198fcd350e04b9960c1f40 100644 (file)
@@ -10,6 +10,7 @@
 <!ENTITY FALLBACK_HOSTNAME "{{FALLBACK_HOSTNAME}}">
 <!ENTITY MEMORY_ACCOUNTING_DEFAULT "{{ 'yes' if MEMORY_ACCOUNTING_DEFAULT else 'no' }}">
 <!ENTITY KILL_USER_PROCESSES "{{ 'yes' if KILL_USER_PROCESSES else 'no' }}">
+<!ENTITY JOURNAL_STORAGE_DEFAULT "{{JOURNAL_STORAGE_DEFAULT}}">
 <!ENTITY DEBUGTTY "{{DEBUGTTY}}">
 <!ENTITY SYSTEM_SYSVRCLOCAL_PATH "{{SYSTEM_SYSVRCLOCAL_PATH}}">
 <!ENTITY HIGH_RLIMIT_NOFILE "{{HIGH_RLIMIT_NOFILE}}">
index 1d615b110dc27cf2a260f83b2f604294122cc790..322fe6d17b6d655b499b4150bae045acd8cf97af 100644 (file)
@@ -1,6 +1,9 @@
 <?xml version='1.0'?> <!--*-nxml-*-->
 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % entities SYSTEM "custom-entities.ent" >
+%entities;
+]>
 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
 
 <refentry id="journald.conf"
@@ -82,8 +85,9 @@
         <filename>/var/log/journal</filename> directory exists, and <literal>volatile</literal> otherwise
         (the existence of the directory controls the storage mode). <literal>none</literal> turns off all
         storage, all log data received will be dropped (but forwarding to other targets, such as the console,
-        the kernel log buffer, or a syslog socket will still work). Defaults to <literal>auto</literal> in
-        the default journal namespace, and <literal>persistent</literal> in all others.</para>
+        the kernel log buffer, or a syslog socket will still work). Defaults to
+        <literal>&JOURNAL_STORAGE_DEFAULT;</literal> in the default journal namespace (this value is
+        determined at compilation time), and <literal>persistent</literal> in all others.</para>
 
         <para>Note that journald will initially use volatile storage, until a call to
         <command>journalctl --flush</command> (or sending <constant>SIGUSR1</constant> to journald) will cause
index 599d2a3217dae8b228e5f4785a495817c39a4855..055ee31ee4c556ee7e755b19e067f7a46e926480 100644 (file)
@@ -117,6 +117,9 @@ conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max'))
 conf.set10('BUMP_PROC_SYS_FS_NR_OPEN',  get_option('bump-proc-sys-fs-nr-open'))
 conf.set('HIGH_RLIMIT_NOFILE',          512*1024)
 
+conf.set('JOURNAL_STORAGE_DEFAULT',     get_option('journal-storage-default'))
+conf.set('JOURNAL_STORAGE_DEFAULT_VAL', 'STORAGE_' + get_option('journal-storage-default').to_upper())
+
 # Meson ignores the preceding arguments when joining paths if an absolute
 # component is encountered, so this should canonicalize various paths when they
 # are absolute or relative.
@@ -3096,6 +3099,7 @@ summary({
         'default locale'                            : default_locale,
         'default nspawn locale'                     : nspawn_locale,
         'default status unit format'                : status_unit_format_default,
+        'default journal storage mode'              : conf.get('JOURNAL_STORAGE_DEFAULT'),
         'default user $PATH'                        : default_user_path != '' ? default_user_path : '(same as system services)',
         'systemd service watchdog'                  : service_watchdog == '' ? 'disabled' : service_watchdog,
         'time epoch'                                : f'@time_epoch@ (@alt_time_epoch@)',
index 1d7c4f4bd27f4b760b4e5f07aa777b8fcc3db29e..f8a0fe37123ada88f697ddc5ee6ccf956d96f567 100644 (file)
@@ -139,6 +139,8 @@ option('timedated', type : 'boolean',
        description : 'install the systemd-timedated daemon')
 option('timesyncd', type : 'boolean',
        description : 'install the systemd-timesyncd daemon')
+option('journal-storage-default', type : 'combo', choices : ['auto', 'volatile', 'persistent', 'none'],
+       description : 'default storage mode for journald (main namespace)')
 option('remote', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
        description : 'support for "journal over the network"')
 option('create-log-dirs', type : 'boolean',
index 8cffec880b23c443ac6aacafa5b5972d2bc0e2d3..de78a40008fd2066986255adac29782cf2f2a216 100644 (file)
@@ -116,7 +116,7 @@ void manager_merge_configs(Manager *m) {
 
         journal_config_done(&m->config);
 
-        MERGE_NON_NEGATIVE(storage, STORAGE_AUTO);
+        MERGE_NON_NEGATIVE(storage, JOURNAL_STORAGE_DEFAULT_VAL);
         manager_merge_journal_compress_options(m);
         MERGE_NON_NEGATIVE(seal, true);
         /* By default, /dev/kmsg is read only by the main namespace instance. */
index 9a12ca76576866723b395997bcf3456cc0c2ec09..805b79bc8ad2dae2418ce18320770835b08ca036 100644 (file)
@@ -17,7 +17,7 @@
 # See journald.conf(5) for details.
 
 [Journal]
-#Storage=auto
+#Storage={{ JOURNAL_STORAGE_DEFAULT }}
 #Compress=yes
 #Seal=yes
 #SplitMode=uid