• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: swap on SD Card  (Read 2699 times)
TJeh
Newbie
*

Karma: 0
Posts: 20


View Profile
« on: September 16, 2009, 10:50:32 AM »

Hi am stuck getting my Plug to use a swap partition that is on my sd card. Kernel and rootfs is on partition 1.

Even stressing the Plug's memory with:
Code:
dd if=/dev/urandom bs=768304 of=/tmp/memtest count=1050
fills only the 512 Mbyte Ram an the swap is just ignored!

Here is my setup:
Code:
root@ubuntu:/# fdisk -l && free -t && swapon -s && cat /etc/fstab

Disk /dev/mmcblk0: 16.0 GB, 16062087168 bytes
4 heads, 16 sectors/track, 490176 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0x15fe73a8

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1      458753    14680088   83  Linux
/dev/mmcblk0p2          458754      490176     1005536   82  Linux swap / Solaris

             total       used       free     shared    buffers     cached
Mem:        513752      79380     434372          0       2232      58356
-/+ buffers/cache:      18792     494960
Swap:      1005528          0    1005528
Total:     1519280      79380    1439900

Filename Type Size Used Priority
/dev/mmcblk0p2                          partition 1005528 0 -1

# UNCONFIGURED FSTAB FOR BASE SYSTEM
/dev/mmcblk0p2 none swap sw 0 0

has anybody else come accross this?

Regards,

TJeh
Logged

DamonHD
Full Member
***

Karma: 4
Posts: 169


View Profile WWW
« Reply #1 on: September 16, 2009, 10:56:15 AM »

Hi,

I know this is not answering your point exactly, but have you tried a swap file instead?

I'm going to try avoiding swap if at all possible, for various reasons, but if I have to have it, I'll be using a swap file for maximum flexibility.

Rgds

Damon
Logged

restamp
Global Moderator
Sr. Member
*****

Karma: 4
Posts: 273


View Profile
« Reply #2 on: September 16, 2009, 11:07:28 AM »

I guess I don't understand what your problem is.  Have you made /tmp a tmpfs or something?
Logged

TJeh
Newbie
*

Karma: 0
Posts: 20


View Profile
« Reply #3 on: September 16, 2009, 11:52:02 AM »

@DamonHD
I have tried a swapfile as well on USB and SD... both did not work.

@restamp
the trouble is while running transmission-daemon my memory gets filled up  and the result is something like this:

Mem:    513752k total,   489272k used,    24480k free,     3716k buffers
Swap:  1005528k total,        0k used,  1005528k free,   431912k cached

Filename                                Type            Size    Used    Priority
/dev/mmcblk0p2                          partition       1005528 0       -1

even though I have a swap partiton assigned my plug does not use it Sad

Regards,

TJeh
Logged

restamp
Global Moderator
Sr. Member
*****

Karma: 4
Posts: 273


View Profile
« Reply #4 on: September 16, 2009, 12:32:02 PM »

the trouble is while running transmission-daemon my memory gets filled up  and the result is something like this:

Mem:    513752k total,   489272k used,    24480k free,     3716k buffers
Swap:  1005528k total,        0k used,  1005528k free,   431912k cached

Filename                                Type            Size    Used    Priority
/dev/mmcblk0p2                          partition       1005528 0       -1

even though I have a swap partiton assigned my plug does not use it Sad
Isn't that the way it is supposed to work?   Linux basically uses its non-kernel memory for two purposes:  (1) the program memory segments that comprise each process, and (2) its i/o buffers.  The kernel migrates (1) to swap (if present) when free memory becomes tight.  Generally, it fairly quickly writes (2) to a file system somewhere, and thus the data in the buffer becomes non-critical, but if memory is plentiful, it doesn't free the associated buffers right away:  It can always reclaim that memory easily if it needs to later, but delaying the freeing of the buffer might save a read if the data is accessed later.  But, I don't believe it ever writes (2) to swap, since the data exists elsewhere.

It looks to me like you are filling your memory with cached data, and not program memory, so the kernel has no need to move anything to swap.
Logged

cbxbiker61
Global Moderator
Sr. Member
*****

Karma: 38
Posts: 497


View Profile
« Reply #5 on: September 16, 2009, 01:17:01 PM »

If you want to exersize your swap try the following program.

Code:
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

#define MEG512 (1024*1024*512)

int main ( int argc, char *argv[] )
{
        char *allocated = malloc(MEG512);
        if ( ! allocated )
        {
                fprintf(stderr, "unable to allocate memory\n");
                exit(1);
        }

        {
                char *p = allocated;
                char *pend = allocated + MEG512;
                for ( p = allocated; p < pend; p += 1024 )
                {
                        *p = '0';
                }
        }

        /*sleep(30);*/
        free(allocated);
        return 0;
}
Logged

birdman
Sr. Member
****

Karma: 4
Posts: 443


View Profile WWW
« Reply #6 on: September 16, 2009, 02:59:21 PM »

Even stressing the Plug's memory with:
Code:
dd if=/dev/urandom bs=768304 of=/tmp/memtest count=1050
fills only the 512 Mbyte Ram an the swap is just ignored!
There's no memory stressing there - all you are doing is filling a file system.
Logged

TJeh
Newbie
*

Karma: 0
Posts: 20


View Profile
« Reply #7 on: September 16, 2009, 03:20:30 PM »

@cbxbiker61
Thank you for the programm code. Executing it, verified that my swap is working.  Cheesy

Code:
Mem:    513752k total,   510520k used,     3232k free,       88k buffers
Swap:  1005528k total,   172208k used,   833320k free,     3584k cached

I was hoping to use the swap partition to extend the memory that transmissionbt can use. Especially when downloading new files, probably just before completion neither the webui nor the transmission-remote of the transmission-daemon is responding to queries. Looking at the plug's memory it showed that it was filled up whereas the cpu had only 15% load.

Does this indicate that I have a bad build of transmission 1.75?

Quote
It looks to me like you are filling your memory with cached data, and not program memory, so the kernel has no need to move anything to swap.

So basically the downloaded data is put into memory before writing it to the sd card? Is there a way of avoiding a situation as i described above?

Regards,

TJeh

Logged

birdman
Sr. Member
****

Karma: 4
Posts: 443


View Profile WWW
« Reply #8 on: September 16, 2009, 05:43:35 PM »

So basically the downloaded data is put into memory before writing it to the sd card?
Yes - and it's left in memory (as well as being on the SD card) unless something that actually needs it comes along to request it (at which point it's just dropped and the memory is assigned to the new use).  This means that if anything wants to read the file data that has just been written it comes straight out of memory without making a disk request.
This seems to create panic in some of the Capacity Management people at work who keep wondering why all of our Linux systems have so much memory in use all of the time.  They must need more memory, or be using it inefficiently.,   The fact that they never use swap seems to escape their notice...
Quote
Is there a way of avoiding a situation as i described above?
I can see anything you want to avoid at the moment.
Logged

Pages: [1]
Print
Jump to: