AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1232004
Accepted
x70766c
x70766c
Asked: 2020-04-28 07:45:47 +0800 CST2020-04-28 07:45:47 +0800 CST 2020-04-28 07:45:47 +0800 CST

在 Ubuntu 20.04 上挂载 /tmp 作为 tmpfs

  • 772

我想在/tmp没有 fstab 条目的情况下使用tmp.mount

但是在 Ubuntu 20.04 LTS 上,它似乎不起作用。

user@user-x1:~$ systemctl status tmp.mount 
Unit tmp.mount could not be found.
user@user-x1:~$ sudo systemctl enable tmp.mount 
Failed to enable unit: Unit file tmp.mount does not exist.
user@user-x1:~$ sudo systemctl cat tmp.mount 
No files found for tmp.mount.
user@user-x1:~$ cat /usr/share/systemd/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

[Install]
WantedBy=local-fs.target
user@user-x1:~$ 

发生了什么?为什么即使 bash 自动制表符填满,systemd 仍说找不到单元,而无需任何配置tmp.mount即可启用此功能的最简单方法是什么?tmpfs

fstab mount systemd tmpfs
  • 2 2 个回答
  • 8691 Views

2 个回答

  • Voted
  1. Best Answer
    ExploitFate
    2020-04-28T15:53:26+08:002020-04-28T15:53:26+08:00

    默认情况下不启用 tmp.mount。只需复制并启用它

    sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/ 
    sudo systemctl enable tmp.mount
    
    • 12
  2. Richard Yu
    2022-06-28T19:14:04+08:002022-06-28T19:14:04+08:00

    请注意,systemctl enable接受单元文件的绝对路径。(参见systemctl 手册页)因此无需手动复制。

    我在 Ubuntu 22.04 上测试过:

    $ sudo systemctl enable /usr/share/systemd/tmp.mount
    Created symlink /etc/systemd/system/local-fs.target.wants/tmp.mount → /usr/share/systemd/tmp.mount.
    Created symlink /etc/systemd/system/tmp.mount → /usr/share/systemd/tmp.mount.
    
    • 2

相关问题

  • 修复 USB 驱动器自动通知

  • 是否有更好的方式为 /home/userX 构建分区/挂载

  • 当另一个文件系统安装在路径上时是否可以删除文件?

  • 命令列出启动时启动的服务?

  • 如何避免启动时出现“S to Skip”消息?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve