Ubuntu – Swap not being detected on 14.04 LTS


I upgraded from 12.04 to 14.04. When I opened my resource monitor, I noticed my swap was not detected. I installed Gparted, opened the program and started to look at my file tree. I noticed that my swap area was flagged as unknown, with a red exclamation point beside it. I formatted it as linux-swap, then selected 'swapon' from the menu. I reloaded the system monitor and it looked as if my problem was solved.

I restarted my computer, opened up system monitor again, and I saw that swap was no longer there. In Gparted, this time the partition was recognized as swap, but the system did not see it. I need to `swapon every time my system reboots.

I was first alerted to this issue when VMware told me that I had no swap. I thought I did, since all I did was upgrade my distro. My partition layout did not change at all during the upgrade process.

I decided to use my gparted livedisk to format that same swap area (that you will see in the photos) as linux-swap. Before I did that, Gparted livesisk gave the same error that it was unrecognised. With the swap formatting completed, I restarted my computer, to find out that it did not boot. This time GRUB has an error. This has never happened to me before with distros, doing similar disk work.

Then I decided to do a clean install of 14.04 from USB and CD, but I am still having the same problem. I tried (as you will see in photos as well) to 'swapon -a' from terminal with no success either (even though I am able to swapon from Gparted in the OS) – I get a directory error.

This is my fstab file:

# /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/sda5 during installation
UUID=a596c6cc-c9aa-43fe-aaad-abfeaae63916 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda6 during installation
#UUID=c4959ceb-5934-4cff-acd3-33ffcb153220 none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

I don't know much of what that information means, but it might be helpful to you. Could I have messed up my swap by formatting it in Gparted? It was unknown in the utility, since it was cryptswap.

This is my current state. As I said, I need to 'swapon' every time I restart.

enter image description here

enter image description here

I have used Ubuntu as dual-boot for several years now. Since 6.06 "Dapper". I have used almost every distro and have never had this problem before. This is where I ask of your help and suggestion. I am no geek, only an enthusiast, and I posses basic skill and ability.

Best Answer

Open terminal and run this command:

sudo blkid

It will give you the UUID no's of partitions of your hard drive from them note the swap partition UUID no.

Now go to fstab file as root in that file go to line under '# swap was on /dev/sda6 during installation' replace the UUID number under swap with the one you got from blkid command

Remove the '#' symbol before the UUID it means that line will not run so remove it.

Also remove the below line completely /dev/mapper/cryptswap1 none swap sw 0 0

Now reboot.

I hope that helps.

Related Question