On my Ubuntu 18.04, I see /var/log/journal
is created but I can't figure out what created it in the first place. Could somebody help me? I'll provide more details below.
This is not an XY problem. I'm asking this question for pure curiosity in order to understand systemd
or Ubuntu better.
What I have learned
By reading systemd-journald.service(8) and journald.conf(5), I learned that:
- If
Storage=persistent
in /etc/systemd/journald.conf
, /var/log/journal
is created automatically.
- If
Storage=auto
in /etc/systemd/journald.conf
, /var/log/journal
is not created automatically if it doesn't exist. But if the system admin creates /var/log/journal
, systemd-journald
will write logs into it. Otherwise, it falls back to using /run/log/journal
.
On my Ubuntu 18.04, my /etc/systemd/journald.conf
uses all the default values:
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See journald.conf(5) for details.
[Journal]
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=1000
#SystemMaxUse=
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
In other words, I'm using Storage=auto
on my system.
I also learned from systemd-tmpfiles(8) and tmpfiles.d(5) that systemd-tmpfiles
creates, deletes, and cleans up volatile and temporary files and directories, based on the configuration file format and location specified in tmpfiles.d(5).
So I examined the tmpfiles.d(5)
folders and I only found configuration files under /usr/lib/tmpfiles.d
that modify the attributes of /var/log/journal
, as shown in the following grep
output:
/usr/lib/tmpfiles.d$ grep journal *.conf
journal-nocow.conf:# Set the NOCOW attribute for directories of journal files. This flag
journal-nocow.conf:# WARNING: Enabling the NOCOW attribute improves journal performance
journal-nocow.conf:# enabling the NOCOW attribute for journal files is safe, because
journal-nocow.conf:h /var/log/journal - - - - +C
journal-nocow.conf:h /var/log/journal/%m - - - - +C
journal-nocow.conf:h /var/log/journal/remote - - - - +C
systemd.conf:z /run/log/journal 2755 root systemd-journal - -
systemd.conf:Z /run/log/journal/%m ~2750 root systemd-journal - -
systemd.conf:a+ /run/log/journal/%m - - - - d:group:adm:r-x
systemd.conf:a+ /run/log/journal/%m - - - - group:adm:r-x
systemd.conf:a+ /run/log/journal/%m/*.journal* - - - - group:adm:r--
systemd.conf:z /var/log/journal 2755 root systemd-journal - -
systemd.conf:z /var/log/journal/%m 2755 root systemd-journal - -
systemd.conf:z /var/log/journal/%m/system.journal 0640 root systemd-journal - -
systemd.conf:a+ /var/log/journal - - - - d:group::r-x,d:group:adm:r-x
systemd.conf:a+ /var/log/journal - - - - group::r-x,group:adm:r-x
systemd.conf:a+ /var/log/journal/%m - - - - d:group:adm:r-x
systemd.conf:a+ /var/log/journal/%m - - - - group:adm:r-x
systemd.conf:a+ /var/log/journal/%m/system.journal - - - - group:adm:r--
But by reading the meanings of h
, z
, Z
, and a+
, none of them seem to create the folder /var/log/journal
. All of them seem to only modify the attributes of /var/log/journal
.
I did a test in which I deleted the folder /var/log/journal
and rebooted my computer. Then I saw /var/log/journal
was not re-created (which was expected because of Storage=auto
on my machine). Instead, /run/log/journal
was created (as expected).
What created /var/log/journal
?