[XA2][HowTo] Mounting SD card in Aliendalvik (+ making internal storage accessible to write + duplicating media workaround)

asked 2019-05-14 02:55:58 +0300

meschk gravatar image

updated 2019-05-14 18:32:15 +0300

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.

edit retag flag offensive close delete