# Linux-增加Swap方法

**如何增加swap空间？**

```bash
# 例如添加是swap空间路径 /data/swap, bs是每块的大小，count是块的数量；bs*count，就是swap文件的大小：这里1M*1024=1G。可以根据需要自行调整
dd if=/dev/zero of=/data/swap bs=1M count=1024
mkswap /data/swap
chmod 0600 /data/swap -R
swapon /data/swap

# 开机自启动
echo "/data/swap swap swap defaults 0 0" >> /etc/fstab
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/centos/linux-ji-cao/linux-zeng-jia-swap-fang-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
