DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th February 2016
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default /var/log on tmpfs and missing log files

Hello,
I am experimenting with /var/log on tmpfs.
I would like to have this directory in RAM and having it written
to /var/log_backup at shutdown. I have done it putting script
into /etc/rc.shutdown
I know this is not so secure as having this on HDD all time,
but for me probably will be enough. In future maybe I will further
advance setup, add cron job to make backups hourly to HDD
or something.

Problem.
Problem is that after boot I don't have some logs created.
For example there is no /var/log/daemon and it seems
after few minutes of working and issuing command like that:
Code:
rcctl -f start ntpd
to start another daemon, which logs should in the end
go to /var/log/daemon, it is not here.
Actually in /var/log I have only pflog and Xorg.0.log files.
Is there a way configure system to make logs in this setup?
Reply With Quote
  #2   (View Single Post)  
Old 20th February 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

See the -P option of mount_mfs(8). With it, you will be able to pre-populate /var/log into an MFS filesystem at mount time.

An equivalent option does not exist for mount_tmpfs(8), and would require customization of rc(8) since the execution of rc.local(8) does not occur until after logging daemons are started.
Reply With Quote
  #3   (View Single Post)  
Old 20th February 2016
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

I am going to experiment with it in a few days, because I don't have much time today.
Does this -P option can be used via /etc/fstab? Because I mount /var/log via /etc/fstab.
BTW For me it is weird that directory mounted early (I guess this is done early, if mounted by fstab) and log daemon doesn't create new, zero length file and doesn't log into it if it doesn't exist before.
Reply With Quote
  #4   (View Single Post)  
Old 20th February 2016
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

Quote:
Originally Posted by e1-531g View Post
Does this -P option can be used via /etc/fstab?
Yes, see the fstab(5) man page, there is an example of an MFS filesystem using the -s option.
Quote:
...it is weird that directory mounted early (I guess this is done early, if mounted by fstab) and log daemon doesn't create new, zero length file...
syslog(8) doesn't do this. Log files are rotated by newsyslog(8).

You want to create your own, custom logging, in a fashion not intended by the Project's utilities. You're welcome to do so, as long as you are aware that what you want to accomplish is unsupported. You'll need to do this on your own.

Should you decide to customize the rc(8) script, please note that this will be replaced with the Project's standard rc() script after any upgrade.
Reply With Quote
  #5   (View Single Post)  
Old 12th March 2016
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

I have added in /etc/rc one line starting script which
extracts files from tar archive to /var/log mounted as tmpfs filesystem.

Code:
$ grep -B1 'starting early daemons' /etc/rc 
/usr/sbin/wypadkuj_logi
echo -n 'starting early daemons:'
Script contains just this:
Code:
$ cat /usr/sbin/wypadkuj_logi                     
#!/bin/ksh

/bin/tar -xf  /var/log_plik.tar -C /
exit 0
Maybe I will further improve this in future, but it works.

Thanks for help.
Reply With Quote
  #6   (View Single Post)  
Old 28th August 2016
e1-531g e1-531g is offline
ISO Quartermaster
 
Join Date: Mar 2014
Posts: 628
Default

tmpfs has been disabled so I needed to switch to mfs.

Code:
$ grep -B1 'starting early daemons' /etc/rc   
/usr/sbin/wypakuj_logi
echo -n 'starting early daemons:'
$ cat /usr/sbin/wypakuj_logi                                                   
#!/bin/ksh

echo 'Populationg /var/log'
cd /
list_of_files=$(tar -ztf /var/sysmerge/etc.tgz  | grep ^\./var/log)
tar -zxvf /var/sysmerge/etc.tgz ${list_of_files}
Code:
$ grep mfs /etc/fstab | grep 'var/log'   
swap               /var/log  mfs rw,-s=40960,nosuid,nodev 0 0
__________________
Signature: Furthermore, I consider that systemd must be destroyed.
Based on Latin oratorical phrase
Reply With Quote
Reply

Tags
/var, /var/log, log, logs, tmpfs

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
tmpfs on OpenBSD tmpusr OpenBSD General 4 12th August 2016 08:42 PM
OpenBSD tmpfs Enabled in -current J65nko News 0 17th December 2013 02:38 PM
Running system in tmpfs or with readonly root ragnvaldf OpenBSD General 2 4th March 2012 08:32 PM
DragonFly BSD Update on tmpfs and swapcache work (in master) J65nko News 1 22nd February 2010 01:32 AM
sys.tar.gz missing from 3rd CD in 4.5? thirdm OpenBSD Installation and Upgrading 0 5th May 2009 03:25 PM


All times are GMT. The time now is 03:55 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick