Extrat swap memory on SD Card (used as storage/swap memory)

asked 2016-04-02 16:14:24 +0300

AA-0001 gravatar image

updated 2018-12-03 23:07:08 +0300

Tanghus gravatar image

Hello,

I'm quite annoyed by my Jolla killing my android apps all the time, so I was thinking about a swap memory on my sd card ( I saw it on another thread, it was talking about mkswap). I know there's other threads about this, but could I have a safe and clear way to configure it without losing my data on my card ? I would like to allocate 1GB of swap space (of if its possible, 2GB).

edit retag flag offensive close delete

Comments

You could create a file on the uSD card using dd and use it as swap space following the mkswap/swapon procedure.

But: At first you have to be aware that critical data could be swapped out onto the uSD card which could be easily removed and the data could be extracted from there. And the usual FAT filesystem does not allow to set the file permissions to root:root.

Using a swap file on the internal filesystem does not have these drawbacks.

lechris ( 2016-04-03 02:16:20 +0300 )edit

So it would be better to use a swap file on the Internal filesystem ? If it's not too much to ask, could you explain me how to do this or give me a link to a proper tutorial ?

AA-0001 ( 2016-04-03 21:16:05 +0300 )edit

lechris: would that swap persist after reboot?

jbruggem ( 2016-04-04 09:42:32 +0300 )edit

@AA-0001 If you have a FAT file system on the uSD card, then yes. I assume that you are just looking for more swap space and have enough space on the internal memory.

I have tried out using a swap file on the uSD card by means of dd if=/dev/zero of=/media/sdcard/YOURCARD/aux.swap bs=1M count=1k mkswap /media/sdcard/YOURCARD/aux.swap swapon /media/sdcard/YOURCARD/aux.swap and it showed up in the list presented by swapon.

Please take into account that the swap space is significantly slower than RAM and using too much of it may degrade the systems responsiveness.

lechris ( 2016-04-05 22:04:19 +0300 )edit

@jbruggem You could add the swap file during startup with systemd. I couldn't you give a proper recipe rigt now, but this question may be a good starting point.

lechris ( 2016-04-06 09:49:49 +0300 )edit