Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux开启Swap分区 #111

Open
Bpazy opened this issue Apr 14, 2019 · 2 comments
Open

Linux开启Swap分区 #111

Bpazy opened this issue Apr 14, 2019 · 2 comments

Comments

@Bpazy
Copy link
Owner

Bpazy commented Apr 14, 2019

swap 的开启和关闭。

@Bpazy
Copy link
Owner Author

Bpazy commented Jan 9, 2025

禁用 swap

sudo swapoff -a

然后删除 /etc/fstab 对应行

@Bpazy
Copy link
Owner Author

Bpazy commented Jan 23, 2025

Linux开启Swap分区

  1. 创建要作为swap分区的文件:增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。
$ dd if=/dev/zero of=/root/swapfile bs=1M count=1024
  1. 格式化为交换分区文件:
$ mkswap /root/swapfile #建立swap的文件系统
  1. 启用交换分区文件:
$ swapon /root/swapfile #启用swap文件
  1. 使系统开机时自启用,在文件/etc/fstab中添加一行:
/root/swapfile swap swap defaults 0 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant