Any benefit of swap?

Hi!

I have an extra usb thumb drive that I used with my old android based media center as a swap partition.
It just struck me - Would OSMC (or retrosmc for that matter) be helped by adding a usb drive for swap space? Performance wise, stability or other

For reference: https://wiki.debian.org/Swap

You don’t say what device you run OSMC on.

Without that information there can’t be a useful answer to the question as different devices have different amounts of RAM - for example with Pi’s varying from 256MB to 512MB to 1GB of ram.

For reference, we already enable swap on a 256MB Pi as it is almost impossible to run without it, but we do not enable it for 512MB or 1GB Pi’s or the Vero as it is not needed and would only slow things down.

Oh! My bad I’m using a raspberry pi 2

Curious as to why it would slow things down? (I don’t think I fully understand the swap function, thought it would be used only if needed)

Thanks for the quick reply :slight_smile:

Depends on sysctl.swappiness (which is already fine-tuned).

We only enable swap for devices that need it.

Sam

This is an old thread but my question is relevant. On ATV1 I see there is a swap file:

$ swapon -s
Filename Type Size Used Priority
/swap file 131068 180 -1

$ ls -l /swap
-rw------- 1 root root 134217728 Apr 3 2016 /swap

but there is no swap partition:

$ mount | grep swap
$
$ grep swap /etc/fstab
$

If there is no swap entry in fstab, how is swap enabled on osmc?

It’s enabled by the perftune service.

Thanks Sam,

I can see /usr/bin/performance_tuner is reading the output of:

$ cat /proc/cmdline
console=tty1 root=/dev/sda2 rootfstype=ext4 rootwait quiet video=vesafb intel_idle.max_cstate=1 processor.max_cstate=2 nohpet vga16fb.modeset=0 osmcdev=atv

to find out where the root device is, but I can’t see where a swap device/file is set.

Regards
Mick

It swaps on if there’s not much memory. I’m mobile but if you can’t find it let me know

Sorry Sam, I had a look around but can’t find anywhere what component of perftune service and /usr/bin/performance_tuner checks the memory size to determine if a swap file is necessary, or which part creates the swapfile and attaches it. Interestingly, I had a swap partition on an attached USB drive, but this is not being used without me setting it up manually. Mind you a USB drive may have slower I/O than the IDE disk ATV1 comes with.

Regards,
Mick

swapon is done in perftune

if [ -f /enable_swap ] || [ "$MEMORY" -lt 262144 ]

Oops! I beg your pardon Sam, it was there all along but I hadn’t paged down enough to see the rest of it! :blush: For some reason I thought the script was much shorter than it actually is …

Thank you for pointing it out.

Regards

i need to temporarily enable the swapfile on my vero to for compiling a large pip install. how would i do that?

cheers
bendsch

sudo touch /enable_swap and reboot