[root@hoge ~]# df -hT /tmp
ファイルシス タイプ サイズ 使用 残り 使用% マウント位置
/dev/nvme0n1p6 ext4 40G 9.4G 28G 26% /
[root@hoge ~]# systemctl enable tmp.mount
The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
instance name specified.
[root@hoge ~]# rpm -q systemd
systemd-239-13.el8_0.5.x86_64
[root@hoge ~]# EDITOR=vim systemctl edit tmp.mount
[root@hoge ~]# systemctl cat 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=man:hier(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
# /etc/systemd/system/tmp.mount.d/override.conf
# Make 'systemctl enable tmp.mount' work:
[Install]
WantedBy=local-fs.target
[root@hoge ~]# systemctl enable tmp.mount
Created symlink /etc/systemd/system/local-fs.target.wants/tmp.mount → /usr/lib/systemd/system/tmp.mount.
[root@hoge ~]#
2019-06-22追記、同じ要領で fedora28 x86_64 のコンテナを作ったのですが、yum ではなく dnf を指定しておく必要がありました。
このイメージを tar などで固めて、ホスト環境へ転送します。あとは、起動するだけ。
[root@hoge srv]# uname -a
Linux hoge 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@hoge srv]# systemd-nspawn -D /var/lib/machines/mycon32 --personality=x86
Spawning container mycon32 on /var/lib/machines/mycon32.
Press ^] three times within 1s to kill container.
Failed to create directory /var/lib/machines/mycon32//sys/fs/selinux: No such file or directory
Failed to create directory /var/lib/machines/mycon32//sys/fs/selinux: No such file or directory
[root@mycon32 ~]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@mycon32 ~]# exit
logout
Container mycon32 exited successfully.
[root@hoge srv]# systemd-nspawn -b --network-bridge=virbr0 -D /var/lib/machines/mycon32 --personality=x86
Spawning container mycon32 on /var/lib/machines/mycon32.
Press ^] three times within 1s to kill container.
Failed to create directory /var/lib/machines/mycon32//sys/fs/selinux: No such file or directory
Failed to create directory /var/lib/machines/mycon32//sys/fs/selinux: No such file or directory
systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)
Detected virtualization systemd-nspawn.
Detected architecture x86.
Welcome to CentOS 7 (AltArch)!
Initializing machine ID from random generator.
Cannot add dependency job for unit display-manager.service, ignoring: Unit not found.
[ OK ] Reached target Remote File Systems.
[ OK ] Created slice Root Slice.
...
[ OK ] Reached target Login Prompts.
[ OK ] Started Cleanup of Temporary Directories.
[ OK ] Started Login Service.
CentOS 7 (AltArch)
Kernel 3.10.0-514.26.2.el7.x86_64 on an i686
mycon32 login: root
Password:
[root@mycon32 ~]# uname -a
Linux mycon32 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 i686 i686 i386 GNU/Linux
[root@mycon32 ~]#