/tmp에 대한 systemd의 tmpfs 자동 마운트를 비활성화/재정의하는 방법은 무엇입니까?

/tmp에 대한 systemd의 tmpfs 자동 마운트를 비활성화/재정의하는 방법은 무엇입니까?

배경:내 시스템에서 /tmp이것은 파티셔닝의 일반적인 부분 /이며 시스템의 일부 중요한 기능에 사용합니다.

현재 systemd접근 방식:새 시스템에서 systemd, 특히 시작 시 또는 업데이트 중에 인계 설치가 시작되었습니다 tmpfs. /tmp이 위치는 다음과 같습니다 /usr/lib/systemd/system/tmp.mount.

/usr/lib/systemd/system/tmp.mount
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Temporary Directory (/tmp)
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,size=50%,nr_inodes=400k

질문:몇 달 전, 업데이트 중에 중요한 파일이 /tmp사라졌기 때문에 일부 실행 중인 프로세스에서 오류 메시지를 쓰기 시작했습니다. systemd실행 중인 시스템에서 업데이트하는 경우에도 tmpfs기존 시스템 위에 강제로 설치 /tmp될 수 없었습니다(" 파일 시스템이 사용 중입니다."). 이로 인해 문제가 발생합니다.

부분 수정:위에 제공된 파일의 마지막 5줄을 주석 처리하여 문제를 해결했습니다. 또한 업데이트할 때마다 사용자 정의 내용이 손실됩니다 /usr/lib/systemd/system/local-fs.target.wants/tmp.mount. systemd두 파일 모두 구성 파일이 아닙니다( wanted파일은 플래그여야 함). 경고 없이 교체됩니다.

질문: 임시(또는 모든) 파일 시스템의 마운트를 영구적으로 비활성화하는 방법은 무엇입니까 /tmp? systemd옵션이 누락된 것이 아닐까요 ? systemd업그레이드 후에도 지속되는 솔루션을 찾고 있습니다 .

설명서와 링크된 문서를 확인했지만 아무 효과가 없었습니다. 나도 시도했다

chattr +i /usr/lib/systemd/system/tmp.mount

조정된 파일에 있지만 systemd전혀 업데이트되지 않습니다. 이는 확실히 옵션이 아닙니다.

답변1

나는 이것이 systemctl mask tmp.mount당신에게 도움이 될 것이라고 생각합니다. 이것은 장치를 비활성화하고 /dev/null에서 심볼릭 링크하여 /etc업그레이드 시 다시 활성화되는 것을 방지합니다. 또한 장치의 수동 부팅을 방지합니다.

# systemctl mask tmp.mount
Created symlink /etc/systemd/system/tmp.mount → /dev/null.

관련 정보