---
title: 'How to Add Swap Swap Partition in OS Linux | Zomro'
description: 'In Linux, the SWAP partition plays an important role by providing additional memory for the operating system. If you need to add a new SWAP swap partition to your...'
image: 'https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907824_1.png'
---

![opened image]()

  * [Zomro](https://zomro.com/)
  * [FAQ](https://zomro.com/blog/faq/)
  * How to Add Swap Swap Partition in OS Linux 



# How to Add Swap Swap Partition in OS Linux

20-02-2023

In Linux, the SWAP partition plays an important role by providing additional memory for the operating system. If you need to add a new SWAP swap partition to your Linux server, you can use the dd command to get the job done.  
  
Locate the swap partition SWAP  
  
Before creating a new SWAP swap partition, you need to determine the location where you want to install it. Typically, the SWAP swap partition is located in free space on the hard disk or on a separate partition.  
  
You can check the free space on your hard drive with the command:  

    
    
    df-h
    

  
![How to Add Swap Swap Partition in OS Linux - 1](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907824_1.png)  
**Create a new swap file**  
  
To create a new swap file that will be used as the SWAP swap partition, run the following command:
    
    
    fallocate -l 1G /swapfile
    

  
![How to Add Swap Swap Partition in OS Linux - 2](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907837_2.png)  
This command creates a file size of 1GB.  
  
Now it needs to be activated:
    
    
    mkswap /swapfile
    

  
![How to Add Swap Swap Partition in OS Linux - 3](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907882_3.png)  
You can enable SWAP with the command:
    
    
    swapon /swapfile
    

  
To make sure it's enabled, type:
    
    
    swapon --show
    

  
![How to Add Swap Swap Partition in OS Linux - 4](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907882_4.png)  
Change the permissions on the swap file  
  
After creating a new swap file, you need to change the permissions on it using the chmod command:
    
    
    chmod 600 /swapfile
    

  
This ensures that only root can read and write to the swap file.  
  
  
At the moment SWAP is not persistent, if you reboot your linux the swap space will not be mounted. To make it permanent, you must add an entry to **/etc/fstab**.
    
    
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    

  
![How to Add Swap Swap Partition in OS Linux - 5](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907935_5.png)  
Now, the next time you boot, SWAP will be available.  
  
If this utility failed to create a swap partition, you can use the dd utility.

**Create a SWAP swap partition using the dd command**

  
For example, to create a 1 GB swap file with a data block size of 1024 bytes and a block count of 1048576, run the following command:
    
    
    dd if=/dev/zero of=/swapfile bs=1024 count=1048576
    

  
![How to Add Swap Swap Partition in OS Linux - 6](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676907983_6.png)  
After creating a new swap file, you need to change the permissions on it using the chmod command:
    
    
    chmod 600 /swapfile
    

  
  
**Create a swap partition**  
  
After running the dd command, you can create a SWAP swap partition using the mkswap command:
    
    
    mkswap /swapfile
    

  
![How to Add Swap Swap Partition in OS Linux - 7](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676908004_7.png)  
**Enable Swap Partition**  
  
After creating the swap partition SWAP, you can enable it using the swapon command:
    
    
    swapon /swapfile
    

  
![How to Add Swap Swap Partition in OS Linux - 8](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676908033_8.png)  
To check that the SWAP swap partition is working, run the swapon -s command:
    
    
    swapon -s
    

  
![How to Add Swap Swap Partition in OS Linux - 9](https://dx86q6oq7ry0e.cloudfront.net/uploads/media/blog/a48@server-panel.net/2023/02/01/1676908046_9.png)  
This command will list all active SWAP swap partitions on the server, including the new SWAP swap partition you just created.  
  
To add a swap partition to a SWAP created with the **dd** command, you can use the following command:
    
    
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    

  
Now, the next time you boot, SWAP will be available.  
  
As you can see, adding a new SWAP swap partition on Linux using the dd and fallocate command is a fairly simple process that can be completed in a few steps.

Similar articles:

[How to order a virtual server in the new billing system](https://zomro.com/blog/faq/229-kak-zakazat-server-v-novom-billinge) [How to Install Python 3.10 on Ubuntu 20.04](https://zomro.com/blog/faq/299-kak-ustanovit-python-310-na-ubuntu-2004) [How to set up a Samba server on Windows Server and connect to it from Windows Server 2019](https://zomro.com/blog/faq/333-how-to-set-up-a-samba-server-on-windows-server-and-connect-to-it-from-windows-server-2019) [How to order a dedicated server in the new billing](https://zomro.com/blog/faq/230-kak-zakazat-vydelennyj-server-v-novom-billinge) [Linux dig command - usage and examples.](https://zomro.com/blog/faq/404-linux-d-command-usage-examples)

[ Forex Server from €7.95/mon ](/server-for-forex)
