How to automatically mount swap partition?

This is your previous /etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=33a0fc77-06b0-406c-95fd-15bf7033b619 /               ext4    errors=remount-ro 0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

Now, to add your swap partition to it, do the following:

  1. Open Gparted.

    Gparted screenshot

  2. Right-click on the swap partition and click on Information.

    select partition in Gparted

  3. Note down your UUID.

    UUID in partition info

  4. Now, modify your previous /etc/fstab, by doing the following:

    • Open the file by typing the command:

      sudo -H gedit /etc/fstab
      
    • Then, add this line,

      UUID=THE UUID YOU OBTAINED FROM ABOVE none       swap   sw         0     0
      

      after the line

      # a swapfile is not a swap partition, no line here
      
    • Save the file and restart your computer. Everything should be working now.


Type in terminal:

gnome-disks 

Then select the swap partition. In the settings menu select "Edit mount" option.