Tips to Make Swap File on Linux

Tips to Make Swap File on Linux

Hello Geeky, so today we are focusing on How to Make Swap File on Linux. So please read this tutorial carefully so you may comprehend it in a better helpful way.

Guide: How to Make Swap File on Linux

A swap file lets Linux configure hard disk space like RAM. If your system runs out of memory, it will use swap memory and convert some memory to disk space. This is free up working memory to serve more important principles. When the original memory is free again, it stores data back from the disk. I recommend reading this article to learn more about swap on Linux. Traditionally, swap memory is used as a separate partition on the hard drive. When installing Linux, create a separate partition for the swap. But this trend has changed in recent years. With a swap file, you no longer need a separate partition. It creates a file under the root and tells your system to use it as a swap site.

With a dedicated swap partition, changing the amount of swap space is a nightmare and, in many cases, an impossible task. In the case of swap files, however, you can change the size as you wish. Swap memory is part of the appropriate system memory (hard disk). When the system detects that the program’s physical memory is full, it automatically starts using the swap space available on the system. In simple terms, a swap space is part of a hard drive used as system memory.

How to Create a Conversion File in Linux

  • Indicate current swap location and RAM usage on Linux.
    • $ free -h
    • $ swapon – stack
  • Next, create a new file that you will use for the swap site either using the dd command:
    • # Example: 2 Gib Linux swap file #
    • $ sudo dd ti = / dev / odo ti = / swap-file count = 2 bs = 1GiB
  • Make sure you set it up up modify Linux file permissions for security purposes using chmod command and chown command:
    • $ sudo chmod -v 0600 / swap-file
    • $ sudo chown -v root: root / swap-file
    • # List permissions #
    • $ ls -l / swap-file
  • Run the next mkswap command to set up Linux swap area using a file:
    • $ sudo mkswap / swap-file
  • Enable swap field operation by typing swapon command:
    • $ sudo swapon / swap-file

How to play field swap file frequently on Linux

  • Make sure that our swap file is activated after the Linux system reboot. To make the change permanent, edit the file / etc / fstab:
    • $ sudo vi / etc / fstab
  • Add the following configuration instructions:
    • / swap-file swap swap default 0 0
  • Save and delete the file.


Guide about How to Make Swap File on Linux

In this guide, we told you about the How to Make Swap File on Linux; please read all steps above so that you understand How to Make Swap File on Linux in case if you need any assistance from us, then contact us.

How this tutorial or guide assisting you?

So in this guide, we discuss the How to Make Swap File on Linux, which undoubtedly benefits you.

Final note

I hope you like the guide How to Make Swap File on Linux. In case if you have any queries regards this article/tutorial you may ask us. Also, please share your love by sharing this article with your friends and family.

Tips to Make Swap File on Linux
Tips to Make Swap File on Linux
Trickbugs: Get the latest Trick and Tips
Enable registration in settings - general