Collapse

Announcement

Collapse
No announcement yet.

Steps to create swap file on Centos Server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mandeep
    replied
    You're welcome !!
    Last edited by Mandeep; 02-11-2018, 12:38 PM.

    Leave a comment:


  • Administrator
    replied
    Thanks great information on how to create swap space.

    Leave a comment:


  • Mandeep
    replied
    Hi Neha,

    Here, I'll consider that you need to create a Swap space of 4 GB as as a reference and you may follow below steps to do so.

    Connect to the server as root user.

    1. Check total disk space available on the server

    Code:
    df -h
    2. Manipulate File space. Create a swapfile in the location where it can't be deleted. I've considered /root location for the same.

    Code:
    fallocate -l 4G /root/4GB.swap
    3. Use following command, the count parameter will be used to allocate the desired block size 4 GB.

    Code:
    dd if=/dev/zero of=/root/4GB.swap bs=1024 count=4048576
    4. Create a swap file.

    Code:
    mkswap /root/4GB.swap
    5. Change the permission to 600.

    Code:
    chmod 600 /root/4GB.swap
    6. To enable Swap immediately and not on boot time.

    Code:
    swapon /root/4GB.swap
    7. To enable swap at boot time add an entry to /etc/fstab file

    Code:
    vi /etc/fstab
    Code:
    /root/4GB.swap  swap  swap  defaults 0  0
    8. To check the mount or entry is correct.

    Code:
    mount -a
    9. Swap is now available and can be checked using below command.
    Code:
    free -m

    Leave a comment:


  • Neha
    started a topic Steps to create swap file on Centos Server

    Steps to create swap file on Centos Server

    Can you please guide me through the steps to create swap file on Centos Server?

Working...
X