K
K
K. A.2018-06-09 12:32:06
bash
K. A., 2018-06-09 12:32:06

How to create a folder structure in tmpfs on boot?

Good day.
On the laptop with ubuntu, there is a lamp and the /var/log folder is configured to be mounted as tmpfs, so as not to once again force the SSD disk with Apache logs (they are only needed while I work, so it makes no sense to store them on the disk)
But there was a problem: Apache does not start , until you create the /var/log/apache2 folder and, accordingly, every time you have to create this directory after the system boots and start it manually.
To solve the problem, I created the /etc/rc.local file in which I wrote the following script (found on the open spaces of the tyrnet, adapted to my needs):

#!/bin/sh -e

for d in fsck apt installer upstart dist-upgrade samba unattended-upgrades cups mpd hp lightdm apache2 nginx postfix; do
  [ -d /var/log/$d ] || mkdir /var/log/$d
done

exit 0

But for some reason, when downloading the file does not start. Couldn't find any information on how to make ubuntu execute this file on system boot. I thought there was a problem with the rights, but I wrote mkdir to the home folder - the folder did not appear ..
I also tried to transfer the file to /etc/init.d/rc.local (which also did not exist by default) - the result is the same.
Ubuntu 18.04

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AVKor, 2018-06-09
@AVKor

At the top of a Google search: click .

A
Alexander Karabanov, 2018-06-09
@karabanov

Turn off the logs completely, since they have no value anyway.

P
pfg21, 2018-06-09
@pfg21

create a service for systemd with the launch of entogo script.
prescribe in it a mandatory launch of it before the services waiting for it. those. enter the line
names and the need for services, see in your system.
description https://www.freedesktop.org/software/systemd/man/s...
then enable the service to boot and reboot the system. everything should start automatically.
to enable/disable this service together with the test subjects, add the BindsTo= option,
but you will have to add a script for unmounting the temps and freeing memory.
by the way, as an option, redirect all specified dirs to /run with softlinks and complete the crap cleaning script from the corresponding /run directories.
in general, think / study - options for a wagon and a small cart.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question