Directory tmpfiles.d: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
(Created page with "== Overview == tmpfiles.d 디렉토리 내용 정리. == Basic == tmpfiles.d 디렉토리의 설정 파일들은 tmpfs 의 임시 파일들을 관리한다. <pre> df -h File...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:


== Basic ==
== Basic ==
tmpfiles.d 디렉토리의 설정 파일들은 tmpfs 의 임시 파일들을 관리한다.
Configuration for creation, deletion and cleaning of volatile and temporary files.
<pre>
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf
</pre>
 
systemd-tmpfiles uses the configuration files from the above directories to describe the creation, cleaning and removal of volatile and temporary files and directories which usually reside in directories such as /run or /tmp.
 
Volatile and temporary files and directories are those located in /run (and its alias /var/run), /tmp, /var/tmp, the API file systems such as /sys or /proc, as well as some other directories below /var.
 
System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory if this is feasible.
<pre>
<pre>
  df -h
  df -h
Line 15: Line 26:
</pre>
</pre>


tmpfiles.d 디렉토리의 설정 파일들은 tmpfs 및 temporary directory 의 임시 파일들을 관리한다. 대부분은 문제가 없으나, 만약 특정 프로세스들을 시스템 시작시 자동 시작하게 설정했을 경우, tmpfs 와 관련해서 문제가 발생하는 경우가 있다.
예를 들면, Asterisk 의 경우, 프로세스가 시작하게 되면 /var/run/asterisk 디렉토리에 소켓 파일을 생성하고, 이후에 asterisk -r 명령을 사용할 때 이 소켓 파일을 이용하는데, 시스템 시작시에 자동으로 동작하도록 설정할 경우, 이 파일들을 생성하는데 문제가 발생하게 되기 때문이다.
<pre>
$ ls -tlr /var/run/asterisk/
total 4
-rw-r--r-- 1 asterisk asterisk 5 Jun 21 08:51 asterisk.pid
srwxr-xr-x 1 asterisk asterisk 0 Jun 21 08:51 asterisk.ctl
</pre>
이를 해결하기 위해서는 다음과 같은 tmpfile 을 생성해주면 된다.
<pre>
#Type Path        Mode UID  GID  Age Argument
d    /var/run/asterisk  0755 asterisk asterisk - -
</pre>
== Configuration format ==
<pre>
#Type Path        Mode UID  GID  Age Argument
d    /run/user  0755 root root 10d -
L    /tmp/foobar -    -    -    -  /dev/null
</pre>


== Reference ==
* https://manpages.debian.org/jessie/systemd/tmpfiles.d.5.en.html


[[category:system]]
[[category:system]]

Latest revision as of 09:18, 5 July 2019

Overview

tmpfiles.d 디렉토리 내용 정리.

Basic

Configuration for creation, deletion and cleaning of volatile and temporary files.

/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf

systemd-tmpfiles uses the configuration files from the above directories to describe the creation, cleaning and removal of volatile and temporary files and directories which usually reside in directories such as /run or /tmp.

Volatile and temporary files and directories are those located in /run (and its alias /var/run), /tmp, /var/tmp, the API file systems such as /sys or /proc, as well as some other directories below /var.

System daemons frequently require private runtime directories below /run to place communication sockets and similar in. For these, consider declaring them in their unit files using RuntimeDirectory if this is feasible.

 df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.7G     0  3.7G   0% /dev
tmpfs           749M   76M  673M  11% /run
/dev/sda1       9.8G  8.5G  868M  91% /
tmpfs           3.7G     0  3.7G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.7G     0  3.7G   0% /sys/fs/cgroup

tmpfiles.d 디렉토리의 설정 파일들은 tmpfs 및 temporary directory 의 임시 파일들을 관리한다. 대부분은 문제가 없으나, 만약 특정 프로세스들을 시스템 시작시 자동 시작하게 설정했을 경우, tmpfs 와 관련해서 문제가 발생하는 경우가 있다.

예를 들면, Asterisk 의 경우, 프로세스가 시작하게 되면 /var/run/asterisk 디렉토리에 소켓 파일을 생성하고, 이후에 asterisk -r 명령을 사용할 때 이 소켓 파일을 이용하는데, 시스템 시작시에 자동으로 동작하도록 설정할 경우, 이 파일들을 생성하는데 문제가 발생하게 되기 때문이다.

$ ls -tlr /var/run/asterisk/
total 4
-rw-r--r-- 1 asterisk asterisk 5 Jun 21 08:51 asterisk.pid
srwxr-xr-x 1 asterisk asterisk 0 Jun 21 08:51 asterisk.ctl

이를 해결하기 위해서는 다음과 같은 tmpfile 을 생성해주면 된다.

#Type Path        Mode UID  GID  Age Argument
d    /var/run/asterisk   0755 asterisk asterisk - -

Configuration format

#Type Path        Mode UID  GID  Age Argument
d    /run/user   0755 root root 10d -
L    /tmp/foobar -    -    -    -   /dev/null

Reference