View previous topic :: View next topic |
Author |
Message |
hadadat n00b
Joined: 16 May 2015 Posts: 16
|
Posted: Tue Sep 20, 2016 5:40 am Post subject: Swap Space Not Being used LVM+LUKS |
|
|
I recently changed my partitioning to use LVM + LUKS since I made that change my swap space isn't being used even though it's reported as active
I have some programs that I need to run that consume a bunch of memory. Previously it would just activate my swap and the process would finish. Now the process consumes all memory and my swap space is not being used.
I checked dmesg, but there doesn't seem to be any messages about swap or memory usage in there.
Here's some info
Code: |
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 698.7G 0 disk
├─sda1 8:1 0 2M 0 part
├─sda2 8:2 0 128M 0 part
└─sda3 8:3 0 698.5G 0 part
└─root 254:0 0 698.5G 0 crypt
├─vg-lvol0 254:1 0 20G 0 lvm [SWAP]
├─vg-lvol1 254:2 0 50G 0 lvm /
└─vg-lvol2 254:3 0 628.5G 0 lvm /home
sr0 11:0 1 243.3M 0 rom
|
Code: |
#cat /etc/fstab
...
/dev/sda2 /boot ext2 noauto,noatime 1 2
/dev/mapper/vg-lvol0 none swap sw 0 0
/dev/mapper/vg-lvol1 / ext4 noatime 0 1
/dev/mapper/vg-lvol2 /home ext4 noatime 0 2
|
Code: |
# swapon -v -s
Filename Type Size Used Priority
/dev/mapper/vg-lvol0 partition 20971516 0 1
# cat /proc/sys/vm/swappiness
60
|
Does anyone have some idea of what could be causing this? I'm not sure how to start on this problem or what could be wrong.
I've tried doing swapoff swapon after booting, but I saw the same behavior. |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21618
|
Posted: Wed Sep 21, 2016 1:33 am Post subject: |
|
|
Is the device is listed in /proc/swaps? It should be, based on the deprecated output you provided. What is the output of free -m? Why do you think that the swap device is not usable? The system may elect not to swap in some cases. Are you seeing failures that you believe would not occur if swap was enabled? |
|
Back to top |
|
|
hadadat n00b
Joined: 16 May 2015 Posts: 16
|
Posted: Wed Sep 21, 2016 2:11 am Post subject: |
|
|
Code: |
# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/vg-lvol0 partition 20971516 0 -1
|
Code: |
# free -m
total used free shared buff/cache available
Mem: 7858 721 6234 127 902 6926
Swap: 20479 0 20479
|
I have a tool that I need to use that consumes all memory. Previously when this tool was running I could still use my system even with the load that it was putting on my system. I would observe my swap space being used.
When running the same tool once it consumes all memory my system is not usuable. When viewing the usage of my swap space it is always 0, even when reaching 100% memory usage. |
|
Back to top |
|
|
russK l33t
Joined: 27 Jun 2006 Posts: 665
|
Posted: Wed Sep 21, 2016 2:43 am Post subject: |
|
|
hadadat,
Did you mkswap ? Maybe redo it regardless:
Code: | # swapoff /dev/mapper/vg-lvol0 ; mkswap /dev/mapper/vg-lvol0 && swapon /dev/mapper/vg-lvol0 && echo yes
|
HTH |
|
Back to top |
|
|
hadadat n00b
Joined: 16 May 2015 Posts: 16
|
Posted: Wed Sep 21, 2016 2:54 am Post subject: |
|
|
russK wrote: | hadadat,
Did you mkswap ? Maybe redo it regardless:
Code: | # swapoff /dev/mapper/vg-lvol0 ; mkswap /dev/mapper/vg-lvol0 && swapon /dev/mapper/vg-lvol0 && echo yes
|
HTH |
I tried this and my swap space was still not being used.
Is there a command I can use to force something into swap to check if it fails?
Edit:
So I ran some more test and it ends up my swap space is being used. It's just extremely slow. I ran the tool that is consuming memory, once it seemed that it stalled my machine I went to bed. In the morning 8 hours later it still wasn't done, but my swap space was being used. This task use to take me 5 minutes before I switched to LVM+LUKS. I knew that there would be some overhead added using LUKS, but the speed that it's writing out to swap is ridiculous.
Is encrypted swap partitions really that much slower? Do people with the same setup have similar issues? |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21618
|
Posted: Thu Sep 22, 2016 1:07 am Post subject: |
|
|
I use encrypted swap on machines I plan to hibernate. I have done this for years and have never noticed performance problems at the scale you describe, neither on laptops nor on desktops. |
|
Back to top |
|
|
russK l33t
Joined: 27 Jun 2006 Posts: 665
|
Posted: Fri Sep 23, 2016 11:32 pm Post subject: |
|
|
hadadat,
If you're still having the issue maybe try running some common benchmarks and make sure the machine is otherwise performing as it should. Sometimes a machine can have issues that go unnoticed until you hit something like this.
Regards |
|
Back to top |
|
|
P151 n00b
Joined: 25 Sep 2016 Posts: 6
|
Posted: Sun Sep 25, 2016 3:27 am Post subject: |
|
|
hadadat wrote: | Is encrypted swap partitions really that much slower? Do people with the same setup have similar issues? |
I am posting from a laptop using LVM on LUKS (running Arch). LUKS is basically transparent to me as far as file transfer. Sustained read/write operations are within 5% of manufacturer claimed speeds on the drive.
Is it possible you have an overall issue with drive transfer, rather than just an issue with swap? (Legacy driver, unusual block size on 4K drive, drive dying?) |
|
Back to top |
|
|
1clue Advocate
Joined: 05 Feb 2006 Posts: 2569
|
Posted: Sun Sep 25, 2016 4:27 am Post subject: |
|
|
@hadadat,
Does this tool which consumes all memory require 8g or does it automatically consume all available memory no matter what size your memory is?
The others posting have covered everything I can think of regarding the mechanics of swap, but I have other comments regarding your use case.
In my strongly held opinion, to actually swap memory to disk due to lack of memory is always an error condition. Speaking directly to hardware use, swap is nearly catastrophic in what it does to your system. It causes the system to slow down to a relative crawl and it causes unnecessary disk wear. To have a system which continually uses swap in its normal day-to-day business is asking for trouble.
The system I'm using has actually used swap exactly twice. The first time I upgraded from 6gb RAM to 12gb RAM, and the second time I doubled it again. I'm now using 24gb RAM, still have swap configured but have not "used" it for a long time. The box is about 5 years old. I use "swap" not only for traditional swap but also for tmpfs.
Getting back to your use case, if the app you're using requires 8g RAM and cannot be configured to use less, then I recommend buying more memory. If it automatically grabs everything the system has and cannot be configured to not do that, then it's my strongly held opinion that you have crappy software and should look for an alternative. |
|
Back to top |
|
|
|