dphys-swapfile broken

Post Reply
drew1horn
Posts: 10
Joined: Fri Feb 16, 2018 6:21 am
languages_spoken: english
ODROIDs: XU4
Location: Tijeras, NM
Has thanked: 0
Been thanked: 0
Contact:

dphys-swapfile broken

Unread post by drew1horn » Thu Nov 08, 2018 4:00 am

I know many if not most of us have slow sd card storage and don't use any swap.

On on a couple 16.04 XU4 I have

/boot on sd card
/ on SSD
swap on swap file /var/swap

Unfortunately, I did not document the incantations and voodoo for the / and /boot part.
I have to figure it out again for 18.04

the dphys-swapfile package worked flawlessly on 16.04

it doesn't work on 18.04

I realized dphys-swapfile is a shell script and dug in.

fallocate $MEMSIZE /var/swap
mkswap /var/swap

is not being executed

it's not clear what the correct value for MEMSIZE is with the XU4

I used 2048 MiB for my work around.

dphys-swapfile is calculating 2004 MiB

User avatar
meveric
Posts: 10572
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105)
Has thanked: 19 times
Been thanked: 165 times
Contact:

Re: dphys-swapfile broken

Unread post by meveric » Thu Nov 08, 2018 4:49 am

Since dphys-swapfile is just a shell-script you can easily do this by hand as well:

Code: Select all

fallocate -l 2G /var/swap
to create a 2GB file

Code: Select all

mkswap /var/swap
will "format" the file as a swap file.
You will probably see an error that is has not the correct permissions, so you can simply correct this via:

Code: Select all

chmod 600 /var/swap
Afterwards you add the swap file to your fstab to mount it automatically on each system start:

Code: Select all

echo "/var/swap  none  swap  sw  0  0" >> /etc/fstab
and then you either mount it with mount -a or just turn swap "on" with swapon -a
That's it.

But the reason people don't use physical swap is not that they use sdcards (as many use either eMMC or SSD as well), but that most people simply activate ZRAM instead, as it's much faster than physical swap and often is good enough.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

drew1horn
Posts: 10
Joined: Fri Feb 16, 2018 6:21 am
languages_spoken: english
ODROIDs: XU4
Location: Tijeras, NM
Has thanked: 0
Been thanked: 0
Contact:

Re: dphys-swapfile broken

Unread post by drew1horn » Thu Nov 08, 2018 5:11 am

I did the chmod but forgot to mention it.
I forgot about fstab, but I would have figured it out eventually.

Never heard of ZRAM. I'll have to google it.

Is there an Eratta or Bugs page where this is documented?

User avatar
meveric
Posts: 10572
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105)
Has thanked: 19 times
Been thanked: 165 times
Contact:

Re: dphys-swapfile broken

Unread post by meveric » Thu Nov 08, 2018 8:06 am

drew1horn wrote:Is there an Eratta or Bugs page where this is documented?
Where what is documented? ZRAM? That was discussed in the forum a long time ago, mostly around the C1 that only had 1GB RAM where next to nothing works without SWAP (ZRAM).
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest