Installing apps on micro SD card

Hi,

The phone space gets occupied quickly due to large app sizes. Is it possible to change app (including flatpak app) installation location to the SD card?

Thanks.

I don’t recommend doing this. It is fraught.

In some special cases, the app itself may support reconfiguring to offload some of the storage used by the app to another location - but that would have to be looked at on a case-by-case basis.

Or … fun option … use a chain boot to boot from the uSD card and put everything on the uSD card. (DIsclaimers apply. :wink:)

I can’t comment on anything specific to flatpak.

Could you please point me to any tutorial on chain boot?

Unfortunately not. You did see that disclaimers apply, right? :wink: At minimum, you would need an up-to-date uboot (and know how to activate USB boot i.e. uSD boot). Search the forum but I think very few customers have done this so you would be a trailblazer.

I also cannot comment on flatpak, but when it comes to normal Linux distribution installs, it takes a lot to fill up 16GB, much less 32GB, unless you let updates download and never install them. This is probably not something that a person new to Linux should do, but a more common practice is to put the home directory on a different storage device. In your case, the SD card. This would free up some space for apps on the eMMC, and give you plenty of room for user data.

Purism might want to create a utility for doing this, if they do not already have one. I can see it being helpful for all sorts of users.

2 Likes

This is discussed in this forum. There are pitfalls to be aware of but it is doable. Quick and Easy User Personas (which maybe turned out to be anything but “quick and easy” :wink:).

I don’t think there’s an automated procedure.

Another question is whether something else is filling up the disk e.g. out of control journals. https://source.puri.sm/Librem5/community-wiki/-/wikis/Tips%20&%20Tricks#managing-journals

Use journalctl --disk-usage to see how much space is being used.

What is bad about this (other than that the SD is typically slower):

Format SD in ext4
Arrange /etc/fstab to mount SD at some fixed place. Say /mnt/sdcard
Move /opt/myhugeapp to /mnt/sdcard/
ln -s /mnt/sdcard/myhugeapp /opt/myhugeapp

With this, I have installed the whole texlive on my sdcard (which is 6 or 7 Gb installation) and TeX and variants run flawlessly (and fast enough).

  • It’s a bit questionable as to whether package upgrades will work correctly. It might work. It might not. (Is that something that you have tested?)
  • You also have to be very careful with the dependencies i.e. if the package has any relevance to the system boot then you have to ensure that the uSD card is mounted before the package is needed. systemd would not typically recognise the dependency that you just created with ln -s. (I’m sure TeX is not needed to boot the system, so it probably isn’t a problem here.)

I’m not sure if debian places anything in /opt, but I think it doesn’t. Then you’re free from packaging problems or boot dependencies, unless you ask for them.

The trick is to separate the extra storage from the main system to the fullest extent.

3 Likes

I’d agree and reformulate that the /home needs to be placed on a separate partition, and if/when so intended “on a different storage device” (during reflash/reinstall process).

It has never happened to me that huge applications need to run before the disk is mounted.

You are correct though that this is not proper solution for any application.

1 Like

Yes, my comments were directed at the general topic of “installing apps on the uSD card” (which may apply even if the app is not huge). Each app needs to be considered on a case-by-case basis for the approach that you mention and how the approach might impact on the two points that I listed and all the points that I didn’t list because I don’t know about them.

One risk with boot dependency, for a general app, is that the app starts some kind of daemon at boot time - so definitely executes some code at boot time - but the daemon will unpredictably fail to start (will sometimes start and sometimes not start) because there is a race condition between starting the daemon and mounting the other disk - and systemd does not do anything at all to sequence things properly because the dependency is not visible to it.

I expect that is just not an issue for TeX.

I think that the requirement of the Personas thread was that the SD card be optional or be expected to fail of old age. If this SD card is going to live in this phone for the entire life of the phone, then none of the booting issues apply.

1 Like

I would agree about partition if there were more space to waste by not having well defined capacity requirements like we have on the /boot partition. I used to partition / at 32GB and give /home the rest (I am omitting the other stuff for simplicity).

1 Like

IMO, /boot partition might preferably be of size 1048576 sectors (instead of 952320) but it should stay there (PureOS approach is justified) as is. /home partition would be either third or fourth one (if any extra space/separation required).

For example, if below eMMC module (up to 128GB as of now) doesn’t consume a lot of power and if it stays “cold” during usage we might wish to be able to insert (if not predicted to be used as main modular storage) one within Librem 6 (perhaps use it as separate /home partition)?


Anyway, constant power put on microSD card or UFD or other storage media needs to be considered as well before inserted battery gets instruction to power/have separate /home partition ON non-stop. Perhaps even individual replacement of WiFi card for some storage media card over related HKS might sound fine too, but I don’t know nor think much about such possibility.