PDA

View Full Version : Manually Creating a Swapfile



pooface
18-07-10, 16:35
I've seen a few people asking how to create a swap file for pli image, vti image etc... Have already posted these instructions somewhere on the forum, but putting them in a new thread to hopefully make it easier for people to fine :)

Anyway, this is what you should do (worked for me).

First off, telnet in to the box using your favourite telnet programme.

Then, type the following command (after count, enter the size of file you want. In example below, it is a 128mb swap - 1024 x 128 = 131072):


dd if=/dev/zero of=/media/usb/swapfile bs=1024 count=131072

Then, set up a linux swap area:


mkswap /media/usb/swapfile

Now, to activate the swap space immediately, type:


swapon /media/usb/swapfile

Now, activate the swap file to load when the vu duo loads, we need to edit the fstab file. To do this, type the following command to edit the fstab file:


vi /etc/fstab

Add the following line to the file:


/media/usb/swapfile swap swap defaults 0 0

Now, when the box restarts, the swap file should automatically be enabled...

To verify that it has worked correctly, type the following command in a telnet session:


free

This should give you some information similar to below:



total used free shared buffers
Mem: 140848 135964 4884 0 564
Swap: 131064 1848 129216
Total: 271912 137812 134100

SLOTH
18-07-10, 17:50
Thanks Pooface ...i,ll give that a go when i get a minute !
Cheers
Sloth

Sicilian
18-07-10, 19:52
Good post pooface, made it a sticky :)

cbr900
19-07-10, 10:49
what is the benefit of using Swapfile? why to use it?

pooface
19-07-10, 11:24
Basically, it gives your system more memory to cache things to, and should help to stop any problems you may get... Here's the wikipedia information on in:


http://en.wikipedia.org/wiki/Disk_swapping

andyblac
19-07-10, 19:19
type:

free

in a telnet session, and it will give you the amount of swap / physical memory used and free.

after you have step up a swap test to see if you are using it, if not than don't bother with one it will only hinder the system.

Andy,

Rob van der Does
20-07-10, 08:46
Basically, it gives your system more memory to cache things to, and should help to stop any problems you may get... Hmmmmm, let's ask the same question in other words: why should the VU need more memory? I think it has plenty and therefore doesn't need a slow swapfile.

andyblac
20-07-10, 09:03
Hmmmmm, let's ask the same question in other words: why should the VU need more memory? I think it has plenty and therefore doesn't need a slow swapfile.

all depends on how many plugin's, cam's, etc, etc, your using :)

as i said type free, to see what memory is available.

andy

pooface
20-07-10, 11:19
As an example, let's show you what mine currently says:



total used free shared buffers
Mem: 140848 118636 22212 0 552
Swap: 131064 32992 98072
Total: 271912 151628 120284


This alternates with the amount of free space on the vu being lower and amount of free space on the swap being higher, depending on the processes being run etc...

Ojustaboo
20-07-10, 16:34
Out of interest, what does the size of the buffers mean

for me I have



total used free shared buffers
Mem: 141448 1383526 3096 0 9764
Swap: 131064 2852 128212
Total: 272512 141204 131308

Rob van der Does
21-07-10, 07:45
all depends on how many plugin's, cam's, etc, etc, your using :)You will need to use an incredible amount of pluguns to suffer from memory shortage.......
I don't think the VU will ever need a swapfile.

pooface
21-07-10, 08:53
You will need to use an incredible amount of pluguns to suffer from memory shortage.......
I don't think the VU will ever need a swapfile.

I beg to differ there mate, sorry... Did you see my usage in my post earlier ... Plus, when I checked it last night, there was even more used! Don't have many plugins installed at all. Am using the vti image. I installed the movie cut, movie tag, move retitle, apache/php server and possibly a few others. Wouldn't call this a lot of plugins.

Where the need for swap is required, is the amount of memory asked for by the plugins etc. So, although you're probably only using 1 plugin, if that plugin is quite memory hungry, then you will find that you need a swap file...

Rob van der Does
21-07-10, 16:40
I beg to differ there mate, sorry... Did you see my usage in my post earlier ... Plus, when I checked it last night, there was even more used! Don't have many plugins installed at all. Am using the vti image. I installed the movie cut, movie tag, move retitle, apache/php server and possibly a few others. Wouldn't call this a lot of plugins.

Where the need for swap is required, is the amount of memory asked for by the plugins etc. So, although you're probably only using 1 plugin, if that plugin is quite memory hungry, then you will find that you need a swap file...I run the VU with 26 plugins and a lot of Picons: there is always plenty of free memory (without using a swapfile) and never any problem (using PLi).

BTW: there is only one way to see the free memory properly, and that is: " cat /proc/meminfo" , and then (MemTotal minus MemFree minus Buffers minus Cached) = Free Memory

Sicilian
21-07-10, 16:47
Not quite sure how to explain this, but isn't it a case that the more memory a linux system has installed the more it will use to optimise performance, i.e. create a large cache. Better explanation here
http://thelinuxnewbie.blogspot.com/2006/08/linux-uses-too-much-memory-very-basic.html

Rob van der Does
21-07-10, 20:34
People tend to get upset by marks: if the idea is to have a fast and faultless working system, judge it by the result, not by benchmarks. Is there any body who has solved any problem or got a faster and more reliable VU+ DUO by using a swapfile? I sincerely doubt that.

Ojustaboo
21-07-10, 21:16
Does it have any decremental effect by having one that's not used?

I created one to see if it helped with epg download crashing probs on Dream Elite. I've since changed to PLI but as I have the swapfile on my external esata drive, I turned it on in this image too.

If I type free, it's totally unused. That being the case, surely unless it did ever become needed, it wouldn't slow the system down?

Or to put it another way, why would it swap things out from memory if it wasn't running out of space, surely it doesn't swap things out just because the swap space is there?

pooface
21-07-10, 21:22
People tend to get upset by marks: if the idea is to have a fast and faultless working system, judge it by the result, not by benchmarks. Is there any body who has solved any problem or got a faster and more reliable VU+ DUO by using a swapfile? I sincerely doubt that.

If you read my question in a thread regarding the vti image & rytec plugin, then you'll find that when I didn't have a swap file, the image would just crash randomly. I had it where it would download around 150,000 items, sometimes 140,000 items (all give or take), but the image would crash without giving a green screen. So, I imagine that the plugin tries to do some fault handling....

Anyway, since I had the swap file running, I haven't had it do that crash, and it's actually run all the way through to give me a correct epg.dat for all the receivers that rytec offers that I want...

Hence, I still beg to differ against your postings...

Ojustaboo
21-07-10, 21:36
There's an interesting (to me) post here



http://kerneltrap.org/node/3202with such comments as



Even for systems that don't *need* the extra memory space, swap can actually
provide performance improvements by allowing unused memory to be replaced
with often-used memory.


On a modern operating system like Linux, pretty much all of your physical memory is
in use all the time. Without swap, dirty pages cannot be evicted from physical
memory, even if they haven't been used for days. If your physical memory exceeds
your working set size, you win no matter what. But without swap, every dirty
page is part of your working set, even if it hasn't been read/written for days.


Physical memory will always get full because the OS will always keep copies of
file data in memory just in case it needs them again. Because new pages are
always being read in and processes are always allocating new memory, the OS
will have to make a decision of what pages to evict from physical memory.

If a page is dirty, it can only be evicted if there's swap. So if you have dirty
pages that are very rarely used, swap allows you to keep more hot, clean
pages in memory.

A lot of people feel subjectively that swap makes a system slow. There's
anecdotal evidence that swap does horrible things or "must be badly broken
because the machine gets slow" on almost every operating system that
supports swapping. In most cases, it's just a case where the real working
set has exceeded physical memory, and in that case, swap is just doing
what it's supposed to be doing.

Rob van der Does
22-07-10, 13:09
Of course: do as you please.
In spite of the 26 plugins in use on my VU, the Rytec-download of over 250.000 items runs flawless without any swapfile......
If the system would really benefit from a swapfile, I bet the factory- and other image makers would have made an easy to handle GUI to create it. I haven't seen that in any image......

pooface
22-07-10, 13:30
You not looked at the dream-elite image? Am pretty sure I saw one for the vti image (although that defaults to /media/sdb1, as that is what it tries to hard code any usb stick to)... So other image makers must think that it benefits some way?

Are you running the apache/php web server? That is quite resource-hungry, so I suspect is the reason for the crashing with the rytec image for me. But, I want to keep the apache php server running, hence I need the swap file.

Ojustaboo
22-07-10, 13:41
Of course: do as you please.
and other image makers would have made an easy to handle GUI to create it. I haven't seen that in any image......

Definitely in a standard install of VTI, a simple GUI option that allows you to specify a swap of various sizes.

I still don't understand what the problem with having one is, even if it wasn't used?

Ojustaboo
22-07-10, 14:31
A swapfile is 100% making a difference to a problem I'm receiving today, please see my thread here

http://www.vuplus-support.co.uk/showthread.php?1384-Pluguin-error-message&p=8234#post8234

Rob van der Does
22-07-10, 18:05
A swapfile is 100% making a difference to a problem I'm receiving today, please see my thread here
http://www.vuplus-support.co.uk/showthread.php?1384-Pluguin-error-message&p=8234#post8234OK, I answered that. Has nothing to do with memory (-shortage).

parkher
12-08-10, 13:19
3. questions (sorry, if stupid):

1. why free is showing 141332 when according to the specifications should be 384 MB? Almost 2/3ds are missing. Surely there is no point in having 384 if the address space is used for something else and only 141332 available? If so, 256 (as in DB) or 384 makes no difference whatsoever.

2. where /media/usb/swapfile is physically located?
Shouldn't it be /media/hdd/swapfile?
I have installed 1 TB internal hd and now I see /media/hdd directory which contains lost+found and movie subdirectories

3. Shouldn't the size of the swap file be 2-3 times larger than the memory size? I think it is recommended for Windows, at least.
for example 3x 384 MB or at least 2x 141332 KB ?

parkher
23-08-10, 14:15
As to the question 2, I am guessing, it is on usb stick, because hd is usually powered down (standby in ....)
That is questionable:
- hd is faster, and for the swap file it is very important,
- perhaps it is better to keep the hard drive always spinning (no standby) - hard drive crashes are usually caused by frequent starting, not by continuous spinning,
in "no standby" mode (when spinning 24/7) your hard drive is likely to survive longer.

raedkuwait
10-09-10, 01:24
hi
I did exactly what is written how ever when i reboot the box, the swap file is not loaded automatically am using
VTI 1.3?

pooface
10-09-10, 10:03
hi
I did exactly what is written how ever when i reboot the box, the swap file is not loaded automatically am using
VTI 1.3?

It should load automatically doing that, but iirc, when I used vti 1.3 I had to manually edit the enigma2.sh file to be able to get it to do the mkswap and swapon code...

There is a swap utility in vti 1.3 iirc, and possibly also in 2.0 (never tried 2.0). There is definately a swap option in the vix image that works fine ;)

raedkuwait
10-09-10, 18:33
yes there is swap utility in vti but only to make swap file on the HDD not on the usb,
mmm, i'll c if i can edit the .sh file
ty.

grtmoby
10-09-10, 18:39
yes there is swap utility in vti but only to make swap file on the HDD not on the usb,
mmm, i'll c if i can edit the .sh file
ty

cant find enigma2.sh though ?

the swap utility give u the choice of hdd or usb. at least this is on vti 2.0

maracsx
17-12-10, 16:13
I did everything, and it is working fine, I've even edited fstab in editpad lite and uploaded it back but after restart swapfile is not enabled. When I enabled it manually than it works. What did I do wrong ?

pooface
17-12-10, 18:56
I did everything, and it is working fine, I've even edited fstab in editpad lite and uploaded it back but after restart swapfile is not enabled. When I enabled it manually than it works. What did I do wrong ?

What image?

maracsx
19-12-10, 10:30
OpenPli latest build, vu+ duo

pooface
19-12-10, 10:50
OpenPli latest build, vu+ duo

Sorry, I haven't tried using swap on pli image, so I cannot help. Maybe someone else has/can?!

abu baniaz
08-10-13, 19:56
Would it be of benefit to move this thread to the guides section?