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 空间的增加。