4

I recently increased space and swap space for ubuntu on my laptop. Even though the space got increased, my swap is not being recognized. It is showing as 0 bytes of space. However, interestingly, when I boot from live cd and click try ubuntu, space for swap is being recognized.

What can be causing this weird problem?

Normal Boot: enter image description here

bhaarat@bhaarat-laptop ~ % free
             total       used       free     shared    buffers     cached
Mem:       1015780     954008      61772          0      49836     449444
-/+ buffers/cache:     454728     561052
Swap:            0          0          0

Live CD Boot enter image description here

ubuntu@ubuntu:~$ free
             total       used       free     shared    buffers     cached
Mem:       1015780     983500      32280          0      87408     558984
-/+ buffers/cache:     337108     678672
Swap:     13590952        384   13590568

Outputs in Live CD Boot

Output of grep swap /etc/fstab

/dev/sda6 swap swap defaults 0 0

Output of sudo fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
240 heads, 63 sectors/track, 10337 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2bd2c32a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda2               1       10338    78149632    5  Extended
/dev/sda5   *           1        8539    64551936   83  Linux
/dev/sda6            8540       10338    13590958+  82  Linux swap / Solaris

Output of sudo swapon -a No output

Gparted Screenshot: enter image description here

Update contents of cat /proc/swaps after the fix are:

 Filename Type Size Used Priority 
 /dev/sda6 partition 13590952 0 -1

3 Answers3

5

Is the swap enabled? swapon <device>

See cat /proc/swaps

If it's listed, then it's enabled. If not, then the system isn't using it as swap.

blkid | grep swap

It appears your fstab entry looks incorrect.

Try using the line:

/dev/sda6 none swap sw 0 0

Then sudo swapon -a

You can try using UUID you get from blkid command above and using that in place of /dev/sda6

papashou
  • 2,440
  • 1
  • 14
  • 9
0

Try adding /dev/sda6 none swap sw 0 0 to /etc/fstab, which you can do with the following commands (enter them in a terminal):

  1. sudo su
    (Now it should ask for your password. Enter it and press enter to continue)
  2. echo "/dev/sda6 none swap sw 0 0" >> /etc/fstab

After that, reboot your system and check again.


For people who are wondering why I'm using sudo su, in stead of just su; su doesn't appear to work for me anymore in Ubuntu 12.04.

RobinJ
  • 8,910
0

When you resize your swap it changes the UUID name in /etc/fstab. If you don't have a label (/dev/sda5 for example) in your /etc/fstab file it will not recognize the new swap. As it explains in the fstab file, using UUID is more robust in some cases (obviously not in this one).

Unmount the swap drive and copy it's UUID:

>sudo swapoff -av
swapoff on /dev/sda5

>sudo mkswap /dev/sda5
Setting up swapspace version 1, size = 16604156 KiB
no label, UUID=f0ac7203-dac5-479b-a33a-be7a3dca6aae

Update the UUID of your swap in /etc/fstab to the new value from the step above:

>sudo vim /etc/fstab

Now remount, note the identical swapsize and devsize:

>sudo swapon -a --verbose
swapon on /dev/sda5
swapon: /dev/sda5: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/sda5: pagesize=4096, swapsize=17002659840, devsize=17002659840

Although looking at the accepted answer above I see now what I needed to know, I wanted to make it more explicit here after finding the answer in Pollox's post

Most responses to my problem suggested changing the `/etc/fstab' line to use the label rather than the UUID. I was hesitant to do so and therefore was unable to resolve the issue until I came across the fact that the UUID changes as well.

Cyrille
  • 111
  • 3