在btrfs文件系统创建swapfile

在btrfs文件系统上为archlinux创建swapfiles

swapfile的作用

  • 扩展物理内存

  • archwiki上的介绍
    Swap space can be used for two purposes, to extend the virtual memory beyond the installed physical memory (RAM), and also for suspend-to-disk support.

创建方法

  • 创建一个swap子卷
1
sudo btrfs su cr /swap
  • 创建一个大小为0的swapfile
1
2
cd swap
sudo truncate -s 0 swapfile
  • 修改权限
1
sudo chmod 0600 swapfile
  • 格式化swapfile
1
sudo mkswap swapfile
  • 开启swapfile
1
sudo swapon swapfile
  • 写入fstab文件,开机自动启动
1
2
3
4
5
6
7
8

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>

# /swapfile
/swap/swapfile        none        swap        defaults      0 0

以上的有关swapfile的内容可供参考,但是必须在之前挂载主分区

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy