# Add Swap Space To System

We can add swap space to the system by following method -

## Check for existing swap space

```bash
sudo swapon --show
```

## Create a new swap space

```bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
```

## Enable swap space

```bash
sudo mkswap /swapfile
sudo swapon /swapfile
```

## Verify that the swap space exists

```bash
sudo swapon --show
```

## Make swap persistent upon restart

```bash
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
```

***Source:*** [***DigitalOcean***](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04)


---

# 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://til.devjugal.com/linux/add-swap-space-to-system.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.
