Improve Your Librem 5's Performance (with this one weird trick)

I am not sure if this will be good for the health of the EMMC? The EMMC IMO does not like a huge amount of write processes and a defective EMMC woul produca a brick - phone is dead

1 Like

The Micro SD will be defective in a short time. Problem is well known from users of the Raspi with apps that write lot of data to the SD Card

1 Like

I believe that was addressed in the OP. However it’s up to the individual customer as to how to prioritize things. For myself, I won’t be rushing to use eMMC or µSD card for swap. Swap-over-the-network anyone? :slight_smile:

(This is not as silly as it sounds, given that the µSD card is quite slow. The real problem there would be loss of connectivity, and the resultant hanging.)

1 Like

Yepp, on the Raspis most of the SDs fail after only 5-6 months :frowning:

1 Like

Raspberry Pi is really not comparable. The µSD on Raspi has to do all the work that the eMMC does on the L5, including everything that goes in and out of RAM.

As the OP explains and IrvineWade concurs (I believe), rapid swapping in and out of RAM will still use the zRAM on the L5. He [EDIT: “he” referring only to the OP and definitely not including IrvineWade] presents the case for supplementing the zRAM with a larger but slower swap space. He and I just propose different ways of doing this, and I have given reasons why some users might be better served by a swap partition on the µSD.

Personally, I am a very light user of the L5 and doubt that my swap partition will make any noticeable difference to its operation. However, it does no harm, and µSD storage is cheap.

The other big difference is that the one µSD on Raspi is the only persistent storage, holding the OS as well as all your media. If it wears out, you no longer have a computer. If the µSD on the L5 stops working, all you lose is the 3000 videos of your dog catching a frisby, plus the swap space that your device never used to have in the first place. There is even a question whether deterioration of the swap partition would cause any loss at all of the media in the FAT partition.

If the swap partition doesn’t seem to be working any longer after a year or two, another swap partition can be carved out of the FAT and the /etc/fstab pointed to the new UUID instead. Alternatively, you might buy a new µSD once in a while.

3 Likes

I thought that the Micro-SD in the L5 only works with a transfer-rate of approx 20MB/sec ?

2 Likes

That’s what makes it slower than zRAM, as OP and I have said.

2 Likes

Hmmmmh, it would it make VERY slow if my information is correct. Swap-Out for 256MB RAM will last 15 seconds?
Has anybody tested this configuration with swap on a micro SD and can report his experiences and impressions?

1 Like

But perform periodic backups, of course, or clone it.

BTW, Raspberry Pi OS makes it super easy to clone your installation using its built-in SD Card Copier and a µSD card reader/writer.

2 Likes

Hey, sorry for the misunderstanding. As others have mentioned, the “clickbait” language was absolutely meant as a joke.

6 Likes

How’s your experience swapping to SD card so far? Personally I would be very concerned about the relative speed and reliability comparing SD with onboard MMC.

I think the SD card reader on the Librem 5 is actually connected via USB, which could impact both speed and reliability pretty significantly.

2 Likes

This is something I had previously done on my L5 to assist in performance (and overheating) as well as stability issues (especially when running WayDroid in conjunction with local apps). Tweaks and optimizations such as these would (IMO) be helpful to incorporate into the default build configuration for the L5.

For reference, this public L5 OS-issues repository:

This is where general OS issues will be tracked for the Librem 5 project. It is a catch-all for issues that do not have a place in specific application/project repositories or Apps_issues.

The community is certainly welcome to post feature requests and bug reports there.

In the meantime, I have created an issue to account for this topic. You are all welcome to expand upon the conversation in this ticket, work with the Purism development team to publish a MR, etc:

3 Likes

My experience is not a useful test, because I am a very light user of L5 and seldom have anything in swap. I’ll try to take note of whether there is any reduction in overheating since setting up the swap partition. (JCS suggests that a swap space might reduce overheating, a problem that I have had in browsing certain websites.)

[EDIT] In your first post, you suggested (correctly, I believe) that some readers should not be using dd and other powerful commands on their L5. Some replies were from users who did not feel they had any spare room for a swap space in their eMMC. My aim was to find an alternative for those two groups of users. You might be right that this alternative is not a particularly practical one.

1 Like

I haven’t exactly experienced that.

I have two Pi devices that are on 24x7, and have been for some years, one of them almost a decade. (Actually the newer one now runs off eMMC - but I did that in an unsuccessful attempt to get better performance, not because of any issues of reliability - and it ran off µSD card for a few years before that.)

I have not experienced any outright card failure. I have experienced file system corruption after power failure - and then have to restore from backup.

That by itself would make me wary of putting anything important on SD card. So I guess I am agreeing with the spirit of your post, if not the detail.

No, Irvine Wade does not occur.

I won’t be rushing to put any real swap for the Librem 5 on either eMMC (very much opposed) or µSD card (wary, and it’s sloooooowwwww). However the point of actually owning your hardware is that you are free to do with it what you want.

All I have on the µSD card at the moment is the metaphorical “3000 videos of my dog catching a frisbee” so it wouldn’t be a drama if the card died. That’s all just synched from the server. So if the card fails, I could just buy a new card, resynch it, recreate swap, and off I go.

However I would be a little concerned if there were undetected media failure - since that will corrupt memory and thereby corrupt other things. On the other hand, detected but uncorrected media failure could result in a hang.

You get that much? :wink:

This whole topic is only useful if your real memory usage is getting up towards the amount of RAM installed (3GB on the standard Librem 5).

It is.


Random alternative suggestion … use a USB flash drive as (secondary) swap.

My thinking is that a docked scenario is the more likely scenario when my RAM usage will be high … and in a docked scenario I can throw a flash drive onto the dock. (In that case though, that swap should not be enabled by default, only when present and entering docked mode - and it would make it trickier to exit docked mode).

Maybe.

2 Likes

My apologies for this. When you wrote, “I believe that was addressed in the OP,” I took your “that” to mean the question of excessive wear on the eMMC. Apparently I misunderstood your sentence. Sorry again.

[EDIT: Corrected a quotation: “believe” instead of “thought”]

1 Like

No drama. I just meant that the OP is aware of the potential for excessive wear and that he has expressed his opinion on it in the first post.

2 Likes

Hey and welcome!

Did someone try writeback with zram yet? I didn’t get around to it and I didn’t have any need so far…

1 Like

Hello. I must have done something wrong in trying to install this because my fstab file soes not have any “/swap” files.

Here is what my /etc/fstab file shows:

proc /proc proc defaults 0 0
UUID=442eff79-a91c-42ef-b49b-c991832c0419 / ext4 errors=remount-ro 0 1
UUID=55b6447c-bfc3-42b0-99b8-10b5cf65b47c /boot ext2 errors=remount-ro 0 2

I installed something but I am not sure what. Any help would be most appreciated. Thank you!

2 Likes

If it helps, I had created a helper script to turn a rootfs swapfile on and off:

A couple deviations from the guidance in this thread:

  • I use fallocate rather than dd to allocate disk space for the swapfile to save time, as the data will be quickly overwritten, anyway.
  • I use the nofail flag in /etc/fstab to allow booting in case the swapfile is moved/deleted for any reason.
6 Likes

Did you create a root shell and then run all the commands in that shell (and then type exit)?

What will not work is to prefix each command with sudo - in particular the command that updates
/etc/fstab will not work. This is a well-known Linux annoyance.

The correct hackaround if you want to prefix each command with sudo is, for that one command in the sequence of commands, to replace this command

echo '/swapfile none swap sw 0 0' >>/etc/fstab

with this command

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

3 Likes