2 2
Isaac

How can I set log2ram never to write to the disk?

Recommended Posts

Hi,

 

I'd like to setup log2ram so that it never writes to the disk, but rather discards all logs at shutdown. The documentation for log2ram says that if I delete /etc/cron.daily/log2ram it will only sync the logs to the disk at shutdown. But is there a way to have it not even do that?

 

Also, in order to prevent log2ram from filling up all its space in RAM, is it possible to setup an overwrite mechanism so that the logs begin overwriting themselves once they hit the space limit?

Share this post


Link to post
Share on other sites

Check out line 3

3. If you don't need detailed archived logging. You can protect your sdcard from hourly writes by telling log2ram to not write syslog and kern.log to disk. As a bonus at boot your ramdisk will not be filling with previous session's logs.

 

on This Post

 

Not quite what you're looking for but it might give a hint?

Share this post


Link to post
Share on other sites
(edited)

I see. He says to insert a clause into those lines to exclude certain files. Are you hinting that if I take out those rsync lines all together it will never sync to the disk at all (but otherwise function properly)?

 

Also, regarding RAM filling up, deleting the logs between sessions would normally do the trick, but I'm trying to prevent a situation where I'd keep a computer logged in for a long time or do something that results in lots of messages being written to the logs and the RAM disk would fill up.

Edited by Isaac

Share this post


Link to post
Share on other sites

I was thinking that some of the syntax may lead you to discover your own solution.  Looks like there has been some other discussion on the topic on this forum but I'm still exercising my forum search skills ;] 

 

I'm sure you've studied all the code in the reference but it looks like you can change the amount of memory and file size. 

 

Quote

I see. He says to insert a clause into those lines to exclude certain files. Are you hinting that if I take out those rsync lines all together it will never sync to the disk at all (but otherwise function properly)?

 

I didn't think of that but why not see what happens? You DO have a test unit, don't you?? ;]

 

You might want to see what rsync is doing, what the aXWv switches do ...

 

 

Share this post


Link to post
Share on other sites
(edited)

Alright, I got it, thank you! I commented out all the lines in the syncToDisk function (in log2ram code) and replaced them with one "echo "Ok"" (since it was giving me some strange error when I left it all blank). It works like magic! I now modified the log2ram code to give the user an option in the configuration file to do this (i.e. to never write the logs back to the disk). We'll see if he accepts my pull request.

 

Regarding the other issue, logrotate could rotate the logs in the /var/log tmpfs partition in RAM, so that if the computer is running for many days straight, the 40 MB partition shouldn't fill (note: under my arrangement, when the computer reboots /var/log empties anyway - with the exception of the boot log). If it does fill, I could always set logrotate to run more frequently or save fewer logs.

 

Thanks again!

Isaac

Edited by Isaac

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
2 2