Mount swap on emmc

I use coreelec 19.5-Matrix_rc2, my device is an amlogic s905w, everything works fine but since I have no RAM to spare I want to have a swapfile as a backup. basically followed the instructions here:

in my setup I boot from usb, and mount /dev/data (emmc) to /storage/mnt, when I reboot dmesg tells me that [ 6.065396@1]- systemd[1]: Starting Mounting swapfile... [ 7.663247@0]- systemd[1]: swap.service: Control process exited, code=exited, status=1/FAILURE [ 7.664586@0]- systemd[1]: swap.service: Failed with result 'exit-code'. [ 7.667067@0]- systemd[1]: Failed to start Mounting swapfile.

which is understandable because it’s probably mounting the partition AFTER the OS tries to mount the swapfile so it doesn’t exist.

is there a way I can mount emmc then mount swap so it can work?

Copy swap service and add mount command in it?

cp /usr/lib/systemd/system/swap.service /storage/.config/system.d/

So it will look like

Description=Mounting swapfile


ExecStartPre=/bin/sh -c 'mount | grep -q /dev/data && true || mount /dev/data /storage/mnt'
ExecStartPre=/usr/lib/libreelec/mount-swap create
ExecStart=/usr/lib/libreelec/mount-swap mount


how would I set the swap size? do I need to keep swap.conf ?

You still have everything as before. You only change swap.service to mount emmc before mounting swap.

Try and see :slight_smile:

ok that’s it, thank you very much @vpeter !!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.