Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log2ram JOURNAL_AWARE=true feature is not able to preserve any journal logs across boot #233

Open
ioogithub opened this issue Sep 14, 2024 · 7 comments

Comments

@ioogithub
Copy link

ioogithub commented Sep 14, 2024

Tested with systemd 255 on ubuntu 24.04 and 22.04 version 1.7.2

Journal logs are not saved and restored after a system reboot.

To test:

  1. Clear the journal with journal --rotate and journalctl --vacuum-time=1s.
  2. Reboot
  3. Run journalctl --list-boots and observe 1 boot entry is recorded.
  4. Reboot
  5. Run journalctl--list-boots and observe only the last 1 entry is recorded. All journal logs before the most recent boot are lost.
  6. Double chech: Run journalctl and observe the log entries start only from the most recent boot.

Journalctl -t log2ram showes rsync copy records from after the boot including /journal/* files but nothing before the boot as those logs are lost.

Is this by design? I can't see log2ram being useful if it wipes out the logs after every reboot. The only change to log2ram was to increase size to 2560M.

It looks like this could be a bug because the log2ram.conf that was installed has double entries for the JOURNAL_AWARE=true setting:

# Should log2ram consider journald and do a log rotate before copying the log files back? Please note that for this
# rsync is mandatory. Also make sure that you have configured SystemMaxUse in journald.conf, because the size of this
# ram folder is will probably not be as large as journald will use by default
JOURNALD_AWARE=true

# Set to 'true' to enable log rotation for journald logs before syncing. 
# Note: 'rsync' must be used for this feature. 
# Ensure 'SystemMaxUse' is configured in 'journald.conf' 
#  - (To limit journald’s disk usage to be smaller than the log2ram RAM allocation).
JOURNALD_AWARE=true

Was this part of the app modified recently? If so it does not work.

@ioogithub
Copy link
Author

Tested a few more times, removed --purged log2ram and reinstalled.

Here is what is happening. After a boot log2ram saves the journal entries from the first boot before it was installed and the last previous boot only. All other journal entries are deleted.

So if I boot 5 times 8n journalctl I would see -1 and 0:

-1 = Boot 1
0 = Boot 5 (the most recent boot).

All entries for boot 2, 3, and 4 are missing.

I can easily troubleshoot what log2ram is doing before the boot because of course all the logs are gone.

Definately not working as expected.

@ioogithub
Copy link
Author

ioogithub commented Sep 14, 2024

I am not sure but I think this could be a similar issue to: #219

Also this issue was closed as being fixed: #222 but it appears to also be similar.

Is log2ram confirmed as not working on ubuntu at all?

@ioogithub ioogithub changed the title All journal logs always lost on reboot on ubuntu 24.04 All journal logs previous to most recent boot are lost on ubuntu Sep 14, 2024
@ioogithub ioogithub changed the title All journal logs previous to most recent boot are lost on ubuntu log2ram is not preserving any logs before most recent boot on ubuntu Sep 14, 2024
@ioogithub ioogithub changed the title log2ram is not preserving any logs before most recent boot on ubuntu log2ram is not preserving any journal logs entries before most recent boot on ubuntu Sep 14, 2024
@ioogithub
Copy link
Author

ioogithub commented Sep 14, 2024

Looking deeper into this it appears that in the /var/log/journal directory the logs are still there but logs from the previous boot are corrupted with a ~ after the filename. So it looks like the problem is indeed this line:

JOURNALD_AWARE=true

log2ram is corrupting the journal when it tries to rotate.

I think it is a similar issue to this which was marked as completed but I think the issue has not been fixed:
#185.

I have tested on two systems ubuntu 22.04 and 24.04, same result. I believe the corrupted journal is why all logs are missing from before a reboot.

@ioogithub ioogithub changed the title log2ram is not preserving any journal logs entries before most recent boot on ubuntu log2ram corrupts the journal when JOURNALD_AWARE=true is set on ubuntu Sep 14, 2024
@ioogithub ioogithub changed the title log2ram corrupts the journal when JOURNALD_AWARE=true is set on ubuntu log2ram corrupts the journal when JOURNALD_AWARE=true is set on ubuntu resulting in all logs before boot missing Sep 14, 2024
@ioogithub
Copy link
Author

Discussion of the specific issue is here: #200

@ioogithub ioogithub changed the title log2ram corrupts the journal when JOURNALD_AWARE=true is set on ubuntu resulting in all logs before boot missing log2ram JOURNAL_AWARE=true feature is not able to preserve any journal logs across boot Sep 14, 2024
@azlux
Copy link
Owner

azlux commented Sep 18, 2024

Hi,

The double JOURNAL_AWARE don't make any issue.
Since it's minor, I didn't release any new version to fix that even if it's already fix into master branch.

The option JOURNALD_AWARE allow log2ram to make a journalctl rotation before sync the /var/log folder : https://github.com/azlux/log2ram/blob/master/log2ram#L29
The code force rsync to include only journals with a @ : https://github.com/azlux/log2ram/blob/master/log2ram#L44

Let's try to investigate in this ticket instead of spreading into multiple issue.

@azlux
Copy link
Owner

azlux commented Sep 18, 2024

I suspect systemd-journald.service starting before finishing the HDD->MEMORY sync.
Can you check that ?
You can get the full starting services order with the command : systemd-analyze plot > stating.svg this generate a big svg file.

@azlux
Copy link
Owner

azlux commented Sep 20, 2024

Can you check also the last commit 83774d4 , it's maybe link to your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants