Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»Debian»How To Add Swap Space on Debian 10

    How To Add Swap Space on Debian 10

    By RahulSeptember 8, 20212 Mins Read

    Swap memory is a location on harddisk is used as Memory by the operating system. When the operating systems detects that main memory is getting full and required more RAM to run applications properly it check for swap space and transfer files there. In general terms, swap is a part of the hard disk used as RAM on the system.

    Advertisement

    This tutorial will help you to ADD Swap memory on Debian 10 Buster Linux system.

    Add Swap in Debian 10

    Use the below steps to create and enable Swap memory on your Debian system via command line.

    1. Check Current Swap

    First of all, Make sure your system have no Swap memory configured on your system. You can check if by running one of the below commands.

    sudo swapon -s
    free -m
    

    check swap Debian 10

    2. Create Swap file on Debian

    Lets create a file to use for swap in system of required size. Before making file make sure you have enough free space on disk. Generally, it recommends that swap should be equal to double of installed physical memory.

    My Debian system have 2GB of main memory. So we will create a swapfile of 4GB in size.

    sudo fallocate -l 4G /swapfile
    chmod 600 /swapfile
    

    The, make it to swap format and activate on your system by running following commands:

    sudo mkswap /swapfile
    sudo swapon /swapfile
    

    3. Make Swap Permanent

    After running above commands, Swap memory is added to your system and operating system can use when required. But after reboot of system swap will deactivate again.

    You can make it permanent by appending the following entry in /etc/fstab file. Edit fstab file in editor:

    vim /etc/fstab
    

    and add below entry to end of file:

    /swapfile   none    swap    sw    0   0
    

    Add swap in fatab

    Save file and close. Now Swap memory will remain activate after system reboots.

    4. Verify Swap Memory

    You have successfully added swap memory to your system. Execute one of the below commands to view current active swap memory on your system:

    sudo swapon -s
    free -m
    

    add swap on Debian

    5. Update Swappiness Parameter

    Now change the swappiness kernel parameter as per your requirement. It tells the system how often system utilize this swap area.

    Edit /etc/sysctl.conf file:

    sudo vim /etc/sysctl.conf
    

    append following configuration to end of file

    vm.swappiness=10
    

    Now reload the sysctl configuration file

    sudo sysctl -p
    

    Conclusion

    In this tutorial, you have learned to create and enable Swap memory on Debian system.

    Debian 10 Memory swap swapfile
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Change Redis Max Memory

    How to Setup DKIM (DomainKeys) with Postfix

    A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

    How To Add Swap Space on Debian 11 (Bullseye)

    How To Add Swap Space on Debian 11

    View 2 Comments

    2 Comments

    1. Olivier on March 26, 2021 8:34 am

      Very good tutorial ! Thank you.

      Reply
    2. mike on June 2, 2020 4:23 pm

      cool i learned from this!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.