2

I'm in dire need of help.

My system has become incredibly laggy and hardly usable. I have realised that this is because for some reason I'm running without virtual memory (this is not intentional). It is a recent phenomenon and the system was much more responsive until a couple of days ago, so I can only summarise it is a recent phenomenon. I cannot think of anything I did to cause this (except attempt to use the Hibernation feature, which failed - did it maybe fill up my swap partition with garbage and leave it there? I do not know. How could I find out?)

As a novice my difficulty is compounded by the fact that I am running on a fully encrypted SSD using LUKS. Everybody keeps posting me links to pages where people have posted links, and honestly I am hopelessly out of my depth. Searching for information with a machine that takes ten seconds to register a keypress is no fun, I assure you.

(Of course this situation persists across reboots)

First, proof of the situation: swapon indicates I have no swap:

user@host:~$ sudo swapon -s
[sudo] password for user: 
Filename                Type        Size    Used    Priority
user@host:~$ 

Secondly, the output of df, indicating how my filesystems are mounted:

user@user~$ df
Filesystem                  1K-blocks     Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-root 237978256 14110548 211756044   7% /
none                                4        0         4   0% /sys/fs/cgroup
udev                          3829132        4   3829128   1% /dev
tmpfs                         3844736        8   3844728   1% /tmp
tmpfs                          768948     1256    767692   1% /run
none                             5120        0      5120   0% /run/lock
none                          3844736    20948   3823788   1% /run/shm
none                           102400       16    102384   1% /run/user
tmpfs                         3844736        0   3844736   0% /var/spool
tmpfs                         3844736       24   3844712   1% /var/tmp
tmpfs                         3844736      624   3844112   1% /var/log
/dev/sda1                      240972    84550    143981  37% /boot
/home/user/.Private        237978256 14110548 211756044   7% /home/user
user@host:~$ 

Next, my /etc/fstab file, as it currently stands:

# /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>
/dev/mapper/ubuntu--vg-root /               ext4 discard,noatime,nodiratime,errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation UUID=db8c65e2-82fd-492c-8f02-8ad140f7337b /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0

tmpfs   /tmp    tmpfs   defaults,noatime,mode=1777  0   0
tmpfs   /var/spool  tmpfs   defaults,noatime,mode=1777  0   0
tmpfs   /var/tmp    tmpfs   defaults,noatime,mode=1777  0   0
tmpfs   /var/log    tmpfs   defaults,noatime,mode=1777  0   0

Finally, I'd like to mention that I booted into a Live-USB distro, and used system-config-lvm to have a look at my unmouned LVM, and /dev/ubuntu-vg/swap_1 is indeed there.

I don't know what else to do. It's taken three hours to type this.

EDIT: adding output of cat /etc/exports/:

user@host:~$ cat /etc/exports
cat: /etc/exports: No such file or directory
user@host:~$

and the output of top

top - 19:10:16 up 32 min,  3 users,  load average: 0.18, 0.11, 0.07
Tasks: 202 total,   1 running, 201 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.7 us,  0.7 sy,  0.0 ni, 98.5 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   7689472 total,  1220864 used,  6468608 free,    44020 buffers
KiB Swap:        0 total,        0 used,        0 free.   549276 cached Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                      
1396 root      20   0  288660  48264  40612 S   1.7  0.6   0:03.80 Xorg                                                                         
2279 user     20   0  856444  16252  11668 S   1.0  0.2   0:01.67 lxterminal                                                                   
3140 user     20   0 1169836 142804  60396 S   0.7  1.9   0:09.86 chrome                                                                       
635 root     -51   0       0      0      0 S   0.3  0.0   0:00.41 irq/62-iwlwifi                                                               
3118 ntp       20   0   33504   2136   1528 S   0.3  0.0   0:00.04 ntpd                                                                         
3326 user     20   0 1038132 111152  48620 S   0.3  1.4   0:11.06 chrome                                                                       
3374 user     20   0   29192   1736   1212 R   0.3  0.0   0:00.03 top                                                                          
1 root      20   0   34052   3436   1484 S   0.0  0.0   0:03.97 init                                                                         
2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd                                                                     
3 root      20   0       0      0      0 S   0.0  0.0   0:00.00 ksoftirqd/0                                                                  
5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                 
7 root      20   0       0      0      0 S   0.0  0.0   0:00.24 rcu_sched                                                                    
8 root      20   0       0      0      0 S   0.0  0.0   0:00.08 rcuos/0                                                                      
9 root      20   0       0      0      0 S   0.0  0.0   0:00.06 rcuos/1                                                                      
10 root      20   0       0      0      0 S   0.0  0.0   0:00.07 rcuos/2                                                                      
11 root      20   0       0      0      0 S   0.0  0.0   0:00.10 rcuos/3                                                                      
12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/4              

Searching around desperately (as best one can while faced with my present situation, anyway) I have found this ancient thread about somebody having problems with cryptswap, but honestly I'm too much of a novice to understand what he is on about and how to use mkswap to remake the swap partition (honestly, it isn't even clear to me what parameters I would need to pass to mkswap to avoid nuking my system by accidentally overwriting my main partition... I saw in fstab that I seem to have two entries that look swap-like (swap_1 and cryptswap) and I do not know which of the two would be the hypothetical target, not to mention all the deep jargon.)

qubex
  • 425
  • 9
  • 22
  • Are you sharing a folder using NFS? My CPU was eaten by the kworker thread by sharing a folder on an encrypted drive. Using sshfs, or using unencrypted drives resolved the issue for me. – Programster May 18 '14 at 16:26
  • Not having swap should appear to increase performance, not decrease it. However if you run out of RAM your processes may die "silently" – Programster May 18 '14 at 16:28
  • How can I check what is happening? All I know is that it is unusably slow (so slow that sudo times out while I laboriously type in my long superuser password, severly hampering my ability to fix things) and that, contrary to my expectations, I have no virtual memory or swap partition enabled. Beyond that it is all idle speculation. If somebody can indicate how I can find these facts out, I will do so gladly so as to increase chances of somebody diagnosing the problem. I don’t think I am using NFS but how do I find out if I am, and how do I kill it while I figure things out?? – qubex May 18 '14 at 16:44
  • If you are the only person who has configured the computer and you don't know if you are using NFS, then chances are that you're not. You can always check by running cat /etc/exports and check there is nothing in there. As for virtual memory, I'd be amazingly surprised if you indeed weren't using any (You use virt memory even if you aren't using swap, just see under VIRT when you run top). It would be helpful me and others if you took the largest possible screenshot of your top, or htop so we can see your running processes. – Programster May 18 '14 at 17:06
  • Do you have any idea why I am experiencing this now that you have seen my top output? I have also tried disconnecting from WiFi (this is a laptop) to see if that killed any wayward network processes but to no avail. – qubex May 18 '14 at 20:36
  • Can somebody please answer my basic question: why is my computer not using (and apparently unable) to use swap/vm even though it is set up? Would it be able to if it needed to? There’s a lot of commentary on cryptswap and so forth but much of it is opaque and impenetrable. Thanks. – qubex May 19 '14 at 06:12
  • 1
    Looking at top, I couldn't see anything unusual but maybe someone else will. I believe the reason nobody else has added anything is because they can't see anything obvious either and more context may be required. I really don't think the issue is that you don't have any swap partition mounted. If you really think it is, go ahead and give this a try this to manually add swap http://programster.blogspot.co.uk/2013/11/ubuntu-1204-add-swap-to-your-ec2.html. If I was in your position I would reinstall ubuntu without encrypting my drive and see if the problem goes away. – Programster May 19 '14 at 06:42
  • Reinstalling my system now that it is almost the way I like it just for the sake of experiment seems a bit harsh (particularly as, for policy reasons, I will need to keep encryption enabled). I did however boot from a Live-USB installation (Xubuntu 14.04 which I keep handy for such situations) and nothing was amiss, though of course that does not use VM and indeed creates ramdisks (a roughly opposite predicament). The slowdown I experienced may be coincidental, but the lack of swap and virtual memory is real and might easily result in heartbreak in a near future, so I wish to solve it somehow. – qubex May 19 '14 at 07:30

3 Answers3

2

I was having the same issue, Eliah Kagan's answer on this other thread did the trick for me.
Here's the most important bit:

  1. Open a Terminal window (Ctrl+Alt+T) or a virtual console and run: sudo swapoff -a
  2. Open /etc/crypttab (e.g., sudo nano -w /etc/crypttab or sudo -H gedit /etc/cryptab for a GUI editor) and put a # at the beginning of the line that starts with cryptswap1. Save the file.
  3. Do the same thing with the line that starts with /dev/mapper/cryptswap1 in /etc/fstab.
  4. Install gparted Install gparted. Run it and format your swap partition as linux-swap. Make sure to get the right partition; if you get the wrong one, you'll lose possibly important data! The line you commented out in crypttab should give the correct partition name (it comes right after /dev/).
  5. Run sudo mkswap /dev/..., repacing ... with that same device name. Part of that command's output should be text that says UUID=..... where ..... is a string of letters and numbers.
  6. In the file /etc/initramfs-tools/conf.d/resume, find the line that says RESUME=UUID= followed by letters and numbers like (but not identical to) ..... from the last step. Replace them with ..... (i.e., with the letters and numbers mkswap gave after UUID=.
  7. Run sudo swapon /dev/... (with the same /dev/... as you had in steps 4 and 5 above).
  8. Run sudo ecryptfs-setup-swap.

swapon -s will check to see if swap is successfully enabled. See that blog post for more information, and example output, for checking this.

No more laggy behavior ð‿ð enter image description here hey look, imgur gave the image a palindromic name

JorgeArtware
  • 3,527
  • 1
  • 21
  • 23
1

I’m not sure whether this qualifies as a ‘solution’ (insofar as I am not quite sure what I have solved beyond successfully re-enabling virtual memory) but by commenting out the ‘cryptoswap’ line in /etc/fstab so it reads

# /dev/mapper/cryptswap1 none swap sw 0 0

allows swapon to succeed in activating swap on /dev/mapper/ubuntu—-vg-swap_1

The lag I had noticed seems to be related to TPM (power management), but I don’t know how to solve that yet. I’ve just discovered that by connecting to an external power supply the issue disappears until the next reboot.

qubex
  • 425
  • 9
  • 22
1

Your basic problem has nothing to do with swap. Lack of swap leads to OOM crashes, not lags. I think your problem is that you have LUKS encrypted disk, and put ecryptfs encrypted home folder over it (unless, of cause, you manually called your mount point ~/.Private for some reason ) This leads to vast overusage of CPU, which only increases the more files you put in you home directory.
I suggest you remove home folder encryption or at least move all your non-hidden files out of it somewhere else.