fstab entry for logging into tmpfs

Ask questions about Arch Linux ARM. Please search before making a new topic.

fstab entry for logging into tmpfs

Postby blinch » Sat Jul 25, 2015 11:42 am

Hello Everyone!

To prevent unneccessary read/write cycles of my system, I would like to mount /var/log into a ramdisk.
Finally I accomplished that without letting the start of sshd failing and keeping me out of my own system.
But when I write the line concerning "/var/log" into my fstab as shown below, then my httpd (apache installed with php5 to run a dokuwiki) fails to start.
What am I doing wrong? what mount options did I forget? I tried so many options of mount man page and so many I searched on the internet.
I even tried the GID und UID 33 of http.

$this->bbcode_second_pass_code('', '
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat defaults 0 0
tmpfs /var/tmp tmpfs user,rw,size=50M 0 0
')

output of "systemctl status httpd -l":

$this->bbcode_second_pass_code('', '
* httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2015-07-24 18:36:51 UTC; 1min 6s ago
Process: 235 ExecStart=/usr/bin/apachectl start (code=exited, status=1/FAILURE)
')
Thank You for your help!

PS: System is a Raspberry Pi with Arch Linux 4.0.8-3
blinch
 
Posts: 3
Joined: Sat Jul 25, 2015 10:03 am

Re: fstab entry for logging into tmpfs

Postby tinx » Tue Jul 28, 2015 1:22 pm

Hi blinch, I would restrain from mounting /var/log with option 'user' as it is a system directory. Your fstab entry should work if it looked like the following:

$this->bbcode_second_pass_code('', '# Use RAM disk for /var/log
tmpfs /var/log tmpfs nodev,nosuid,noexec,relatime,size=50M 0 0')


Kind regards,

tinx

P.S.:
However, journald will NOT put it's entries there after changing the configuration as suggested above. You can set it's maximum size by adapting /etc/systemd/journald.conf accordingly. Refer to Archlinux Wiki and/or `man journald.conf` for further info.

https://wiki.archlinux.org/index.php/Systemd#Journal
$this->bbcode_second_pass_quote('', 'I')n Arch Linux, the directory /var/log/journal/ is a part of the systemd package, and the journal (when Storage= is set to auto in /etc/systemd/journald.conf) will write to /var/log/journal/. If you or some program delete that directory, systemd will not recreate it automatically and instead will write its logs to /run/systemd/journal in a nonpersistent way. However, the folder will be recreated when you set Storage=persistent and run systemctl restart systemd-journald (or reboot).
tinx
 
Posts: 9
Joined: Thu Apr 02, 2015 4:01 pm

Re: fstab entry for logging into tmpfs

Postby blinch » Tue Jul 28, 2015 5:46 pm

Thank you so much for your help tinx!!!

Now my fstab looks like:

$this->bbcode_second_pass_code('', '
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat defaults 0 0
tmpfs /var/log tmpfs nodev,nosuid,noexec,relatime,size=50M 0 0
')

I have set "Storage=auto" in journald.conf and I have set:
SystemMaxFileSize=10M
RuntimeMaxFileSize=10M

I can boot, i am not locked out, I can connect via SSH. But my httpd still fails to start.

When I type "apachectl start", it fails too:
(2)No such file or directory: AH02291: Cannot access directory '/var/log/httpd/' for main error log
AH00014: Configuration check failed

So I tried the ugly noob way and created the missing directory.
Now I can start apache and now I can start httpd manually.


So this is working for me. I do not reboot often. Systemd and Journal are on top of my "read into" list.
It is not working flawlessly, but again: Thank you so much tinx!
blinch
 
Posts: 3
Joined: Sat Jul 25, 2015 10:03 am

Re: fstab entry for logging into tmpfs

Postby WarheadsSE » Tue Jul 28, 2015 6:02 pm

What you probably want is a tmpfiles.d entry that makes the necessary directories.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: fstab entry for logging into tmpfs

Postby blinch » Tue Jul 28, 2015 6:09 pm

generally speaking, I want to minimize some unnecessary write cycles to my SD-Card. My Pi is running 24/7...
blinch
 
Posts: 3
Joined: Sat Jul 25, 2015 10:03 am

Re: fstab entry for logging into tmpfs

Postby tinx » Wed Jul 29, 2015 12:51 pm

What WarheadsSE suggested is creating a configuration in /etc/tmpfiles.d/ that will create the missing directory in the fresh ramdisk so that your httpd will find it's log dir.

It's a neat solution I haven't needed or tried yet. You can create a file e.g. /etc/tmpfiles.d/httpd-log.conf containing a 'd' entry for /var/log/httpd/. Please check `man tmpfiles.d` for the exact syntax.

$this->bbcode_second_pass_quote('', 'd')
Create a directory if it does not exist yet.
tinx
 
Posts: 9
Joined: Thu Apr 02, 2015 4:01 pm


Return to User Questions

Who is online

Users browsing this forum: No registered users and 38 guests