LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-13-2010, 03:35 PM   #1
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Reclaim swap memory


I have 5.8GB of RAM.
I have 6.1GB of swap.

At some point in time my VMs exceeded the 5.8GB limit and overflowed into swap (all dev VMs). I have since shut down the VMs and restarted Firefox (memory hog).

Right now I have 0.73GB in RAM and 0.29GB in swap. I want to move all of the data in swap into RAM where it will be faster. So I will end up with 1.02GB in RAM and 0GB in swap.

Is there a quick command to move data contained within swap to RAM? I know of the swapon/swapoff command. I was wondering if there was another method which clears swap.

Last edited by sag47; 12-13-2010 at 04:07 PM.
 
Old 12-13-2010, 03:44 PM   #2
no2498
Member
 
Registered: Jan 2010
Posts: 120

Rep: Reputation: 23
? do you not just type free m in the terminal
 
Old 12-13-2010, 04:06 PM   #3
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899

Original Poster
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
man free says "free - Display amount of free and used memory in the system". It only displays information. This doesn't free swap at all. Not sure where you're going with that. If it is capable of being my solution then care to emphasize?

I modified my question a little and bolded it. Perhaps you didn't understand my original question.

Last edited by sag47; 12-13-2010 at 04:08 PM.
 
Old 12-13-2010, 04:42 PM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
if you are using swap then chances are its because you ram is full, wanna pull stuff out of swap? probably the best way to do that is to get more ram, swap is not like a regular hard drive partition that will eventually get full and need wiping it is constantly being written, over-written and erased as it is used.
 
Old 12-13-2010, 05:38 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Are you talking about the host RAM/swap ?.
There is no sensible alternative to swap{off,on} - why do you not want to use it ?. It's quick, and it works. If there is insufficient RAM to hold all the swap resident pages, the swapoff fails, no damage done.
I suspect you aren't actually using that swap anyway - Linux uses lazy deallocation, and the pages will only be reclaimed (and flags cleared) if needed. So they'll (probably) already be unused, but stale.
 
Old 12-14-2010, 02:58 PM   #6
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899

Original Poster
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Well I tried the swapoff command but it doesn't work with no arguments. I just have to look up how it's formatted. I just wondered if there was a one shot deal which moved swap data into RAM.

Thanks for the responses guys/gals.
 
Old 12-14-2010, 03:34 PM   #7
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
You need to tell swapoff which partition is the swap partition

For instance,
Code:
swapoff /dev/sda5
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reduce swap space and reclaim the space grantm Linux - Newbie 7 08-16-2012 07:05 AM
Memory Page Scanning and Reclaim/Memory Management ilfantomas Linux - Kernel 1 03-02-2010 08:31 PM
system doesnt reclaim the freed memory after free() muralia Linux - Newbie 2 07-20-2009 10:56 PM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration