[XA2][HowTo] Mounting SD card in Aliendalvik (+ making internal storage accessible to write + duplicating media workaround)
Here is a small guide about mounting SD card in Aliendalvik, making it accessible to Android apps. It is made for Xperia XA2 series (and maybe other devices with 8.1 dalvik, if there are any), and is tested with 3.0.3.8/3.0.3.9 (might not work with older versions due to different layout).
For the reference: phone's internal storage (/home/nemo
) is being mounted to /home/.nemo_bind
with bindfs (its purpose is permission spoofing, so that files created by Sailfish default user are accessible by Android media UID and vice versa). Then, this folder is being passed through to Alendalvik LXC container with read-only access. We are going to do the same mount for the SD card.
- Log in as root using
devel-su
either with Fingerterm or via SSH. - Create files
/home/sdbind.sh
and/home/sdunbind.sh
and put these lines there.
For sdbind.sh:
#!/bin/bash
# map files from sdcard to alien
mkdir -p /home/.sd_bind
bindfs --chmod-ignore --chown-ignore --chgrp-ignore --map=100000/1023:@100000/@1023 /run/media/nemo/<UUID> /home/.sd_bind
if [ "$?" != "0" ]; then
echo "Failed to mount sdcard for alien"
exit 1
fi
You should replace <UUID>
with UUID of your sd card. You can see it just by using ls /run/media/nemo
.
For sdunbind.sh:
#!/bin/bash
umount /home/.sd_bind || :
Run
systemctl edit aliendalvik.service
and insert these lines:[Service] ExecStartPre=/bin/su -c "/bin/bash /home/sdbind.sh" ExecStopPost=/bin/su -c "/bin/bash /home/sdunbind.sh"
Edit
/var/lib/lxc/aliendalvik/extra_config
and add this line:lxc.mount.entry = /home/.sd_bind data/media/0/sd none bind,rw,create=dir 0 0
Reboot. SD card then should be accessible from
sd
folder in Android internal storage.
Replace "rw" with "ro" if you want to mount your SD card read-only.
- BONUS: Mounting internal storage with write support
Simply open /var/lib/lxc/aliendalvik/config
and replace "ro" with "rw" in this line:
lxc.mount.entry = /home/.nemo_bind data/media/0/nemo none bind,ro,create=dir 0 0
It should be this:
lxc.mount.entry = /home/.nemo_bind data/media/0/nemo none bind,rw,create=dir 0 0
After that, reboot as usual.
- BONUS №2: Dealing with photos and stuff being shown twice in Android apps
As I mentioned before, /home/nemo
is being mounted in Aliendavik as nemo
folder in internal storage. But the internal storage itself is stored in /home/nemo/android_storage
. This creates bug which makes files show in filesystem two times: first one in the main folder of internal storage itself and the second one in the nemo/android_storage
folder.
This can be easily fixed by creating an empty folder (for example, /home/.empty
) and mounting it in the /var/lib/lxc/aliendalvik/extra_config
:
lxc.mount.entry = /home/.empty data/media/0/nemo/android_storage none bind,ro,create=dir 0 0
Again, reboot. Then the nemo/android_storage
folder in Android apps will show up empty and files will stop duplicating.
suggestsions :
have
sdbind
andsdunbind
take an argument ( with approriate[ -d "$1" ]
tests at the beginning) :Then use a separate template .service:
Bonus point: it should be possible to wire that template service to be "WantedBy=aliendalvik.service" so there is no nee to modify aliendalvik.service itself
Then it's all a matter of
DrYak ( 2019-12-04 23:08:49 +0200 )editMay I ask you two probably "ignorant" questions: Is this method also working on a XA2 with SFOS 3.2.1.20 ? If yes: when using android apps is all data which is normally saved to /home/nemo/android_storage now saved to the sd card? (Excuse me, if I do not understand all of your code; I'm not to familiar with this...) Best regards, Uwe.
UweLabs ( 2020-01-11 18:56:33 +0200 )editMay I ask again if somebody knows if this procedure will work in SFOS 3.2.1.20? Best regards, Uwe.
UweLabs ( 2020-02-25 18:11:52 +0200 )edit