View Single Post
chemist's Avatar
Administrator | Posts: 1,036 | Thanked: 2,019 times | Joined on Sep 2009 @ Germany
#1
>
Code:
Version: 1.1.2.15
This is no beginners guide, you need to know your way around! I try to make everything as foolproof as possible.
This version does only apply to the SFOS release with the same version number!


*Understand what to do before you do!*


What I did to share the space of my uSD between nemo and android without getting duplicates with bind-mounts or any other hickup, read carefully and use at your own risk:
  • format the whole usdcard (mmcblk1 not mmcblk1p1) to btrfs
  • mount that volume (=0)
  • create two subvolumes > jolla and android
  • set the default volume to jolla (the default is what gets mounted when something calls mount /dev/mmcblk1)
  • stop alien-dalvik and copy everything form /data/media to the new subvolume android (don't move the files, this way you have all basics alien-dalvik needs even after pulling the uSD)
  • add a system.service to systemd that mounts and unmounts the subvolume for android as needed and honours aliendalvik.service The problems to solve are: aliendalvik fuse-mounts its /data/media to /home/nemo/android_storage so you need to make sure everything is mounted before that happens on boot, and stop aliendalvik when the sd gets pulled or the mount needs to be lifted for any other cause.
  • alter alien.sh to -rbind /data to the /opt/alien chroot
  • reboot and wait for the device to settle, as soon as your jolla volume is mounted in /media/, you should see /dev/mmcblk1 being mounted to both /media/sdcard/($UUID) and /data/media


----------
detailed cmds use at your own risk

## preparing the sdcard, should only be needed once! ##
first do
Code:
systemctl stop aliendalvik.service
then follow this list


Code:
umount /dev/mmcblk1p1 #unmount the card might be another /dev or even more than one
mkfs.btrfs -O ^extref -f /dev/mmcblk1 #format the card (no need for partition)
mount -o subvolid=0 /dev/mmcblk1 /media/sdcard
cd /media/sdcard
btrfs subvolume create jolla #create folder called jolla
btrfs subvolume create android #create folder called android
btrfs subvolume list . #returns an ID for each subvolume
btrfs subvolume set-default ID for jolla /media/sdcard/ #sets jolla to be mounted as default
chown nemo:nemo jolla/ #add -R if needed
chmod 775 jolla/
chmod 777 android/
cp -r -a -v /data/media/* /media/sdcard/android
cd ..
umount /dev/mmcblk1
## preparing the system ##
create /etc/systemd/system/androidsdcard.service and fill with:

#
Code:
[Unit]
Description=Mount SDCard btrfs subvolume for Android
ConditionPathExists=/dev/mmcblk1
ConditionPathIsDirectory=/data/media
Requires=local-fs.target
Before=aliendalvik.service
After=local-fs.target mount-sd@mmcblk1.service
BindsTo=mount-sd@mmcblk1.service
    
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/mount -o subvol=android,compress,dirsync,noatime,users /dev/mmcblk1 /data/media
ExecStop=/bin/sh/ -c 'systemctl stop aliendalvik.service;umount /data/media'
    
[Install]
WantedBy=local-fs.target aliendalvik.service
(beware of those linewraps of ExecStart and Stop!!! one line each)
with
Code:
systemctl enable androidsdcard.service
the service file gets started every time aliendalvik is started and stops aliendalvik when it gets stopped, on boot it prevents aliendalvik from starting if it is not started yet but waits for the local-fs to be settled and actually having a mountpoint (due to the-vault only looking for the biggest mounted sdcard partition we have to wait for mount-sd too to have it read by the-vault first)

*for the future we only need to load the service file to its place and enable it, if something changes I will update the code*


Alternatively you may have a .mount systemd instead (not both!!!) of a service

First, create /etc/systemd/system/data-media.mount file:

Code:
[Unit]
Description=SD card btrfs subvolume for Android
ConditionPathExists=/dev/mmcblk1
ConditionPathIsDirectory=/data/media
Requires=local-fs.target
Before=aliendalvik.service
After=local-fs.target mount-sd@mmcblk1.service
BindsTo=mount-sd@mmcblk1.service

[Mount]
What=/dev/mmcblk1
Where=/data/media
Options=subvol=android,compress,dirsync,noatime,users

[Install]
WantedBy=local-fs.target aliendalvik.service
Second, create /etc/systemd/system/aliendalvik.service.d/sdcard.conf file:

Code:
[Unit] 
PartOf=data-media.mount
Then run
Code:
systemctl enable data-media.mount
Update: now for > 1.1.2.x you need additionally to move
Code:
data
form the bind section (*line19*) of /
Code:
opt/alien/system/script/alien.sh
to its rbind section (*line26*) so it survives a reboot too. As always, you probably want to save the original file to alien.sh.bak **before** you start messing around!

move the value [data] from section

Code:
for d in bin sbin lib usr var etc tmp home vendor data; do
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        mount --bind /$d $ROOT/$d
    fi
done
to
Code:
for d in dev sys run; do 
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        mount --rbind /$d $ROOT/$d
    fi
done
result looks like


Code:
for d in bin sbin lib usr var etc tmp home vendor; do
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        mount --bind /$d $ROOT/$d
    fi
done
    
for d in dev sys run data; do 
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        mount --rbind /$d $ROOT/$d
    fi
done

PLEASE Check Original Postings
original posting on tjc https://together.jolla.com/question/...-with-android/

the .mount solution by Vuubi is
https://together.jolla.com/question/...#post-id-46430

Last edited by chemist; 2015-02-24 at 15:38.
 

The Following 3 Users Say Thank You to chemist For This Useful Post: