azlux / log2ram

ramlog like for systemd (Put log into a ram folder)
MIT License
2.65k stars 195 forks source link

Strange issue where hdd.log is on RAM and not syncing to SD #197

Open eternalliving opened 2 years ago

eternalliving commented 2 years ago

So hopefully I can explain my problem. I have a standard config of log2ram and it all seems to work great... except...

Once the Pi is booted mount and df shows the /var/log mount. I can move large files to it and I know it's on the RAM.

The servive log2ram.service fails to start due to trying to start too early or something, I would have to restart the Pi to get the output. However, I am able to restart it manually and get it running once everything is booted up. However this creates and interesting problem....

I ended up with multiple mounts, one for /var/log and one for /var/hdd.log. Testing whether it's on the SD or in RAM i transfer large files to the folders. When the log2ram service is running both /var/log and /var/hdd.log appear to be on RAM!? When I stop the service, hdd.log acts as though it is actually on the SD, and the timestamps of everything revert to when I first installed log2ram. It seems like log2ram has never been able to sync properly back to hdd.log.

I can attach screenshots if necessary but hopefully the description is enough to get an idea and help me figure out if this is a normal process or log2ram?

eternalliving commented 2 years ago

Having a look through some of the other issues it appears I have a similar problem with log2ram service not being recognized as 'started' at boot. When I start the service it seems to load the hdd.log into RAM as well and then the syncs work fine between the RAM hdd.log and the RAM log, but obviously once I lose power, it reverts back to the SD log.

It seems log2ram is loading at boot but the systemctl status shows it failed (although the mounts are there and they are using the RAM). This then doesn't allow the daily timer to run and so doesn't automatically sync.

Others had mentioned reverting to 1.5.2 and doing a manual install. I'm currently running 1.6, but would prefer to help find a solution moving forward then revert.

azlux commented 1 year ago

Hi, If it's fail, the script didn't finished or have failed (even if the mount point is here). Do you see any error into the journalctl or kernel stating log ? Is the service failed or timeout ?

eternalliving commented 1 year ago

So, when the Pi reboots I get the mount points for log2ram, and I can verify that my log2ram folders are indeed on ram, however, systemctl status shows the service failed (result: timeout) with the only line in the journal as: log2ram.service: Unit cannot be reloaded because it is inactive.

If I start the service with systemctl start log2ram, it works, except it creates mount points for my hdd.log and now my hdd.log is also being stored on ram.

The only thing I seem to be able to do to get log2ram functioning properly is: log2ram stop then systemctl start log2ram This backs up my current log to hdd.log and removes the mount points as you would expect, then is able to start again afresh and it all seems to work as it should.

onlineapps-cloud commented 10 months ago

hi, i have same problem, i installed log2ram on proxmox running on USB flash drive. systemctl status:

systemctl status log2ram
× log2ram.service - Log2Ram
     Loaded: loaded (/etc/systemd/system/log2ram.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-01-16 19:58:21 EET; 15min ago
   Main PID: 646 (code=exited, status=1/FAILURE)
        CPU: 48ms

Jan 16 19:58:21 proxmox2 log2ram[646]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Notice: journal has been rotated since unit was started, output may be incomplete.
root@proxmox2:~# systemctl stop log2ram
root@proxmox2:~# systemctl start log2ram
Job for log2ram.service failed because the control process exited with error code.
See "systemctl status log2ram.service" and "journalctl -xeu log2ram.service" for details.
root@proxmox2:~# systemctl status log2ram.service
× log2ram.service - Log2Ram
     Loaded: loaded (/etc/systemd/system/log2ram.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-01-16 20:14:53 EET; 16s ago
    Process: 7709 ExecStart=/usr/local/bin/log2ram start (code=exited, status=1/FAILURE)
   Main PID: 7709 (code=exited, status=1/FAILURE)
        CPU: 20ms

Jan 16 20:14:53 proxmox2 systemd[1]: Starting log2ram.service - Log2Ram...
Jan 16 20:14:53 proxmox2 log2ram[7709]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Jan 16 20:14:53 proxmox2 systemd[1]: log2ram.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 20:14:53 proxmox2 systemd[1]: log2ram.service: Failed with result 'exit-code'.
Jan 16 20:14:53 proxmox2 systemd[1]: Failed to start log2ram.service - Log2Ram.
root@proxmox2:~# journalctl -xeu log2ram.service
~
~
~
~
~
~
~
~
~
~
~
~
~
Jan 16 19:58:21 proxmox2 log2ram[646]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Jan 16 20:14:53 proxmox2 systemd[1]: Starting log2ram.service - Log2Ram...
░░ Subject: A start job for unit log2ram.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit log2ram.service has begun execution.
░░ 
░░ The job identifier is 2427.
Jan 16 20:14:53 proxmox2 log2ram[7709]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Jan 16 20:14:53 proxmox2 systemd[1]: log2ram.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ An ExecStart= process belonging to unit log2ram.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
Jan 16 20:14:53 proxmox2 systemd[1]: log2ram.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit log2ram.service has entered the 'failed' state with result 'exit-code'.
Jan 16 20:14:53 proxmox2 systemd[1]: Failed to start log2ram.service - Log2Ram.
░░ Subject: A start job for unit log2ram.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit log2ram.service has finished with a failure.
░░ 
░░ The job identifier is 2427 and the job result is failed.

on another proxmox instances where OS is installed on SSD, seems to work as expected. How to fix this error?

onlineapps-cloud commented 10 months ago

upd, i found solution here: https://github.com/azlux/log2ram/issues/163#issuecomment-1043979582