↓Skip to main content
  1. Main/
  2. How-To/

Jolla Android On SD-Card

·

Summary #

The Jolla has 16 GB internal disk space which is filled by Android apps like OsmAnd and Spotify pretty fast.
Thus I’ve developed a way to move the data of these apps to sd-card.

Main #

All of the following commands have to be run as root.
Thus you have to be careful otherwise you’ll break your phone.

Warranty There is no warranty that this setup works for any system which provide the dependencies listed below. I'm just providing these information because it worked for me. If you have questions you can leave a message here but I decide whether I'll answer and help or not.

If you follow these instructions you’ll move all data saved by Android apps running on the SailfishOS of a Jolla to the sd-card of your phone.

That way you might use up to 64 GB of disk space for maps, media files and everything else stored by Android apps.

Dependencies #

  • a Jolla phone ;D
  • SailfishOS >= 1.0.7.16 (earlies versions might work but aren’t tested)
  • Dev-Mode enabled
  • password to become root
  • SD-Card with enough space
  • some Linux knowledge

Instructions #

The following instructions use the following settings:

  • sd-card contains 1 partition
  • the partition device is mmcblk1p1

If your setting differs from these you have to change the corresponding commands.

  1. insert the sd-card into your phone

  2. start terminal

  3. change to root user: devel-su

  4. check whether card was found: ls /dev/mmcblk1

    • the card was found if the output is /dev/mmcblk1
    • if an error is thrown the card wasn’t found -> you have to reboot your phone
  5. check whether the card is mounted mount | grep mmcblk1

    • the card is mounted if the output is like

      /dev/mmcblk1p1 on /media/sdcard/<UUID_of_partition> type btrfs (rw,nosuid,nodev,noexec,noatime,dirsync,thread_pool=4,ssd,noacl,space_cache)
      
    • the card isn’t mounted if the output is empty

  6. if the card is mounted unmount all partitions of it

    umount /dev/mmcblk1p1
    
  7. format the partition you want to use for Android data ⚠️ all data will be lost ⚠️

    mkfs.btrfs /dev/mmcblk1p1
    
  8. mount sd-card:

    mount-sd.sh add mmcblk1p1
    
    • the partition will be mounted on /media/sdcard/<UUID_of_partition>
  9. stop all Android apps

  10. stop Android layer

    systemctl stop aliendalvik
    
  11. copy existing data of apps

    rsync -a --progress /data/media/ /media/sdcard/"$(blkid -o value -s UUID /dev/mmcblk1p1)"/android_storage/
    
  12. correct the permissions

    chown -R media_rw: /media/sdcard/"$(blkid -o value -s UUID /dev/mmcblk1p1)"/android_storage/
    chmod -R 770 /media/sdcard/"$(blkid -o value -s UUID /dev/mmcblk1p1)"/android_storage/
    
  13. create systemd-service file

    echo "[Unit]
    Description=Mount sd for android
    After=mount-sd@mmcblk1p1.service
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStart=/usr/local/sbin/mount-sd4android.sh start
    ExecStop=/usr/local/sbin/mount-sd4android.sh stop
    
    [Install]
    WantedBy=graphical.target display.service" > /etc/systemd/system/mount-sd4android.service
    
  14. create helper script

    echo '#!/bin/bash
    
    sd_uuid="$(blkid -o value -s UUID /dev/mmcblk1p1)"
    
    if [ "$1" == "start" ]
    then
        systemctl stop aliendalvik
        mount -o bind /media/sdcard/"${sd_uuid}"/android_storage /data/media
        systemctl start aliendalvik
    elif [ "$1" == "stop" ]
    then
        systemctl stop aliendalvik
        umount /data/media
    fi' > /usr/local/sbin/mount-sd4android.sh
    
  15. change permission of helper script

    chmod ug+x /usr/local/sbin/mount-sd4android.sh
    
  16. enable systemd-service

    systemctl enable mount-sd4android.service
    
  17. reboot your phone reboot

  18. start terminal

  19. check if all went well df -hT

    • all is ok if the output looks like:

      /dev/mmcblk1p1
                  btrfs     30G  8.4G   21G  29% /media/sdcard/4f1f8dbc-ed55-4b6c-8290-ac97e15b221f /dev/mmcblk1p1
                  btrfs     30G  8.4G   21G  29% /data/media
      /dev/fuse     fuse     30G  8.4G   21G  29% /home/nemo/android_storage
      
  20. if all went well delete the old data

    devel-su
    mount-sd4android.sh stop
    rm -rf /data/media/*
    mount-sd4android.sh start