Technoracle
    Facebook Twitter Instagram
    • Sitemap
    • Privacy Policy
    • Disclaimer
    • Term of Services
    Facebook Twitter Instagram Pinterest Vimeo
    TechnoracleTechnoracle
    • Tutorials
      • Amazon Cloud
      • Google Cloud
    • How To
    • Blog
    • About
    Subscribe
    Technoracle
    Home»How To»How to Create Linux Swap File Easily
    How To

    How to Create Linux Swap File Easily

    Rajesh ShivamBy Rajesh ShivamMarch 29, 2022Updated:March 29, 2022No Comments2 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Create Linux Swap File
    Share
    Facebook Twitter LinkedIn Pinterest Email
    Create Linux Swap File

    Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the primary memory(RAM) is full, inactive pages in memory are moved to the swap space. In this step-by-step tutorial, I am going to create Linux swap file easily.

    Page Contents

    • Steps to Create Linux Swap File
      • Step 1: Create a file for swap setup
      • Step 2: Set Permission for Swap File
      • Step 3:  Set up a Linux swap area
      • Step 4: Enable the swap
      • Step 5: Verify Swap Setup
      • Step 6: Enable Swap on startup
    • Conclusion

    Steps to Create Linux Swap File

    Now, I will create 2GB linux swap file, if you need more you can change the value of 2G.

    Step 1: Create a file for swap setup

    Create a file for swap using following command.

    $ sudo fallocate -l 2G /swapfile

    Step 2: Set Permission for Swap File

    Set permission for swap file. Only root user should read and write the swap file.

    $ sudo chmod 600 /swapfile

    Step 3:  Set up a Linux swap area

    Use mkswap utility for linux swap area.

    $ sudo mkswap /swapfile

    Step 4: Enable the swap

    Make the swap file available for immediate use by adding the swap file to swap space. To make swap available use following command.

    $ sudo swapon /swapfile

    Step 5: Verify Swap Setup

    Verify that the swap setup successful, run following command.

    $ sudo swapon -s

    Step 6: Enable Swap on startup

    To swap enable on startup, edit following file.

    $ sudo vi /etc/fstab

    Add the following new line at the end of the file, save the file, and then exit

    /swapfile swap swap defaults 0 0

    Conclusion

    In this short step-by-step guide, you have learned to create Linux swap file. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.

    create swap linux swap file
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Install PrestaShop on Ubuntu 20.04 Easily
    Next Article Best WordPress Hosting for Bloggers
    Rajesh Shivam

    Hello, everyone, I am Rajesh Shivam, I am a full-time freelancer with more than seven years plus experience in different freelancing platforms, in this blog, I am going to provide complete freelancing tips and tricks.

    Related Posts

    How To

    How to Install Microsoft Teams on Ubuntu 22.04 Easily

    February 22, 2023
    Read More
    How To

    What is Elastic IP and Its Pricing in AWS

    February 22, 2023
    Read More
    How To

    How to Convert PEM to PPK file [Step by Step Guide]

    February 22, 2023
    Read More
    Add A Comment

    Leave A Reply Cancel Reply

    Facebook Twitter Instagram Pinterest
    © 2023 Technoracle

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

    Go to mobile version