我打开了磁盘使用情况分析器,第二大项目是 swap.img。用鼠标右键单击甚至无法从外部打开它。它像 Ubuntu 的备份文件吗?我可以安全地删除它,而不会出现任何问题,还是我只能把它保留在那里。我对这个操作系统比较陌生,抱歉 🙃🤭
swapspace
我已经使用了所有的交换(由 Rust 编译器),尽管我确实安装了软件包,但它并没有增长。
total used free shared buff/cache available
Mem: 15Gi 12Gi 2.4Gi 1.8Gi 2.5Gi 2.6Gi
Swap: 2.0Gi 2.0Gi 0B
时间稍晚一些:
$ swapon
NAME TYPE SIZE USED PRIO
/dev/nvme0n1p2 partition 2G 2G -2
如何使交换文件工作?我需要编辑吗/etc/swapspace.conf
?
/etc/swapspace.conf
:
# This file is part of Swapspace.
#
# Swapspace is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Swapspace is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with swapspace; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# Swap path: location where swapspace may create and delete swapfiles. For
# security reasons this directory must be accessible to root and to root only.
#swappath="/var/lib/swapspace"
# Lower free-space threshold: if the percentage of free space drops below this
# number, additional swapspace is allocated
#lower_freelimit=20
# Upper free-space threshold: if the percentage of free space exceeds this
# number, swapspace will attempt to free up swapspace
#upper_freelimit=60
# Percentage of free space swapspace should aim for when adding swapspace. This
# should fall somewhere between lower_freelimit and upper_freelimit.
#freetarget=30
# Smallest allowed size for individual swapfiles
#min_swapsize=4m
# Greatest allowed size for individual swapfiles
#max_swapsize=2t
# Duration (roughly in seconds) of the moratorium on swap allocation that is
# instated if disk space runs out, or the cooldown time after a new swapfile is
# successfully allocated before swapspace will consider deallocating swap space
# again. The default cooldown period is about 10 minutes.
#cooldown=600
还:
$ systemctl status swapspace.service
● swapspace.service - Swapspace, a dynamic swap space manager
Loaded: loaded (/lib/systemd/system/swapspace.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-04-06 12:25:27 IDT; 1 week 2 days ago
Docs: man:swapspace(8)
Main PID: 5007 (swapspace)
Tasks: 1 (limit: 18672)
Memory: 696.0K
CPU: 56min 53.175s
CGroup: /system.slice/swapspace.service
└─5007 /usr/sbin/swapspace
Apr 15 22:57:50 victor swapspace[5007]: Error: Could not enable swapfile '1': Invalid argument
Apr 16 07:54:11 victor swapspace[2805427]: Setting up swapspace version 1, size = 6.6 GiB (7115493376 bytes)
Apr 16 07:54:11 victor swapspace[2805427]: no label, UUID=e4971b48-a25a-48bd-bba4-c612569f996a
Apr 16 07:54:11 victor swapspace[5007]: Error: Could not enable swapfile '1': Invalid argument
Apr 16 08:04:19 victor swapspace[2920343]: Setting up swapspace version 1, size = 6.1 GiB (6517428224 bytes)
Apr 16 08:04:19 victor swapspace[2920343]: no label, UUID=5e0ae6b7-9715-4882-8cda-51707e96fbaa
Apr 16 08:04:19 victor swapspace[5007]: Error: Could not enable swapfile '1': Invalid argument
Apr 16 08:14:26 victor swapspace[2939298]: Setting up swapspace version 1, size = 6.1 GiB (6539935744 bytes)
Apr 16 08:14:26 victor swapspace[2939298]: no label, UUID=1ba42fae-6106-450e-9d96-3cdc040c84c6
Apr 16 08:14:26 victor swapspace[5007]: Error: Could not enable swapfile '1': Invalid argument
我的机器中有 24GB 的可用 RAM,但我通常使用的内存远少于 8GB。但是,有时我涉及到大型数据文件,我突然需要 40GB,并且在极少数情况下,我希望能够访问更多(最多 60GB)。这主要是使用 numpy 和 Apache Arrow。
现在我有一个 20GB 的 ssd 交换文件,它工作正常,但显然很慢。我想用 zRAM 替换它,假设我在 16GB 上得到双重压缩,即 32GB,加上剩余的 8GB = 40GB 的“ram”。不过,理想情况下,我偶尔会想要超过 40GB,并想知道不适合 zRAM 的内容是否有可能进一步溢出到“传统”SSD 交换文件或分区中。
这是可行的吗?显然,我希望 zRAM 优先于磁盘交换文件。
我最近尝试在 Windows (WSL2) 上安装 Ubuntu。我尝试了该free
命令,并使用了几块交换内存。我想减少交换,所以我vm.swappiness=10
在/etc/sysctl.conf
. 我尝试重新加载sysctl.conf
,它似乎可以工作,但是当我尝试关闭 WSL 并开始一个新会话时,swappiness 被重置为默认值 60。
WSL2 上的 Ubuntu 是否会覆盖此设置以使其再次变为 60?
看到这篇文章后:如何在 Ubuntu 18.04 中增加交换文件?,我想知道,如何在不删除交换文件的情况下减小它的大小?
我已经使用 Windows 几年了。有时我不得不因为断电或旅行而关闭笔记本电脑,而休眠功能帮助了我。现在切换到 Ubuntu 后,我发现没有休眠功能。我已经阅读了一些具体的问题。 如何在 Ubuntu 20.04 中启用休眠选项? 现在在阅读了这个人的回答后,他告诉我应该有交换分区而不是交换文件。现在不幸的是我有交换文件。现在如果我想用交换文件休眠怎么办?
我刚刚创建了一个交换文件,现在我想检查这个交换文件的位置。
如何检查我的交换文件位于哪个分区?
我总是必须在启动后手动激活交换文件。怎么了?这是我的/etc/fstab
:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/nvme0n1p3 during installation
UUID=65238893-d167-43fd-9c3d-489759c09f06 / btrfs defaults,subvol=@ 0 1
# /boot was on /dev/nvme0n1p2 during installation
UUID=4e5c83d5-a781-4af7-a205-f137974d998e /boot ext4 defaults 0 2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=68C0-029E /boot/efi vfat umask=0077 0 1
# /home was on /dev/nvme0n1p3 during installation
UUID=65238893-d167-43fd-9c3d-489759c09f06 /home btrfs defaults,subvol=@home 0 2
UUID=65238893-d167-43fd-9c3d-489759c09f06 /swap btrfs defaults,noatime,subvol=swap 0 0
/swap/swapfile none swap sw 0 0
这是输出sudo btrfs sub list /; ls /swap
:
ID 256 gen 59227 top level 5 path home
ID 318 gen 62429 top level 5 path @
ID 319 gen 62429 top level 5 path @home
ID 330 gen 62180 top level 318 path swap
swapfile