Back to Netrunner | Back to Blue Systems

swapon file upon booting

Hi.

Recently I chose Netrunner as main OS for my work laptop. It’s a somehow old laptop with AMD Athlon Turion 64 ML-37 (1 core, 2GHz), ATI Radeon Xpress 200M, and 2G of RAM (maxed). Everything but the b43 wireless worked out of the box (fixed easily installing the firmware-b43-installer package). So Netrunner offered an awesome experience so far.

Because I have no much HDD space, and my partitions are packed with data, I decided not to create a swap partition knowing that I can use a file for swapping on a NTFS data partition in hdb. But don’t have enough knowledge to configure such (advanced?) settings. :dodgy:

Here’s what I did so far:

$ sudo mkdir /media/DATA

Mounted my NTFS data partition in /etc/fstab:

UUID=################ /media/DATA	ntfs	defaults	0	0

Created the file for swap:

$ sudo dd if=/dev/zero of=/media/DATA/linuxswap bs=999999 count=4k $ sudo mkswap /media/DATA/linuxswap

Everything setup, time to test in current session:

Got rid of the /dev/zram0 swap then swap on /media/DATA/linuxswap :

$ sudo swapoff -a $ sudo swapon /media/DATA/linuxswap
It worked!

My question is how to make use of this swap file on booting Netrunner?

Tried adding a script /etc/init.d/swapfile:

[code]#!/bin/sh

case “$1” in
start)
/sbin/swapoff -a
/sbin/swapon /media/DATA/linuxswap
;;
stop)
/sbin/swapoff /media/DATA/linuxswap
;;
restart|reload|force-reload)
/etc/init.d/swapfile stop
sleep 1
/etc/init.d/swapfile start
;;
esac[/code]

$ sudo chmod 755 /etc/init.d/swapfile sudo service swapfile restart
Works too!

But it doesn’t work upon booting :huh:

How do I get rid of the /dev/zram0 swap and swap on my file everytime I boot Netrunner?
(next step would be enable hybernation, but for now I’ll be glad swapping as I want)

Why don’t you use the /etc/fstab which is intended for also mounting swapfiles ?
So I would suggest that you put your swap file in /etc/fstab (see manpage of fstab to know how exactly)
As for zram I don’t recommend removing it as it makes your system faster when it has to swap as it isn’t writing to disk but instead compresses ram to be used as swap space which is way faster.

But if you really want to remove it just remove the package zram-config .

Thank you.

I read somewhere that Debian (& derivatives) can’t mount a swap file in fstab, and (silly me) I didn’t even tried. They directly messed up with those init scripts…
Well… Now I tried in fstab and it seems to work. Thank you. :smiley:

As with zram… it gets half of my available memory, so it’s 1GB of uncompressed RAM and 1GB of compressed swap in a ramdisk. Isn’t it?
Not sure if it will be faster on a single core CPU or if it would become a bottleneck.
Anyhow, I have damn slooooow HDD in this laptop, and I read about zswap, which looks like a way to keep almost the 2GB of uncompressed RAM, and compress the data (yes, it uses RAM+CPU as in zram) before swapping to disk (I guess it frees the RAM used in compression after that).

Any advice on zswap? Would you recommend its use in a computer like this?

I would stick with zram and wait until zswap matures. There is zcache also and other ideas based on the zswap idea. None of them widely used or tested yet in contrast to zram which is used by many distros and also mobile systems like android and so on.

Ok, thanks again for your help. Much appreciated.

I have a 4Gb swap partition and I have a total of 7.84Gb swap space, so I’ve removed zram-config from my new 14.1 installation but it hasn’t made any difference to the total amount of swap space??