Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Swap not being used?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Budoka
l33t
l33t


Joined: 03 Jun 2012
Posts: 687
Location: Tokyo, Japan

PostPosted: Sat Aug 30, 2014 7:11 pm    Post subject: Swap not being used? Reply with quote

I have been checking randomly using htop and as best I can tell my swap partition isn't being utilized at all. It is always zero. Does this mean I have something misconfigured and if so how do I diagnose it? Is it necessarily a bad thing to have no swap? I only noticed it was being used by chance and haven't seen any unusual behavior with my laptop to date. I am able to "sleep" and "hibernate" without any problem so I assume swap is being used then but if I want to forego that functionality can I get rid of it since my system isn't using it anyway?

Quote:
# fdisk -l

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x14317ff8

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 212019199 105906176 7 HPFS/NTFS/exFAT
/dev/sda3 212019200 1908707327 848344064 f W95 Ext'd (LBA)
/dev/sda4 1908707328 1953521663 22407168 12 Compaq diagnostics
/dev/sda5 212021248 230985727 9482240 7 HPFS/NTFS/exFAT
/dev/sda6 230987776 231397375 204800 83 Linux
/dev/sda7 231399424 1908707327 838653952 83 Linux


Disk /dev/sdb: 7.5 GiB, 8012390400 bytes, 15649200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x74f02dea

Device Boot Start End Blocks Id System
/dev/sdb1 2048 15646719 7822336 73 Unknown


Disk /dev/mapper/root: 799.8 GiB, 858779549696 bytes, 1677303808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/vg-root: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/vg-swap: 9 GiB, 9663676416 bytes, 18874368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/vg-var: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/mapper/vg-home: 750.8 GiB, 806162006016 bytes, 1574535168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sat Aug 30, 2014 7:29 pm    Post subject: Reply with quote

Just remove it from your fstab entry or use swapoff to stop using it.
Now you can test really without one and stop guessing if you need one or not. Better than removing that partition just to discover you were in need of it.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43186
Location: 56N 3W

PostPosted: Sat Aug 30, 2014 7:40 pm    Post subject: Reply with quote

Budoka,

Your swap can only be used for dynamically allocated memory.
Because of the way Linux works, any data or code that has a permanent location on disk can be 'swapped' just by flushing the RAM. It will be reloaded when its needed again.

If you don't have any swap, the kernel is forced to keep dynamically allocated memory in RAM. This cam be a bad thing, an the kernel will flush data/code to free up RAM.

Swap not being used is not wrong, its just that the kernel has net decided to use it yet. Thats not the same as saying you don't need swap.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Budoka
l33t
l33t


Joined: 03 Jun 2012
Posts: 687
Location: Tokyo, Japan

PostPosted: Sat Aug 30, 2014 7:49 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Budoka,

Your swap can only be used for dynamically allocated memory.
Because of the way Linux works, any data or code that has a permanent location on disk can be 'swapped' just by flushing the RAM. It will be reloaded when its needed again.

If you don't have any swap, the kernel is forced to keep dynamically allocated memory in RAM. This cam be a bad thing, an the kernel will flush data/code to free up RAM.

Swap not being used is not wrong, its just that the kernel has net decided to use it yet. Thats not the same as saying you don't need swap.


Thanks Neddy. I kind of understand what you are saying but how can I tell that the kernel actually has access to the swap partition if it isn't being used as far as I can tell. I guess I am concerned that I may have incorrectly configured my install somehow.

Also do you think I may have over or under allocated memory to swap and that might be part of what is going on?

Quote:
# cat /proc/meminfo
MemTotal: 8092340 kB
MemFree: 3981820 kB
MemAvailable: 5260956 kB
Buffers: 228308 kB
Cached: 1137228 kB
SwapCached: 0 kB
Active: 3024932 kB
Inactive: 867916 kB
Active(anon): 2533748 kB
Inactive(anon): 109872 kB
Active(file): 491184 kB
Inactive(file): 758044 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 9437180 kB
SwapFree: 9437180 kB
Dirty: 1384 kB
Writeback: 0 kB
AnonPages: 2527276 kB
Mapped: 251108 kB
Shmem: 116320 kB
Slab: 109096 kB
SReclaimable: 72532 kB
SUnreclaim: 36564 kB
KernelStack: 5464 kB
PageTables: 47876 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 13483348 kB
Committed_AS: 6333280 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 367804 kB
VmallocChunk: 34359357688 kB
DirectMap4k: 8128 kB
DirectMap2M: 8292352 kB
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43186
Location: 56N 3W

PostPosted: Sat Aug 30, 2014 8:04 pm    Post subject: Reply with quote

Budoka,

Code:
# cat /proc/meminfo
MemTotal: 8092340 kB
MemFree: 3981820 kB


You have 8G RAM and have used less than half of it. You will need to make your system work hard to push it into swapping.

Run top in a terminal window. In another terminal window - keep top visible, do
Code:
cd /usr/src/linux
make -j 40


This will compile the kernel, allowing 40 parallel makes which will put the pressure on a bit.
It may even lock op your box, so you might want to start with smaller numbers.
Running gcc 40 times might well push you into swapping.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
cwr
Veteran
Veteran


Joined: 17 Dec 2005
Posts: 1969

PostPosted: Sun Aug 31, 2014 2:45 pm    Post subject: Reply with quote

You'll know when the system starts swapping - you'll be running in molasses.

I have 2G of RAM on a 32 bit system and generally zero swap, though sometimes it will
use one or two MB. I run Conky on my desktop, so I can keep an eye on swap and
other stuff, and really, it's never touched. I just keep it for use by hibernation.

Will
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1746

PostPosted: Sun Aug 31, 2014 3:20 pm    Post subject: Reply with quote

Use 'free' to check your memory usage.
Code:
free -h
             total       used       free     shared    buffers     cached
Mem:          7.3G       6.4G       965M       6.0M        74M       4.2G
-/+ buffers/cache:       2.1G       5.2G
Swap:           0B         0B         0B

Here you have an example with no swap at all.
I just though I won't run out of RAM anyway, even while compiling OOo in memory :)

If you want to see your system using swap, you can use sysctl to change swappiness to 100. On the other hand, setting swappiness to 0 makes system avoid swapping stuff from RAM unless it's really nessecery.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43186
Location: 56N 3W

PostPosted: Sun Aug 31, 2014 3:24 pm    Post subject: Reply with quote

szatox,

Now build libreoffice and firefox at the same time :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum