Firestar-Reimu / Arch-and-Manjaro-KDE-Installation

安装 Arch/Manjaro Linux + KDE Plasma + Windows 11 双系统的指南

Home Page:https://blog.firestar-reimu.top/ArchLinux-Installation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swapon 失败: 无效的参数

Firestar-Reimu opened this issue · comments

[15:25:27] root:firestar # swapoff -a 
[15:25:37] root:firestar # rm -rf /swapfile
[15:25:46] root:firestar # fallocate -l 4096M /swapfile
[15:26:02] root:firestar # chmod 600 /swapfile
[15:26:26] root:firestar # mkswap /swapfile
正在设置交换空间版本 1,大小 = 4 GiB (4294963200  个字节)
无标签,UUID=fb03a376-95d2-45e3-8d0c-b7be03495a7d
[15:26:38] root:firestar # swapon /swapfile
swapon: /swapfile:swapon 失败: 无效的参数
[15:26:46] root:firestar # swapoff -a
[15:26:59] root:firestar # rm -rf /swapfile

emmmmm……没看出来是什么毛病,要不去 Manjaro 论坛中文区或者 archlinuxcn 论坛问一下?
其实我自己用的是 systemd-swap,它可以动态分配 swap 的大小
https://wiki.archlinux.org/index.php/Swap#Automated

动态 Swap 文件设置

先下载systemd-swap软件包:

yay -S systemd-swap

编辑/etc/systemd/swap.conf

kate /etc/systemd/swap.conf

去掉swapfc_enabled前的注释并设置为swapfc_enabled=1,保存并关闭

在终端输入sudo systemctl enable --now systemd-swap以启动systemd-swap服务

这样写是对的吗,我现在有了一个256MB的swap

动态 Swap 文件设置

先下载systemd-swap软件包:

yay -S systemd-swap

编辑/etc/systemd/swap.conf

kate /etc/systemd/swap.conf

去掉swapfc_enabled前的注释并设置为swapfc_enabled=1,保存并关闭

在终端输入sudo systemctl enable --now systemd-swap以启动systemd-swap服务

这样写是对的吗,我现在有了一个256MB的swap

应该没错。如果你开个虚拟机或者做其他比较吃内存的事情,可以观察到 swap 空间的增加。