3

On my archlinux installation, I realised that flushing the journal logs to disk by the systemd-journal-flush service significantly prolongs the boot process and masking the service improves boot time. Can I permanently mask the service and run journalctl --flush later when the computer is idle to flush the journal logs to disk. Will this cause any undesirable system behaviour?

  • 1
    In /etc/systemd/journald.conf, what's the value for Storage= ? – iamauser Jan 4 '18 at 18:04
  • 1
    It is currently set to the default value 'persistant'. I have tried changing it to 'volatile', and this also gives a similar improvement in boot time as this avoids flushing the logs to the disk. But won't using the 'volatile' option lead to loss of journal log data after reboots? – Kevin Selva Prasanna Jan 5 '18 at 5:58
  • I posted a solution to your problem, test it and see if it improves the boot time. – iamauser Jan 5 '18 at 15:57
1

Others point out that running journald without any persistent logs, is an option. This approach is documented without any particular warnings, and is used on large numbers of systems. Fedora started with no persistent journal plus a syslog daemon, and Debian still defaults that way.

So there's no reason to expect a problem.

I would feel free to mask the original service, and arrange for the flush to be run later however you like.

If at some later point you have a weird system crash during the boot process, you might want to re-enable it (and set a low SyncIntervalSec= in journald.conf), to try and recover any relevant log messages.

2

Following are the steps to solve this:

  1. Do a flush journalctl --flush
  2. Remove/Move the directory /var/log/journal
  3. Set Storage=auto in /etc/systemd/journald.conf
  4. Reboot the machine

You should see an improvement in the boot time.

  • The manual entry for journalctl states that if the directory does not exist, the journal logs would not be flushed to the disk. But won't this lead to loss of the log data? I am worried if this loss would be cause of concern. If not, I could just mask the journal flush service permanently. – Kevin Selva Prasanna Jan 5 '18 at 16:49
  • No, this won't result in loss of data anymore than what --flush will cause. Storage=auto takes care of not writing to /var/log/journal which --flush tries to reset. – iamauser Jan 5 '18 at 18:05
0

In /etc/systemd/journald.conf, you can set Storage=auto, which will log to disk if /var/log/journal exists. Don't create the directory.

Then you can use your approach of running a command when idle to flush the logs disk:

sudo mkdir /var/log/journal && journalctl --flush
  • 1
    But once I create the directory, the service would flush the journal to the disk on the next reboot. So the boot time would get worse again. Won't it? I need a permanent solution. – Kevin Selva Prasanna Jan 5 '18 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.