Here is the free -m output

[prem@myserver: /home/prem]$ free -m
              total        used        free      shared  buff/cache   available
Mem:            991         218          85         267         687         360
Swap:             0           0           0

I have added swap space to my cent os 7 machine by using following commands

dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Now the swap space has increased to 2GB

[prem@tuatahi: /home/prem]$ free -m
              total        used        free      shared  buff/cache   available
Mem:            991         284          69         265         638         292
Swap:          2047           5        2042

But I guess in order to make these changes permanent, I need to add fstab entry for my swap space. Here are the contents of fstab

UUID=ef6ba050-6cdc-416a-9380-c14304d0d206 /                 xfs     defaults        0 0

I am not sure how to add the swap space in terms of UUID.


There is no UUID for a file. Simply enter it as:

/swapfile swap swap defaults 0 0

Since it's directly on the root filesystem, there's no worry about the mounting order.

| improve this answer | |
  • Thanks tried and tested... It works fine. I couldn't tag it as answer. – Prem Jul 31 '16 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.