如题
[FAILED] Failed to activate swap /swapfile.
[DEPEND] Dependency failed for Swap.开机时报错如上,开机之后交换文件无法正确被挂载。
在 Arch Linux 论坛上找到了解决方案如下:
SOLVED: Swap not working with Kernel 5.7.2
这个问题仅出现在 ext4 文件系统下的 Linux 5.7.2 上,使用 fallocate 创建的 swap 交换文件。
Arch Linux Wiki 的解释如下:
Note: dynamic space allocation such as using
fallocateis not supported, as it causes problems with some file systems such as F2FS [1] and will likely fail to activate at boot time with error “swapon: swapfile has holes” as of kernel 5.7. Hence, contiguous allocation, such asdd, is the only reliable way to allocate a swap file.[2]
因此删掉原有的 swapfile, 用 dd 重新分配即可.
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile