4

My system is freezing when the memory used is maxed out and I was wondering why. Turns out the swap is not being used. Here's my partition table:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63       80324       40131   de  Dell Utility
/dev/sda4           81918   909195263   454556673    5  Extended
/dev/sda5       512121690   909195263   198536787   83  Linux
/dev/sda6           81920     3987455     1952768   83  Linux
/dev/sda7         3989504   140705791    68358144   83  Linux
/dev/sda8       492589056   512120831     9765888   82  Linux swap / Solaris
/dev/sda9       140707840   492584959   175938560   83  Linux

The swap partition is not turned on and doesn't show in df but it does in the disks utility:

Filesystem             Size  Used Avail Use% Mounted on
udev                   1.9G  4.0K  1.9G   1% /dev
tmpfs                  392M  1.3M  391M   1% /run
/dev/sda7               65G   19G   43G  31% /
none                   4.0K     0  4.0K   0% /sys/fs/cgroup
none                   5.0M     0  5.0M   0% /run/lock
none                   2.0G   26M  1.9G   2% /run/shm
none                   100M   48K  100M   1% /run/user
/dev/sda6              1.9G   89M  1.7G   6% /boot
/dev/sda9              166G   47G  111G  30% /home
/home/my-user-name/.Private  166G   47G  111G  30% /home/my-user-name

enter image description here

$ sudo swapon -s
Filename                Type        Size    Used    Priority

As you can notice my Home partition is encrypted but I have not encrypted the swap.

Swap seems declared in /etc/fstab:

# swap was on /dev/sda8 during installation
#UUID=df55bf68-b824-4f21-83f3-dfa80a0b74ab none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

I'd like to know why it's not working and how can I fix it?

Update It seems there's a reported bug on this for several releases and has not been fixed for 14.04 yet.

Here's the result of cat /etc/crypttab:

cryptswap1 UUID=df55bf68-b824-4f21-83f3-dfa80a0b74ab /dev/urandom swap,cipher=aes-cbc-essiv:sha256

And what was suggested by A.B.:

$ sudo /etc/init.d/cryptdisks reload
 * Stopping remaining crypto disks...                                                                    [ OK ]
 * cryptswap1 (stopped)...                   
 * Starting remaining crypto disks...
 * cryptswap1 (skipped, device /dev/disk/by-uuid/df55bf68-b824-4f21-83f3-dfa80a0b74ab does not exist)... [fail]
                                                                                                         [ OK ]
$ sudo swapon -a
swapon: /dev/mapper/cryptswap1: stat failed: No such file or directory

Based on David Foerster's answer I did cat /dev/disk/by-uuid/ and got 6 uuid's. Did blkid -U of each and non is /dev/sda8 which the swap is supposed to be. I got sda's 1, 5, 6, 7, 9, and /dev/mapper/luks-****. The last of which I think is the other encrypted partition that I left untouched during installation (was encrypted by 12.04).

I also tried the following answer. Did not work either.

Update: I ended up reformatting the partitions and re-installing the system. It seems working fine now.

user10853
  • 1,626

2 Answers2

2
cryptswap1 (skipped, device /dev/disk/by-uuid/df55bf68-b824-4f21-83f3-dfa80a0b74ab does not exist)

Whatever volume had UUID=df55bf68-b824-4f21-83f3-dfa80a0b74ab, when that /etc/crypttab entry was generated, doesn't exist any longer.

How to fix it

  • Run sudo swapoff -a just to make sure that all swap spaces are released. The output of swapon -s should now be empty (apart from a column header line).

  • Remove (or comment out) the lines about swap in /etc/fstab and /etc/crypttab. Make back-ups, if you're unsure.

  • You say you want to place swap on /dev/sda8. Ignore it's current content for the remainder of these instructions; treat is a garbage data. You will lose all data on sda8 in the process! Make a backup, if you value it!

  • Set up a new swap space on /dev/sda8, either unencrypted or encrypted.

My previous advice (please use the above one instead)

Since raw devices (or raw dm-crypt devices) don't have UUIDs, you'll need to resort to other device identifiers. Kernel names (/dev/sd* and friends) aren't stable across boots, so your best bet is to find the entry inside /dev/disk/by-id/, that links to your intended encrypted swap partition. Those are stable enough in my experience (barring changes in the kernel or udev scripts).

Assuming that /dev/sda8 is the intended place for the encrypted swap partition, you can find it's ID-based path(s) in the output of

ls -l /dev/disk/by-id/* | grep sda8

or more elaborately with:

find -L /dev/disk/by-id -samefile /dev/sda8

You can use one of the results for the second column of the crypttab entry.

David Foerster
  • 36,890
  • 56
  • 97
  • 151
-2

I think you have an error in your /etc/fstab file. You swap does not have mount point.

Change the line

/dev/mapper/cryptswap1 none swap sw 0 0

to

/dev/mapper/cryptswap1 swap swap defaults 0 0
Quentin
  • 1,317