Configuring journald via config file

Hi all,

I am trying to limit the size and number of log files created by changing the default entries in /etc/systemd/journald.config

I have tried using sed to change the file in the gadget hooks (install, prepare-device, etc) but I still have the original default file once it installs and boots up. With the expected apparmor denial messages. I have tried adding numerous plugs to the gadget like log-observe, system observe, even system-files specifying the exact file:

    interface: system-files
    - /etc/systemd/journald.conf

I’ve tried injecting the modified file into the build process, and numerous other ways to “modify” the file. Is this even possible to do? I would think that something like this (creating the version of a system file you want and putting in the image before it is read-only) would be a fairly common and useful thing for building a system.

Can someone offer any advice on a possible way to accomplish this?

Thanks in advance,


well, in Ubuntu Core journald does not create “log files” at all but uses a ringbuffer for all logging with (at most) 1% of the size of your RAM, by default nothing is written to disk. what are the files you want to prevent from being created ?

ignoring the above, using a system-files interface is the correct way to go to manipulate the journald defaults … (i’d use a config or agent snap to do this though, not the gadget, since app snaps are easier to change and update in case you want to make any adjustments in production later)

1 Like

@ogra thanks for your response. Yes, I should have been a bit more clear (or more specific). We do want to keep a limited series of logs across reboots, etc for diagnosing issues, so I have enabled journald persistence.

However, we also want to limit the disk space that those saved logs take up, hence the desire to edit the config file.

I am moving the script to change this file to a separate (non-gadget) snap as you indicated and trying that now.

Thanks again for your time.