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:
- the SD mounts
- 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.