First you have to shrink the LVM volume
Read this to learn how. you can either use the answer marked or use gparted with version > 0.14.
One you shrink the LVM you can know create a new partition for swap using Gparted.
Now it's time to add this newly create parition to fstab
You need to edit /etc/fstab and add the new swap partition.
sudo gedit /etc/fstab
You need to add a line that looks like
UUID=new-partition-UUID none swap sw 0 0
You can get the UUID using the command
sudo blkid /dev/sdaX
Where sdaX stands for the newly created partition
Another workaround is to create a swap file instead of a swap partition.
in this i'm going to create a 4G swap file
sudo fallocate -l 4G /swapfile
verify that the correct amount of space was reserved by typing:
ls -lh /swapfile
output should be
-rw-r--r-- 1 root root 4.0G Apr 28 13:19 /swapfile
To enable the swap file:
sudo chmod 600 /swapfile
Verify that the file has the correct permissions:
ls -lh /swapfile
output should be:
-rw------- 1 root root 4.0G Apr 28 17:19 /swapfile
Now teell system to set up the swap space:
sudo mkswap /swapfile
output would be like:
Setting up swapspace version 1, size = 4194300 KiB no label, UUID=e2f1e9cf-c0a9-4ed4-b8ab-714b8a7d6944
Our file is now ready to be used as a swap space. We can enable this by typing:
sudo swapon /swapfile
We can verify that the procedure was successful by checking whether our system reports swap space now:
sudo swapon -s
output would be like:
Filename Type Size Used Priority
/swapfile file 4194300 0 -1
source
UUID=e2342vda-c324-2434-324c-84723ff298c none swap sw 0 0
– Maythux May 28 '15 at 11:20I receive the following message: swapon: /dev/sda6: read swap header failed
– gordon50 May 28 '15 at 21:12