CentOS 7 add swap

    Adding swap to a CentOS 7 AWS virtual machine

    This is the steps for adding swap space to an CentOS 7 server.

    dd if=/dev/zero of=/swapfile count=2048 bs=1MiB
    chmod 600 /swapfile
    chown root. /swapfile
    mkswap /swapfile
    swapon /swapfile
    echo "/swapfile swap swap sw 0 0" >> /etc/fstab

    Check to make sure it created correctly

    swapon -s

    That’s it

    This note was written testing against the following image:

    uname -a: Linux s17.iotau.io 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    Categories: centos Tags: Tags: , ,