Howto: 1. freeupRAM ; 2. freeswap ; 3. runaway /sbin/udevb

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

Howto: 1. freeupRAM ; 2. freeswap ; 3. runaway /sbin/udevb

#1 Post by mcewanw »

HOWTO free up RAM of reserved cache and buffers space:

1. A long time ago I posted a tip on how to regularly free up RAM of the caches and buffers used by Linux (the cache and buffers used does gradually fill up again of course):
http://www.murga-linux.com/puppy/viewtopic.php?t=43298

Code: Select all

#!/bin/sh
sync && echo 3 > /proc/sys/vm/drop_caches
I somewhat unnecessarily uploaded it as a one liner script called freeupram too:
http://www.murga-linux.com/puppy/viewto ... 596#356501

It works.


HOWTO free up swap space:

2. However, for a long time I've noticed another problem in terms of my low-memory (256MByte) low-end (500MHz CPU) old laptop machine, which is currently running Wary 500:

Even when quite a bit of free RAM remains available... the machine has a tendency to eventually use a little swap. Once that happens, I've observed that the machine becomes noticably slower... (even when the amount swapped stays very low - a few tens of kilobytes even...). I suspect a problem with the algorithm used in Linux to determine when swap should occur.

For my machine, I'd like to have no swapping at all unless a certain percentage of RAM was being utilised, but I know of no method for doing exactly that.

I've tried: echo 0 > /proc/sys/vm/swappiness; a mechanism I earlier also discussed here: http://www.murga-linux.com/puppy/viewto ... 506#313208

In practice, however, that does not stop swap occurring.

What does I find work, which is why I'm providing this tip, and I've been using this method for a long time, is to regularly empty swap as follows:

Code: Select all

swapoff <whatever_your_swap_partition_is> 
# on my machine I use: swapoff /dev/sda3 (since that's my swap partition...)
swapon <whatever_your_swap_partition_is>
(Note that on my machine I use /dev/sda3 as my swap partition).

You might like to run "sync" first though I rarely bother...

So if you've noticed your system gradually slowing down, the method I'm suggested may be the "keep-your-old-machine-running-fastish" solution you need...

The method isn't perfect, because if the system RAM really is over-utilised, turning off swap as per the above can crash the system. However, today, when I was looking into the matter further, I stumbled across the following script at help.ubuntu.com which suggested the same as I already do, but which checks for the RAM already over-utilised danger. I haven't bothered providing a ready-made script of this, so just cut and paste it into your favourite text editor, save it as, say, "freeswap", make the script executable and put it in, for example, in /usr/sbin or somewhere in your else in your "PATH"):

Very slightly modified from https://help.ubuntu.com/community/SwapFaq:

Code: Select all

#!/bin/sh
err="not enough RAM to write swap back, nothing done"
mem=$(free|grep Mem:|awk '{print $4}')
swap=$(free|grep Swap:|awk '{print $3}')
[ $mem -lt $swap ] && echo -e $err && exit 1
swapoff <whatever_your_swap_partition_is> && swapon <whatever_your_swap_partition_is> && exit 0
You need to of course replace <whatever_your_swap_partition_is> with whatever it is... (or use the -a option to swap if all your swap partitions are listed in /etc/fstab)

HOWTO somewhat drastically at least resolve a runaway /sbin/udev daemon problem I've come across in irregular circumstances:

3. One last thing I've come across in this system-slowing-down regard (which is probably hard to reproduce without the dodgy power connector problem I have...):

One of my old laptop machines (300MHz Celeron, 256 MBytes, running Wary 500) has a dodgy power connector. For reasons I know nothing about, that occasionally causes a great deal of activity from the daemon: /sbin/udevd --daemon --resolve-names=never Indeed, running "top" when that happens reveals the CPU io load becomes really high when the power becomes intermittent in that fashion; the fan turns on and the machine slows to a crawl... Killing off the /sbin/udevd daemon then has the dramatic effect of fixing the problem... I do wonder why /sbin/udevd doesn't recover by itself when I jiggle the power connector about a bit, which does restore "regular" power to my machine. Perhaps someone has an answer. For now I just mention it here, with what at least is a (somewhat drastic) "remedy".

[EDIT: I'm currently experimenting with running freeupram and freeswap regularly (every ten minutes or so) with cron (in Wary at least, you can use Menu->System->Pschedule to conveniently set up crontab entries)]
Last edited by mcewanw on Sun 01 May 2016, 07:36, edited 1 time in total.
github mcewanw

Guy
Posts: 52
Joined: Mon 26 May 2008, 22:17

sorry post not working

#2 Post by Guy »

I saw your post & thought of this:

https://help.ubuntu.com/community/SwapFaq#What is swappiness and how do I change it?

this should deter the kernel from using swap when you still have RAM

Hope this helps
G

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#3 Post by Flash »

Guy, I removed the URL tags. The forum has a quirk where, if it doesn't think the URL inside the tags is valid, it will show a blank post.

Guy
Posts: 52
Joined: Mon 26 May 2008, 22:17

#4 Post by Guy »

@Flash - thanks. You have no idea how many ways I tried to sort this.

jakfish
Posts: 762
Joined: Fri 18 Jul 2008, 19:09

#5 Post by jakfish »

mcewanw--

This was an extremely helpful post, many thanks. I'm running 4.31 on an old Sony Vaio Picturebook, only 114mb available RAM, so every bit counts.

Much obliged,
Jake

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

Re: sorry post not working

#6 Post by mcewanw »

Guy wrote:I saw your post & thought of this:

https://help.ubuntu.com/community/SwapFaq#What is swappiness and how do I change it?

this should deter the kernel from using swap when you still have RAM

Hope this helps
G
Thanks Guy... but if you check my first post carefully you should notice that I already discussed and included exactly that same link! :-)

The problem I was discussing is that Linux has a tendency to swap whether or not you make the swappiness value 0. Hence the script to empty swap I suggested.
github mcewanw

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: sorry post not working

#7 Post by L18L »

Guy wrote:I saw your post & thought of this:

https://help.ubuntu.com/community/SwapFaq#What is swappiness and how do I change it?

this should deter the kernel from using swap when you still have RAM

Hope this helps
G
replace # by %23

https://help.ubuntu.com/community/SwapFaq%23#What

Thanks to nooby who reported first that % has to be used
http://www.murga-linux.com/puppy/viewto ... 3&start=49

Ether
Posts: 261
Joined: Wed 21 Aug 2013, 17:56

Re: 1. freeupRAM ; 2. freeswap ; 3. runaway /sbin/udevb

#8 Post by Ether »

.
I'm running DD Squeeze on a 15-year-old machine with a single 12GB disk with only one partition (GPartEd shows only sda1... no swap partition) and 385MB RAM.

Does that mean there will be no swapping and I don't need this script?

.

Post Reply