2

So basically BTRFS transparent compression (zstd:0) isn't working for the log files under /var/log/journal. I don't understand this issue because manually compressing the files (zstd file) gives a significant difference in size, but compsize reports them 100% as uncompressed. The compression works fine for other partitions.

fstab

/dev/mapper/vg_1-lv_varlog /var/log        btrfs   compress-force=zstd,relatime,nodev,nosuid,noexec 0       0

compsize

Processed 21 files, 28 regular extents (28 refs), 0 inline.
Type       Perc     Disk Usage   Uncompressed Referenced
TOTAL      100%      1.0G         1.0G         1.0G
none       100%      1.0G         1.0G         1.0G

Examples files

-rw-r-----+ 1 root systemd-journal  72M Apr  3 07:32 system@0a8678d3dc704a8c898bb86a8a8bc4bd-00000000000c94d0-0005a2528ac7d3c7.journal
-rw-r-----+ 1 root systemd-journal  72M Apr  3 19:09 system@0a8678d3dc704a8c898bb86a8a8bc4bd-00000000000de606-0005a25c3fec3527.journal
-rw-r-----+ 1 root systemd-journal  72M Apr  4 06:45 system@0a8678d3dc704a8c898bb86a8a8bc4bd-00000000000f3745-0005a265fa4a95e6.journal
-rw-r-----+ 1 root systemd-journal  72M Apr  4 18:20 system@0a8678d3dc704a8c898bb86a8a8bc4bd-000000000010887c-0005a26fb371f920.journal

Compression ratio example

-rw-r-----+ 1 root systemd-journal  72M Apr  8 06:55 system@0a8678d3dc704a8c898bb86a8a8bc4bd-00000000001c6a81-0005a2b9d9cd6e8f.journal
-rw-r-----+ 1 root systemd-journal 9.2M Apr  8 06:55 system@0a8678d3dc704a8c898bb86a8a8bc4bd-00000000001c6a81-0005a2b9d9cd6e8f.journal.zst

It even seems that journald is not even performing compression, or am I missing something?

Any advice on this?

2
  • What does btrfs property get /var/log and btrfs property get /var/log/journal/[email protected] show? Commented Apr 8, 2020 at 13:41
  • @rickhg12hs The first command: ro=false label=, the second didn't output anything Commented Apr 8, 2020 at 13:59

1 Answer 1

1

It seems that the /var/log/journal folder is set as NOCOW (+C), which also disables the compression functionality in BTRFS. You can check it with the command lsattr /var/log.

Since the developers probably enabled it for a good reason, it's best to leave it as it is, especially since SUSE also applies that flag to that (and the whole /var) folder.

See my comment below for the specific details of the +C flag.

5
  • You should really add this information to your original question. Commented Apr 8, 2020 at 17:53
  • If you set the directory to what you want, do you get the compression you are seeking? Is there a reason that directory was set to NOCOW? Commented Apr 8, 2020 at 17:55
  • @rickhg12hs I have to disagree because this is the reason for my issue. Since the +C flag is set, BTRFS can't do its Copy-On-Write (read: compression) magic. journald automatically sets the folder as NOCOW, probably because of its very high write activity, which would have a negative effect on the performance of the BTRFS filesystem. Commented Apr 8, 2020 at 19:36
  • 1
    Good points. They helped me understand that this is an answer, not an elaboration of the question. Perhaps you could further explain your answer so future readers won't need to read the comments here. Commented Apr 9, 2020 at 11:37
  • Since systemd version 246 the journal is compressed by default. So file system compression would only waste CPU because more compression is not possible. Whether anybody would want to disable compression in systemd-journald and have the file system do it I don't know. Don't see an immediate use case for that. Commented Jul 3, 2022 at 12:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.