옵션 1: 서비스를 영구적으로 변경

옵션 1: 서비스를 영구적으로 변경

a예를 들어 대용량 중간 파일을 생성한 /tmp/aoutput다음 b해당 파일을 읽고 추가 작업을 수행하는 두 단계로 구성된 긴 프로세스를 실행한다고 가정해 보겠습니다 .

이제 이 단계를 실행하는 동안 시스템이 b충돌합니다. 어떻게 든 시스템을 재부팅 할 수 있습니까?아니요먼저 완전히 실행하지 않고도 /tmp즉시 재부팅할 수 있도록 제거할 항목(일반적으로 부팅 시 발생)은 무엇입니까 ?ba

물론 /tmp이것은 tmpfs.

HDD/SSD를 물리적으로 제거하거나 라이브 USB 미디어에서 부팅하는 솔루션을 제외하고 싶습니다. 현재 저의 구체적인 경우에는 실제로 전체 디스크 암호화 기능을 갖춘 SSD이지만 암호화되지 않은 드라이브에서만 작동하는 솔루션에도 관심이 있습니다.


편집하다현재로서는 질문이 남아 있습니다. 어느 대답도 라이브 미디어나 사전 구성 조정 없이 작동하는 솔루션을 제공하지 않기 때문입니다. 아마도 다른 방법이 없을 수도 있지만 이상해 보입니다. GRUB은 이미 Linux를 부팅하기 위해 파티션을 마운트하지 않습니까? 그렇다면 파일을 수동으로 이동할 수 있는 방법이 있나요?앞으로출시된 적이 있나요 systemd? 아마도 제가 틀렸을 수도 있고 부트로더에 대해 잘 알지도 못하지만 왜 이것이 가능하지 않은지 듣고 싶습니다.


systemd구성 정보:

$ grep -s . /*/tmpfiles.d/*.conf /*/*/tmpfiles.d/*.conf
/run/tmpfiles.d/kmod.conf:c! /dev/fuse 0600 - - - 10:229
/run/tmpfiles.d/kmod.conf:c! /dev/cuse 0600 - - - 10:203
/run/tmpfiles.d/kmod.conf:c! /dev/btrfs-control 0600 - - - 10:234
/run/tmpfiles.d/kmod.conf:d /dev/net 0755 - - -
/run/tmpfiles.d/kmod.conf:c! /dev/net/tun 0600 - - - 10:200
/run/tmpfiles.d/kmod.conf:c! /dev/ppp 0600 - - - 108:0
/run/tmpfiles.d/kmod.conf:c! /dev/uinput 0600 - - - 10:223
/run/tmpfiles.d/kmod.conf:d /dev/mapper 0755 - - -
/run/tmpfiles.d/kmod.conf:c! /dev/mapper/control 0600 - - - 10:236
/run/tmpfiles.d/kmod.conf:c! /dev/uhid 0600 - - - 10:239
/run/tmpfiles.d/kmod.conf:c! /dev/vhci 0600 - - - 10:137
/run/tmpfiles.d/kmod.conf:d /dev/snd 0755 - - -
/run/tmpfiles.d/kmod.conf:c! /dev/snd/timer 0600 - - - 116:33
/run/tmpfiles.d/kmod.conf:d /dev/snd 0755 - - -
/run/tmpfiles.d/kmod.conf:c! /dev/snd/seq 0600 - - - 116:1
/usr/lib/tmpfiles.d/00rsyslog.conf:# Override systemd's default tmpfiles.d/var.conf to make /var/log writable by
/usr/lib/tmpfiles.d/00rsyslog.conf:# the syslog group, so that rsyslog can run as user.
/usr/lib/tmpfiles.d/00rsyslog.conf:# See tmpfiles.d(5) for details.
/usr/lib/tmpfiles.d/00rsyslog.conf:# Type Path    Mode UID  GID  Age Argument
/usr/lib/tmpfiles.d/00rsyslog.conf:d /var/log 0775 root syslog -
/usr/lib/tmpfiles.d/dbus.conf:# Type Path                     Mode    UID     GID     Age     Argument
/usr/lib/tmpfiles.d/dbus.conf:L /var/lib/dbus/machine-id      -       -       -       -       /etc/machine-id
/usr/lib/tmpfiles.d/debian.conf:#  This file is part of the debianisation of systemd.
/usr/lib/tmpfiles.d/debian.conf:#
/usr/lib/tmpfiles.d/debian.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/debian.conf:#  under the terms of the GNU General Public License as published by
/usr/lib/tmpfiles.d/debian.conf:#  the Free Software Foundation; either version 2 of the License, or
/usr/lib/tmpfiles.d/debian.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/debian.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/debian.conf:# Type Path    Mode UID  GID  Age Argument
/usr/lib/tmpfiles.d/debian.conf:L /run/initctl -    -    -    -   /run/systemd/initctl/fifo
/usr/lib/tmpfiles.d/debian.conf:L /run/shm     -    -    -    -   /dev/shm
/usr/lib/tmpfiles.d/debian.conf:d /run/sendsigs.omit.d 0755 root root -
/usr/lib/tmpfiles.d/debian.conf:L+ /etc/mtab   -    -    -    -  ../proc/self/mounts
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# This is a systemd tmpfiles.d configuration file
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:#
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# tmpfiles.d defaults are set to clean /run/user every now and then
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# which includes our gvfs-fuse mount being mounted in /run/user/<id>/gvfs
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:#
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# This file adds an exclusion rule so that user data don't get automatically
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# cleaned up (i.e. destroyed).
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:#
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# Due to our fuse mount restrictions root can't access nor stat the mountpoint
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# resulting in warning spitted out by the systemd-tmpfiles process. Please
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# ignore it for the time being until proper solution is found:
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:# https://bugzilla.gnome.org/show_bug.cgi?id=560658
/usr/lib/tmpfiles.d/gvfsd-fuse-tmpfiles.conf:x /run/user/*/gvfs
/usr/lib/tmpfiles.d/home.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/home.conf:#
/usr/lib/tmpfiles.d/home.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/home.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/home.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/home.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/home.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/home.conf:Q /home 0755 - - -
/usr/lib/tmpfiles.d/home.conf:q /srv 0755 - - -
/usr/lib/tmpfiles.d/journal-nocow.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/journal-nocow.conf:#
/usr/lib/tmpfiles.d/journal-nocow.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/journal-nocow.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/journal-nocow.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/journal-nocow.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/journal-nocow.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/journal-nocow.conf:# Set the NOCOW attribute for directories of journal files. This flag
/usr/lib/tmpfiles.d/journal-nocow.conf:# is inheredited by their new files and sub-directories. Matters only
/usr/lib/tmpfiles.d/journal-nocow.conf:# for btrfs filesystems.
/usr/lib/tmpfiles.d/journal-nocow.conf:#
/usr/lib/tmpfiles.d/journal-nocow.conf:# WARNING: Enabling the NOCOW attribute improves journal performance
/usr/lib/tmpfiles.d/journal-nocow.conf:#     substantially, but also disables the btrfs checksum logic. In
/usr/lib/tmpfiles.d/journal-nocow.conf:#     btrfs RAID filesystems the checksums are needed for rebuilding
/usr/lib/tmpfiles.d/journal-nocow.conf:#     corrupted files. Without checksums such rebuilds are not
/usr/lib/tmpfiles.d/journal-nocow.conf:#     possible.
/usr/lib/tmpfiles.d/journal-nocow.conf:#
/usr/lib/tmpfiles.d/journal-nocow.conf:# In a single-disk filesystem (or a filesystem without redundancy)
/usr/lib/tmpfiles.d/journal-nocow.conf:# enabling the NOCOW attribute for journal files is safe, because
/usr/lib/tmpfiles.d/journal-nocow.conf:# they have their own checksums and a rebuilding wouldn't be possible
/usr/lib/tmpfiles.d/journal-nocow.conf:# in any case.
/usr/lib/tmpfiles.d/journal-nocow.conf:h /var/log/journal - - - - +C
/usr/lib/tmpfiles.d/journal-nocow.conf:h /var/log/journal/%m - - - - +C
/usr/lib/tmpfiles.d/journal-nocow.conf:h /var/log/journal/remote - - - - +C
/usr/lib/tmpfiles.d/legacy.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/legacy.conf:#
/usr/lib/tmpfiles.d/legacy.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/legacy.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/legacy.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/legacy.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/legacy.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/legacy.conf:# These files are considered legacy and are unnecessary on legacy-free
/usr/lib/tmpfiles.d/legacy.conf:# systems.
/usr/lib/tmpfiles.d/legacy.conf:L /var/lock - - - - ../run/lock
/usr/lib/tmpfiles.d/legacy.conf:# /run/lock/subsys is used for serializing SysV service execution, and
/usr/lib/tmpfiles.d/legacy.conf:# hence without use on SysV-less systems.
/usr/lib/tmpfiles.d/legacy.conf:d /run/lock/subsys 0755 root root -
/usr/lib/tmpfiles.d/legacy.conf:# /forcefsck, /fastboot and /forcequotacheck are deprecated in favor of the
/usr/lib/tmpfiles.d/legacy.conf:# kernel command line options 'fsck.mode=force', 'fsck.mode=skip' and
/usr/lib/tmpfiles.d/legacy.conf:# 'quotacheck.mode=force'
/usr/lib/tmpfiles.d/legacy.conf:r! /forcefsck
/usr/lib/tmpfiles.d/legacy.conf:r! /fastboot
/usr/lib/tmpfiles.d/legacy.conf:r! /forcequotacheck
/usr/lib/tmpfiles.d/man-db.conf:d /var/cache/man 2755 man root 1w
/usr/lib/tmpfiles.d/passwd.conf:# If a password operation is in progress and we lose power, stale lockfiles
/usr/lib/tmpfiles.d/passwd.conf:# can be left behind.  Clear them on boot.
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/gshadow.lock
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/shadow.lock
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/passwd.lock
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/group.lock
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/subuid.lock
/usr/lib/tmpfiles.d/passwd.conf:r! /etc/subgid.lock
/usr/lib/tmpfiles.d/samba.conf:d /run/samba 0755 root root -
/usr/lib/tmpfiles.d/sshd.conf:d /var/run/sshd 0755 root root
/usr/lib/tmpfiles.d/sudo.conf:# Create an empty sudo time stamp directory on OSes using systemd.
/usr/lib/tmpfiles.d/sudo.conf:# Sudo will create the directory itself but this can cause problems
/usr/lib/tmpfiles.d/sudo.conf:# on systems that have SELinux enabled since the directories will be
/usr/lib/tmpfiles.d/sudo.conf:# created with the user's security context.
/usr/lib/tmpfiles.d/sudo.conf:d /var/run/sudo 0711 root root
/usr/lib/tmpfiles.d/sudo.conf:D /var/run/sudo/ts 0700 root root
/usr/lib/tmpfiles.d/systemd.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/systemd.conf:#
/usr/lib/tmpfiles.d/systemd.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/systemd.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/systemd.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/systemd.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/systemd.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/systemd.conf:d /run/user 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:F! /run/utmp 0664 root utmp -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/ask-password 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/seats 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/sessions 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/users 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/machines 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/shutdown 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/netif 0755 systemd-network systemd-network -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/netif/links 0755 systemd-network systemd-network -
/usr/lib/tmpfiles.d/systemd.conf:d /run/systemd/netif/leases 0755 systemd-network systemd-network -
/usr/lib/tmpfiles.d/systemd.conf:d /run/log 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:z /run/log/journal 2755 root systemd-journal - -
/usr/lib/tmpfiles.d/systemd.conf:Z /run/log/journal/%m ~2750 root systemd-journal - -
/usr/lib/tmpfiles.d/systemd.conf:a+ /run/log/journal/%m - - - - d:group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:A+ /run/log/journal/%m - - - - group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:z /var/log/journal 2755 root systemd-journal - -
/usr/lib/tmpfiles.d/systemd.conf:z /var/log/journal/%m 2755 root systemd-journal - -
/usr/lib/tmpfiles.d/systemd.conf:z /var/log/journal/%m/system.journal 0640 root systemd-journal - -
/usr/lib/tmpfiles.d/systemd.conf:a+ /var/log/journal    - - - - d:group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:a+ /var/log/journal    - - - - group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:a+ /var/log/journal/%m - - - - d:group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:a+ /var/log/journal/%m - - - - group:adm:r-x
/usr/lib/tmpfiles.d/systemd.conf:a+ /var/log/journal/%m/system.journal - - - - group:adm:r--
/usr/lib/tmpfiles.d/systemd.conf:d /var/lib/systemd 0755 root root -
/usr/lib/tmpfiles.d/systemd.conf:d /var/lib/systemd/coredump 0755 root root 3d
/usr/lib/tmpfiles.d/systemd-nologin.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/systemd-nologin.conf:#
/usr/lib/tmpfiles.d/systemd-nologin.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/systemd-nologin.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/systemd-nologin.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/systemd-nologin.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/systemd-nologin.conf:# See tmpfiles.d(5), systemd-user-session.service(5) and pam_nologin(8).
/usr/lib/tmpfiles.d/systemd-nologin.conf:# This file has special suffix so it is not run by mistake.
/usr/lib/tmpfiles.d/systemd-nologin.conf:F! /run/nologin 0644 - - - "System is booting up. See pam_nologin(8)"
/usr/lib/tmpfiles.d/tmp.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/tmp.conf:#
/usr/lib/tmpfiles.d/tmp.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/tmp.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/tmp.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/tmp.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/tmp.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/tmp.conf:# Clear tmp directories separately, to make them easier to override
/usr/lib/tmpfiles.d/tmp.conf:D /tmp 1777 root root -
/usr/lib/tmpfiles.d/tmp.conf:#q /var/tmp 1777 root root 30d
/usr/lib/tmpfiles.d/tmp.conf:# Exclude namespace mountpoints created with PrivateTmp=yes
/usr/lib/tmpfiles.d/tmp.conf:x /tmp/systemd-private-%b-*
/usr/lib/tmpfiles.d/tmp.conf:X /tmp/systemd-private-%b-*/tmp
/usr/lib/tmpfiles.d/tmp.conf:x /var/tmp/systemd-private-%b-*
/usr/lib/tmpfiles.d/tmp.conf:X /var/tmp/systemd-private-%b-*/tmp
/usr/lib/tmpfiles.d/var.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/var.conf:#
/usr/lib/tmpfiles.d/var.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/var.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/var.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/var.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/var.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/var.conf:q /var 0755 - - -
/usr/lib/tmpfiles.d/var.conf:L /var/run - - - - ../run
/usr/lib/tmpfiles.d/var.conf:d /var/log 0755 - - -
/usr/lib/tmpfiles.d/var.conf:f /var/log/wtmp 0664 root utmp -
/usr/lib/tmpfiles.d/var.conf:f /var/log/btmp 0600 root utmp -
/usr/lib/tmpfiles.d/var.conf:d /var/cache 0755 - - -
/usr/lib/tmpfiles.d/var.conf:d /var/lib 0755 - - -
/usr/lib/tmpfiles.d/var.conf:d /var/spool 0755 - - -
/usr/lib/tmpfiles.d/x11.conf:#  This file is part of systemd.
/usr/lib/tmpfiles.d/x11.conf:#
/usr/lib/tmpfiles.d/x11.conf:#  systemd is free software; you can redistribute it and/or modify it
/usr/lib/tmpfiles.d/x11.conf:#  under the terms of the GNU Lesser General Public License as published by
/usr/lib/tmpfiles.d/x11.conf:#  the Free Software Foundation; either version 2.1 of the License, or
/usr/lib/tmpfiles.d/x11.conf:#  (at your option) any later version.
/usr/lib/tmpfiles.d/x11.conf:# See tmpfiles.d(5) for details
/usr/lib/tmpfiles.d/x11.conf:# Make sure these are created by default so that nobody else can
/usr/lib/tmpfiles.d/x11.conf:d /tmp/.X11-unix 1777 root root 10d
/usr/lib/tmpfiles.d/x11.conf:d /tmp/.ICE-unix 1777 root root 10d
/usr/lib/tmpfiles.d/x11.conf:d /tmp/.XIM-unix 1777 root root 10d
/usr/lib/tmpfiles.d/x11.conf:d /tmp/.font-unix 1777 root root 10d
/usr/lib/tmpfiles.d/x11.conf:d /tmp/.Test-unix 1777 root root 10d
/usr/lib/tmpfiles.d/x11.conf:# Unlink the X11 lock files
/usr/lib/tmpfiles.d/x11.conf:r! /tmp/.X[0-9]*-lock
/var/run/tmpfiles.d/kmod.conf:c! /dev/fuse 0600 - - - 10:229
/var/run/tmpfiles.d/kmod.conf:c! /dev/cuse 0600 - - - 10:203
/var/run/tmpfiles.d/kmod.conf:c! /dev/btrfs-control 0600 - - - 10:234
/var/run/tmpfiles.d/kmod.conf:d /dev/net 0755 - - -
/var/run/tmpfiles.d/kmod.conf:c! /dev/net/tun 0600 - - - 10:200
/var/run/tmpfiles.d/kmod.conf:c! /dev/ppp 0600 - - - 108:0
/var/run/tmpfiles.d/kmod.conf:c! /dev/uinput 0600 - - - 10:223
/var/run/tmpfiles.d/kmod.conf:d /dev/mapper 0755 - - -
/var/run/tmpfiles.d/kmod.conf:c! /dev/mapper/control 0600 - - - 10:236
/var/run/tmpfiles.d/kmod.conf:c! /dev/uhid 0600 - - - 10:239
/var/run/tmpfiles.d/kmod.conf:c! /dev/vhci 0600 - - - 10:137
/var/run/tmpfiles.d/kmod.conf:d /dev/snd 0755 - - -
/var/run/tmpfiles.d/kmod.conf:c! /dev/snd/timer 0600 - - - 116:33
/var/run/tmpfiles.d/kmod.conf:d /dev/snd 0755 - - -
/var/run/tmpfiles.d/kmod.conf:c! /dev/snd/seq 0600 - - - 116:1

답변1

간단히 말해서:방금 충돌이 발생한 경우 라이브 미디어를 사용하십시오. 그렇지 않으면 파일을 /usr/lib/tmpfiles.d/tmp.conf복사 하고 변경하여 /etc/tmpfiles.d/tmp.conf시스템을 구성하십시오 etc.

-D /tmp 1777 root root -
+d /tmp 1777 root root 1s
+x /tmp/*output

파일이 특정 패턴을 따르지 않으면 대신 다음 설정을 사용하세요.

-D /tmp 1777 root root -
+d /tmp 1777 root root 12h

이제 이 단계를 실행하는 동안 시스템이 b충돌합니다. b먼저 완전히 실행하지 않고도 즉시 재부팅할 수 있도록 /tmp의 내용(일반적으로 부팅 시 발생)을 삭제하지 않는 방식으로 시스템을 재부팅할 수 있습니까 ?

글쎄요, 시스템을 구성할 수 있다면앞으로충돌이 발생합니다. 이때 시스템이 충돌한 경우~ 해야 하다모든 공통 systemd.target( rescue, , ) multi-user에는 graphical임시 파일 삭제도 포함되므로 라이브 미디어를 사용하세요 rescue.target.

즉, 다음 붕괴에 대비하기 위해 우리는 귀하의 tmpfiles행동을 바꿀 수 있습니다. 대부분의 데비안 파생물은 /tmpin 의 동작을 정의합니다 /usr/lib/tmpfiles.d/tmp.conf:

$ cat /usr/lib/tmpfiles.d/tmp.conf
#  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.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
D /tmp 1777 root root -
#q /var/tmp 1777 root root 30d

# Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*
X /tmp/systemd-private-%b-*/tmp
x /var/tmp/systemd-private-%b-*
X /var/tmp/systemd-private-%b-*/tmp

# Remove top-level private temporary directories on each boot
R! /tmp/systemd-private-*
R! /var/tmp/systemd-private-*

청소를 담당하는 라인은

D /tmp 1777 root root -

에 따르면 tmpfiles.d(5)대문자는 D해당 디렉토리를 삭제해야 함을 나타냅니다 systemd-tmpfiles --remove. 불행히도 이 명령은 다음과 같은 이유로 거의 모든 대상에서 실행됩니다 systemd-tmpfiles-setup.service.

$ systemctl cat systemd-tmpfiles-setup.service | grep Exec
ExecStart=/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev

$ systemctl list-dependencies --reverse systemd-tmpfiles-setup.service | grep target
● └─sysinit.target
●   ├─basic.target
●   │ └─multi-user.target
●   │   └─graphical.target
●   └─rescue.target

--clean또한 작업을 실행하여 오래된 파일을 삭제할 수 있는 타이머가 여러 개 있습니다 .

상황에 따라 다양한 솔루션을 사용할 수 있지만 어느 것도 완벽하지는 않습니다.

경고하다:당신이 뭘 하든지,/usr/lib/tmpfiles.d/내용을 변경하지 마세요. 대신 에 같은 이름의 파일을 생성하세요 /etc/tmpfiles.d.

sudo cp /usr/lib/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf

tmpfiles.d일반적인 시스템 규칙을 따르십시오: /etc>> /run, /usr/lib이것이 /etc/우선순위를 가집니다.

옵션 1: 서비스를 영구적으로 변경

/tmp위 서비스 로 인해 --remove삭제되었습니다 . systemctl edit매개변수를 통해 ExecStart매개변수를 제거 할 수 있습니다 --remove.

$ systemctl edit systemd-tmpfiles-setup.service
ExecStart=
ExecStart=/bin/systemd-tmpfiles --create --boot --exclude-prefix=/dev

ExecStart원래 구성을 제거하려면 추가 Null이 필요합니다. 또는 systemctl edit --full ...생성된 파일을 실행하고 편집합니다.

--remove부족 으로 인해 D모든 프로필이 효과적으로 비활성화되며 이는 아마도 도움이 되지 않으므로 권장하지 않습니다. 따라서 규칙 정의를 변경하고 싶을 수도 있습니다 /tmp.

옵션 2: 특정 기간의 파일에 대해서만 /tmp 정리

/usr/lib/tmpfiles.d/tmp.conf이 줄을 복사하여 바꾸세요./etc/tmpfiles.d/tmp.confD

-D /tmp 1777 root root -
+d /tmp 1777 root root 12h

이렇게 하면 모든 파일이 아닌 12시간이 지난 파일만 삭제됩니다. 충돌 직후 재부팅하면 이것으로 충분할 수 있습니다. 그러나 우리는 한 단계 더 나아갈 수도 있습니다.

옵션 3: 프로젝트 파일 제외

파일이 항상 동일한 이름/패턴을 갖는 경우 다음을 제외하여 파일이 삭제되는 것을 방지할 수 있습니다 x.

-D /tmp 1777 root root -
+d /tmp 1777 root root 1s
+x /tmp/*output

호출 1s하면 모든 파일이 효과적으로 삭제됩니다.systemd-tmpfiles와는 별개로 /tmp/*output파일, 예를 들어 /tmp/aoutput전체 폴더를 제외할 수도 있습니다.

/tmp/이 마지막 변형은 문제를 해결하고 너무 큰 문제가 발생하는 것을 방지하기에 충분합니다 .

구성 확인

구성을 변경한 후에는 테스트할 차례입니다. 어떤 변형을 사용하든 이 테스트는 동일합니다. 파일에 비슷한 이름의 파일을 만들고 /tmpsystemd 서비스를 실행합니다.

$ touch /tmp/my-project-files-{a,b,c,d,e,f} /tmp/some-test-garbage{1..10}
$ systemctl start systemd-tmpfiles-{clean,setup}.service

모든 것이 올바르게 설정되었다면 "프로젝트" 파일이 여전히 존재해야 합니다. 제외 변형을 사용한 경우 x다른 정크는 /tmp/사라져야 합니다.

인용하다

  • tmpfiles.d(5)tmpfiles.d/*파일 구문 및 우선순위
  • systemd.service(5)~을 위한ExecStart
  • systemd.unit(5)ExecStart=덮는 데 사용
  • systemd-tmpfiles(8)tmpfiles풍경 개요
  • 파일이 systemd-tmpfiles-*.service통과됨systemctl cat systemd-tmpfiles-{clean,setup,setup-dev}.service

답변2

/tmp 아래의 일부 파일만 복구하려면 다음 단계를 따르세요.

  1. grub 편집 모드로 들어가려면 grub 메뉴 항목에서 "e"를 누르십시오.
  2. "linux"로 시작하는 줄 끝에 "break=mount"를 추가하세요.
  3. F10을 눌러 부팅하면 (initramfs) 콘솔이 표시됩니다.
  4. blkid사용 가능한 파일 시스템의 개요를 보려면 실행하세요 .
  5. mkdir /mntmodprobe ext4그런 다음 또는 유사한 명령을 실행하여 mount /dev/nvme0n1p1 /mnt관심 있는 파티션을 마운트하십시오./mnt
  6. 비슷한 방법을 사용하여 관심 있는 파일을 영구 위치로 이동하세요.mv /mnt/tmp/important_file /mnt/home/myuser/
  7. 재부팅 reboot -f하고 시스템을 정상적으로 시작하십시오.

답변3

init=/bin/bashsystemd를 시작하지 않고 쉘로 부팅하기 위해 커널 명령줄에 추가할 수 있습니다 . 파일 시스템을 읽기-쓰기로 다시 마운트하고, 파일을 /tmp 밖으로 이동하고, 파일 시스템을 다시 읽기 전용으로 마운트한 다음 exec /sbin/init시스템을 부팅합니다.

쉘에는 완전히 설정된 터미널이 없으므로 일부 기능(탭 완성, control-Z, control-C...)이 작동하지 않을 수 있습니다.

파일을 위험에 빠뜨리지 않고 제대로 작동하는지 먼저 테스트 시스템에서 시도해 볼 것을 권장합니다.

추신: 일반적으로 /var/tmp부팅 프로세스 중에 유지됩니다.

답변4

예.

파일 손실이 발생할 수 있는 상황은 두 가지입니다 /tmp.

  1. 임시 파일 시스템: 많은 최신 시스템은 임시 파일 시스템(예: RAM 디스크)을 마운트합니다. /tmp즉, 종료 시 내용이 항상 손실됩니다.

  2. 오래된 파일 정리존재하다 /tmp. 이는 청소를 위해 구성 가능한 스크립트입니다 /tmp.

명령의 출력을 확인하십시오 df /tmp. 사례 1의 경우 다음과 유사합니다.

$ df /tmp/
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs           12290040   276  12289764   1% /tmp

(중요한 것은 첫 번째 열입니다.. tmpfs)

/etc/tmpfiles.d사례 2(귀하의 경우)의 경우 일반적으로 --see 의 문서를 보면 자세한 내용을 알 수 있습니다 man tmpfiles.d. 출력을 추가해주세요

grep -s . /*/tmpfiles.d/*.conf /*/*/tmpfiles.d/*.conf

귀하의 질문에. ⟹ 귀하의 파일은 아래 예시에 따라 변경 사항을 적용하는 /usr/lib/tmpfiles.d/tmp.conf등 편집이 필요한 파일 입니다.sudo nano /usr/lib/tmpfiles.d/tmp.conf

다음은 예제 파일입니다 /etc/tmpfiles.d/tmp.conf.

# see tmpfiles.d(5)
# always enable /tmp folder cleaning
D! /tmp 1777 root root 0

# remove files in /var/tmp older than 10 days
D /var/tmp 1777 root root 10d

첫 번째 항목은 부팅할 때마다 폴더가 삭제되고 다시 생성된다는 D! /tmp 1777 root root 0의미입니다 . /tmp해당 줄을 주석 처리하고 파일에서 주석 처리되지 않은 다음 줄과 유사한 줄을 추가할 수 있습니다.

# see tmpfiles.d(5)

# # always enable /tmp folder cleaning
# D! /tmp 1777 root root 0

# Keep files in /tmp but not very old ones
D! /var/tmp 1777 root root 30d

# remove files in /var/tmp older than 10 days
D /var/tmp 1777 root root 10d

시스템이 아직 부팅되지 않았으므로 Live DVD/USB 미디어에서 부팅한 다음 시스템 파티션을 마운트해야 합니다 /mnt. 그런 다음 /mnt/usr/lib/tmpfiles.d/tmp.conf위와 같이 파일을 편집합니다.

관련 정보