16

I am on Ubuntu 12.04, Thinkpad Edge 13, encrypted home. A message in the System Monitor tells me that swap is "not available". I can get it back using the swapon option in gparted (I thought I could also do sudo swapon -a in a terminal, but that does not work). The problem is that I have to swapon after every reboot. How can I switch it back on so it stays on even after a reboot?

my fstab:

# # <file system> <mount point> <type> <options> <dump> <pass> 
proc /proc proc nodev,noexec,nosuid 0 0 
# / was on /dev/sda5 during installation 
UUID=47641b93-9d12-4e6a-b803-dde28f0e5725 / ext4 errors=remount-ro 0 1
3
  • Can you post your /etc/fstab?
    – user91091
    Oct 12, 2012 at 10:58
  • # /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> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda5 during installation UUID=47641b93-9d12-4e6a-b803-dde28f0e5725 / ext4 errors=remount-ro 0 1
    – geoffrey
    Oct 12, 2012 at 13:37
  • You realise the two UUIDs you posted above are actually different? There's a "-8" missing after the "4aa8" block in the swapon response (and I suppose in fstab as well).
    – user148539
    Apr 11, 2013 at 13:02

2 Answers 2

27

You have no configuration for swap in /etc/fstab. Add following line to that file:

UUID=<uuid> none   swap    sw    0       0   

You have to replace <uuid> with the uuid of your swap partition. To do that, run sudo blkid

$ sudo blkid
/dev/sda1: LABEL="System Reserved" UUID="88A0D0A1A0D09752" TYPE="ntfs" 
/dev/sda2: UUID="0620D9F920D9EFA3" TYPE="ntfs" 
/dev/sda5: UUID="c282b418-2045-4852-8789-88a44360a0bb" TYPE="ext4" 
/dev/sda6: UUID="f99c6a0c-790a-45ca-a1a9-8874f5a2999b" TYPE="ext4" 
/dev/sda7: UUID="4cc2e909-ebd1-4c72-abee-aa32035bf330" TYPE="swap"

This is a list of my partitions, and as you see, /dev/sda7 is my swap partition. So you can copy the value of UUID corresponding to your swap, omitting the quotes, and use it for your fstab file.

2
  • And what if among the rows returned by sudo blkid there isn't one with 'TYPE="swap"'?
    – reallynice
    Sep 15, 2014 at 14:26
  • @niconic you'll need to create swap partition
    – Len
    May 26, 2015 at 12:07
3

After the upgrade to 12.04, certain little anomalies occurred. I was unaware my swap partition wasn't working until I tried to open a large file in Gimp.

blkid shows:

/dev/sdb6: UUID="3e0550cf-4a55-4aa8-80fa-24103c1b25a7" TYPE="swap" 

but it is not active according to System Monitor. The UUID was definitely right but no go ... not sure how I got to this command:

blkid -p /dev/mapper/foo-swap_1
error: /dev/mapper/foo-swap_1: No such file or directory

File manager showed me a 0 byte icon, filename control, -- so what was supposed to be written there? By what?

sudo swapon --all --verbose yielded
swapon: cannot find the device for UUID=3e0550cf-4a55-4aa80fa-24103c1b25a7

I edited the /etc/fstab file adding

/dev/sdb6   none    swap    sw  0   0

Reboot and System Monitor shows it active.

This was the first site I found for help; in my case, the UUID did not work even though it was in fstab, so there is something missing 'in the middle'. This may help someone, who knows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.