log2ram: RAM disk for "/var/hdd.log/" too small. Can't sync. (but system is reporting: 4.0K /var/hdd.log) - Pop!_OS 21.04

Hey there, I came across this project today when looking for, well, something that did exactly what this does so I decided to give it a try as this new firewall software I was having a go at seems to write nonstop logs to disk on every network action for every application, it seems. (Portmaster) I figured that instead of subjecting my SSD’s to all those writes constantly, why not log it to ram first, then just dump that in one go.

That said, I installed it, cleaned up my logs a bit before hand to get the size down to a reasonable amount and restarted and went to check if it was running, which was when I saw the message of:

● log2ram.service - Log2Ram
     Loaded: loaded (/etc/systemd/system/log2ram.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2021-07-10 16:08:56 CDT; 19min ago
    Process: 1377 ExecStart=/usr/local/bin/log2ram start (code=exited, status=1/FAILURE)
   Main PID: 1377 (code=exited, status=1/FAILURE)

Jul 10 16:08:56 pop-os log2ram[1377]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Jul 10 16:08:56 pop-os log2ram[1424]: /usr/local/bin/log2ram: 45: mail: not found

I was under the impression that it only dealt with /var/log/*, and I can’t even say I remember seeing /var/hdd.log before either? I tried to take a look in the folder to see if there were files and their size using the line you recommended in the readme, it reported back the following:

zsh: sudo du -hs /var/h* | sort -h | tail -n 3                                                                   mosthated@pop-os
4.0K    /var/hdd.log

I entered the folder and did ls -lah but nothing came back.

Any recommendations on what I might need to check/do? My system is running Pop!_OS 21.04.

Thanks, -MH

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 19 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Followed instructions for installation with apt. I got the same problem on two different pis:

Feb 28 08:20:47 rpi1 log2ram[314]: ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync.
Feb 28 08:20:47 rpi1 log2ram[314]: /usr/local/bin/log2ram: 45: /usr/local/bin/log2ram: mail: not found

strangely, the file is actually very small, which is quite misleading:

$ ll /var/hdd.log/
total 0

increased size to 500MB in conf but same problem. Then noticed that there are two places to set sizes: at the top

# Size for the ram folder, it defines the size the log folder will reserve into the RAM.
# If it's not enough, log2ram will not be able to use ram. Check you /var/log size folder.
# The default is 40M and is basically enough for a lot of applications.
# You will need to increase it if you have a server and a lot of log for example.
SIZE=40M

and at the bottom

LOG_DISK_SIZE=500M

I increased that latter one but that’s about Zram. Increasing the first one made it work for me 😃

May I suggest that the error message is changed to something like

RAM disk is too small, please reduce existing logs and/or increase memory in configuration file.

raspbian buster and bullseye 32bit

Using the official imaging tool, I just installed Raspberry Pi OS Lite 64bit on an RPi 3b and, after updating packages, installed log2ram. I was presented with the same error as noted on this issue:

ERROR: RAM disk for "/var/hdd.log/" too small. Can't sync

I eventually determined it was because /var/log was 41M, slightly too large for the default SIZE=40M. I resolved it editing /etc/log2ram.conf and setting SIZE=80M, and then rebooting.

Strangely, this was not the case when I installed Ubuntu 22.04 LTS on the same device. I guess a fresh install of Raspberry Pi OS tends to log a bit more?

Ok great. And thanks for the hint about Mail, I will change the value in my config file.

It might also be useful to include some instructions and/or links on how to reduce the log size before activating log2ram in the documentation:

something like this:

before activating log2ram with sudo systemctl enable log2ram, you may want to reduce the logsize to 20MB, set the maximum size and disable mail:

  • to disable mail: sudo perl -pe 's/^MAIL=.*$/MAIL=false/g' -i /etc/log2ram.conf
  • to set the maximum log size: sudo perl -pe 's/^#?SystemMaxUse=.*$/SystemMaxUse=20M/g' -i followed by /etc/systemd/journald.conf sudo systemctl restart systemd-journald
  • to force log size reduction: sudo journalctl --vacuum-size=16M

i ran into the same issue and fixed : checking the size of the current log folder du -h /var/log/ | tail -n1

change the config SIZE in /etc/log2ram.conf to something grater than the value of the size of the log folder

restart the service