Dirtbag's Blog

Where the hell did my swap go?!

[ link: swapbegone | tags: linux | updated: Fri, 17 Apr 2020 12:12:08 -0400 ]

I was minding my own business one day compiling away on my laptop. From out of nowhere, I start getting funky errors during my emerges! Read on for the full scoop.

Here is the output from the top command.. Notice swap space is suspiciously absent!

top - 11:51:49 up 83 days, 21:42,  4 users,  load average: 0.60, 2.46, 2.22
Tasks: 174 total,   1 running, 173 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  0.2%sy,  0.0%ni, 98.8%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0%st
Mem:    905664k total,   689568k used,   216096k free,     1916k buffers
Swap:        0k total,        0k used,        0k free,    87460k cached 

WTF?!?!

zim jason # swapon /dev/sda2
swapon: /dev/sda2: Invalid argument

So anyway, here is how I fixed it.

zim jason # mkswap /dev/sda2
zim jason # swapon /dev/sda2

So now things are much happier! ;)

top - 11:56:23 up 83 days, 21:47,  4 users,  load average: 0.99, 1.43, 1.82
Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us, 17.1%sy, 19.3%ni, 48.6%id, 14.0%wa,  0.2%hi,  0.5%si,  0.0%st
Mem:    905664k total,   888836k used,    16828k free,    33268k buffers
Swap:  1958032k total,     1868k used,  1956164k free,   229364k cached

-db

Like this article? Buy me a beer!