Overcoming 32GB storage + ZRAM

Hello everyone,

I need Waydroid for my bank, and started getting very annoyed with having to deal with cleaning caches and other folders ever so often. So it took me an 8-hour train journey to get around arranging my new setup. I did it 15 days ago, and my Librem 5 is my only phone, so the setup is guaranteed to work.

Firstly, I finally took the opportunity to reconfigure my ZRAM swap space, according to this exact post:

BACKUP BEFORE DOING ANYTHING!!

Then I inserted a 1TB micro SD card and made sure it would be encrypted and mount at boot with the keys stored in the internal encrypted boot disk. You can create the LUKS partition using the Disks application, and then follow the instructions here (make sure the SD is unmounted before proceeding):

So I stored my key into the /etc folder as /etc/sd.key

sudo echo -n decryptionkey > /etc/sd.key

The -n flag is important. Otherwise, it will not work (you don’t want LF at the end of your key)

Adapting the instructions (make sure your SD LUKS partition is sda1):

# blkid /dev/sda1
/dev/sda1: UUID="1249cb86-92a3-4e3b-8299-828a119fb3d1" TYPE="crypto_LUKS" 
PARTLABEL="primary" PARTUUID="75cf0a0e-0f4d-43c8-b8f5-fa26ab197ddc"
# echo "luks-1249cb86-92a3-4e3b-8299-828a119fb3d1 UUID=1249cb86-92a3-4e3b-8299- 
828a119fb3d1 /etc/sd.key luks,discard" >> /etc/crypttab
# cryptsetup -v luksOpen /dev/sda1 luks-1249cb86-92a3-4e3b-8299-828a119fb3d1 \
--key-file=/etc/sd.key

After that, check /dev/mapper. You should have a new device /dev/mapper/luks-XXXXXXXX as described before (echo lucks-1249cb86… into crypttab). You need to add it to your fstab (assuming mount point /mnt/sd) as

/dev/mapper/luks-XXXXXXXXXXX /mnt/sd ext4 defaults,nofail 0 2

nofail is important. You don’t want to get stuck on boot in case the system can’t mount your encrypted SD during boot. Reboot. Your encrypted SD should mount automatically.

Now the fun part, we will move key folders to the SD and remount them into your home folder. I decided to move
.local
.mozilla
.cache
Pictures
Documents
Downloads

Restart your phone, close anything that may be running, such as email or chatty, and, from ~: (the folder containing Waydroid requires sudo)

sudo rsync -av .cache /mnt/sd/home/purism
sudo mv .cache .cachebkp

Then add to your fstab:

/mnt/sd/home/purism/.cache /home/pursim/.cache none defaults,bind,nofail 0 3

Run sudo mount -av to make sure it mounts correctly. Then reboot and check that:

  1. the SD mounts
  2. The .cache folder mounts as well

If everything is ok, go ahead and remove .cachebkp from your home folder. Repeat the procedure for all folders you wish to move.

After moving everything, I have 6.5G free on my home partition. My phone is faster and more stable. Waydroid takes a bit longer to start and waydroid applications freeze for ~1s after loading, then everything is fine. Photos taken with the camera go straight to the SD, so does the Firefox cache.

edit: the Disks application benchmarks my LUKS partition at 10MB/s for both reads and writes.

6 Likes

Hello Xeda,
thank you for sharing.
Will try it the next Time i setup or have trustworthy Backup and Time. However, i could not be a Day without my L5.

Why i wrote:

  • Had only 900 MB for month.
  • Did not understood flatpak.
  • Installed Flatpaks as root,as user… sometimes twice.
    So flatpak eats my space.
  • i removed all flatpaks and installed only my loved ones.

-Do not try to move “/var/lib/flatpak” to an not encrypted SD Storage with exfat Filesystem.

1 Like

Same link using my AnonymousOverflow instance:

This setup sounds very similar to mine, although mine is less secure. My dual boot on 1 TB SD card is using unencrypted PureOS on there, so if someone steals it then they can steal all my Android stuff. In this way, the Android apps and such are insecure, and only the main PureOS stuff on the phone’s eMMC are encrypted.

Currently I am using a Liberty Phone model, so that I have 128 GB instead of 32 GB, and 4 GB RAM. Together between the 4 GB RAM, and also ZRAM on the dual boot partition, and using the GNOME hotkey for fullscreen combined with Waydroid settings to always use the full phone screen size, in total when I launch the dual boot and then run fullscreen Waydroid, I have been in situations where I handed this phone to a friend to use and they did stuff on Android and forgot it was a L5 until I told them, even though they think of L5’s as a joke to not use because of the social fabric of society and their interactions with me and other L5 users.

But my Waydroid configuration is also using GAPPs (to appease our demon masters), so it’s pretty bad. I much prefer to run GAPPs Waydroid on a cloud VM and remote into it for my every day needs, so that these things aren’t on my local device.

2 Likes