Fstab entry for swap space

fstabswapuuid

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.

Best Answer

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

/swapfile none swap defaults 0 0

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