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 / 问题

问题[tmpfs](ubuntu)

Martin Hope
N0rbert
Asked: 2020-08-02 10:00:32 +0800 CST

如何允许 snap 应用程序访问 /tmp 文件夹?

  • 14

通常我会避免使用基于 snap 的应用程序,但有时我需要它们。

例如 - Markdown Lint Tool 仅以 Snap 命名 mdl。

当文件在主文件夹中时它工作得很好 -

$ echo "# header" > ~/test.md
$ /snap/bin/mdl ~/test.md ; echo $?
0

但是当文件位于/tmp目录中时它会失败:

$ echo "# header" > /tmp/test.md
$ cat /tmp/test.md
# header
$ /snap/bin/mdl /tmp/test.md
/snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/lib/mdl/doc.rb:57:in `read': No such file or directory @ rb_sysopen - /tmp/test.md (Errno::ENOENT)
    from /snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/lib/mdl/doc.rb:57:in `new_from_file'
    from /snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/lib/mdl.rb:75:in `block in run'
    from /snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/lib/mdl.rb:73:in `each'
    from /snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/lib/mdl.rb:73:in `run'
    from /snap/mdl/140/lib/ruby/gems/2.4.0/gems/mdl-0.9.0/bin/mdl:10:in `<top (required)>'
    from /snap/mdl/140/bin/mdl:23:in `load'
    from /snap/mdl/140/bin/mdl:23:in `<main>'

对于此特定应用程序,没有以下选项snap connect:

$ snap connections | grep mdl
home                      mdl:home                             :home                                 -

我也不能将它安装为经典:

$ snap install mdl --classic 
Warning: flag --classic ignored for strictly confined snap mdl

mdl 0.9.0 from Snapcrafters installed

我应该怎么做才能让 Snap 应用程序完全访问该/tmp文件夹?
它是由 Snap 设计发生的吗?

permissions tmp tmpfs snap
  • 2 个回答
  • 4005 Views
Martin Hope
Stonecraft
Asked: 2020-06-17 23:03:11 +0800 CST

fstab 中 tmpfs 的 `size` 参数是否不起作用?

  • 3

我很困惑我的 /tmp 使用 tmpfs 是否尊重size我给它的参数/etc/fstab:

我的 fstab 条目现在显示为:

root_pool/var/tmp  /tmp /var/tmp zfs rw,nodev,nosuid 0 0
tmpfs /tmp tmpfs rw,nodev,nosuid,noexec,nr_inodes=5k,size=2G,mode=1777 0 0
tmpfs /dev/shm tmpfs   defaults,nodev,nosuid,nr_inodes=5k,mode=700,size=4G 0 0

但是根据 du 的说法,它使用了我一半的内存(我理解这是默认值)而不是我打算分配给它的大小。

 ~ df /tmp
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs           65921428     0  65921428   0% /tmp

那么size参数根本没有任何影响吗?我正在使用 Ubuntu 20.04

编辑我可以手动安装它

sudo mount -oremount,size=4G /tmp

当我这样做时,这/tmp是预期的 20.04 GB。

编辑:系统状态:

● tmp.mount - Temporary Directory (/tmp)
     Loaded: loaded (/etc/systemd/system/tmp.mount; enabled; vendor preset: enabled)
     Active: active (mounted) since Wed 2020-06-17 13:30:35 EDT; 8min ago
      Where: /tmp
       What: tmpfs
       Docs: https://systemd.io/TEMPORARY_DIRECTORIES
             man:file-hierarchy(7)
             https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
      Tasks: 0 (limit: 154317)
     Memory: 76.0K
     CGroup: /system.slice/tmp.mount

Jun 17 13:30:35 virtland systemd[1]: Mounting Temporary Directory (/tmp)...
Jun 17 13:30:35 virtland systemd[1]: Mounted Temporary Directory (/tmp).

和journalctl -u tmp.mount

-- Reboot --
Jun 17 13:27:50 virtland systemd[1]: tmp.mount: Directory /tmp to mount over is not empty, mounting an>
Jun 17 13:27:50 virtland systemd[1]: Mounting Temporary Directory (/tmp)...
Jun 17 13:27:50 virtland systemd[1]: Mounted Temporary Directory (/tmp).
Jun 17 13:29:43 virtland systemd[1]: Unmounting Temporary Directory (/tmp)...
Jun 17 13:29:43 virtland systemd[1]: tmp.mount: Succeeded.
Jun 17 13:29:43 virtland systemd[1]: Unmounted Temporary Directory (/tmp).
-- Reboot --
Jun 17 13:30:35 virtland systemd[1]: tmp.mount: Directory /tmp to mount over is not empty, mounting an>
Jun 17 13:30:35 virtland systemd[1]: Mounting Temporary Directory (/tmp)...
Jun 17 13:30:35 virtland systemd[1]: Mounted Temporary Directory (/tmp).

Edit2:设置 tmpfs 的大小/dev/shm按预期工作:

# in fstab
tmpfs /dev/shm tmpfs   defaults,nodev,nosuid,nr_inodes=5k,mode=700,size=4G 0 0
tmpfs                                  13184288       2328   13181960   1% /run
tmpfs                                   4194304      41056    4153248   1% /dev/shm
tmpfs                                      5120          4       5116   1% /run/lock
tmpfs                                  65921432          0   65921432   0% /sys/fs/cgroup
tmpfs                                  65921432          0   65921432   0% /tmp
tmpfs                                  13184284          8   13184276   1% /run/user/1000

此外,尽管许多安全指南推荐使用 noexec 选项,但似乎存在问题,因为某些程序(包括 apt)需要从 /tmp 执行。我知道这可以解决,但我不想找出每个需要例外的程序。

fstab mount tmp tmpfs shm
  • 1 个回答
  • 2676 Views
Martin Hope
x70766c
Asked: 2020-04-28 07:45:47 +0800 CST

在 Ubuntu 20.04 上挂载 /tmp 作为 tmpfs

  • 7

我想在/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 个回答
  • 8691 Views
Martin Hope
user964536
Asked: 2019-06-12 19:48:01 +0800 CST

什么是“udev”和“tmpfs”

  • 4

我运行命令df -h,它显示udev大小为 471M,其他 5tmpfs个估计大小为 1.1G。我该怎么对他们?

filesystem tmpfs udev df
  • 1 个回答
  • 7758 Views
Martin Hope
Yonsy Solis
Asked: 2018-08-01 15:30:01 +0800 CST

/tmp 在 tmpfs 中,如何仅使用 systemd 执行此操作?

  • 9

我现在有一台装有 Ubuntu 18.04 的笔记本电脑,我喜欢它。我已通过/etc/fstab以下行将 /tmp 安装为 tmpfs:

tmpfs           /tmp            tmpfs   defaults,noatime,nosuid,nodev,noexec,mode=1777    0       0

现在,我想知道我如何才能做到这一点systemd,我只需要激活一项新systemd服务(tmp.mount相关),还是我需要更多的东西?如何在实时模式下用笔记本电脑中的实际/etc/fstab线路替换我的实际线路?systemd

tmp systemd tmpfs
  • 1 个回答
  • 14917 Views
Martin Hope
cmcginty
Asked: 2010-12-29 19:17:01 +0800 CST

/var/run、/var/lock的默认文件系统是什么

  • 1

试图弄清楚我的 /var/run 是否正在使用磁盘。查看命令输出:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root   40G   15G   26G  36% /
none                  3.9G  340K  3.9G   1% /dev
none                  3.9G  1.1M  3.9G   1% /dev/shm
tmpfs                 3.9G  600K  3.9G   1% /tmp
none                  3.9G  452K  3.9G   1% /var/run
none                  3.9G     0  3.9G   0% /var/lock
none                  3.9G     0  3.9G   0% /lib/init/rw
/dev/md0              236M   59M  165M  27% /boot
/dev/mapper/vg0-home   60G   58G  2.3G  97% /home
filesystem mount tmpfs
  • 1 个回答
  • 1007 Views
Martin Hope
litvin05
Asked: 2010-11-08 11:55:18 +0800 CST

如何创建 RAM 驱动器?

  • 16

如何在 ubuntu 下创建 RAM 驱动器。他会在启动时自动安装吗?

fstab ram-usage mount memory tmpfs
  • 2 个回答
  • 11338 Views

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