Reply
Thread Tools
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:
Posts: 646 | Thanked: 1,124 times | Joined on Jul 2010 @ Espoo, Finland
#2
Thanks!
Advantages/disadvantages of using service vs .mount systemd ?
 
chemist's Avatar
Administrator | Posts: 1,036 | Thanked: 2,019 times | Joined on Sep 2009 @ Germany
#3
Apart of that the .mount is probably the way sane people would do, I like the Exec of the .service and I have no idea if the .mount actually does what I want (I did not test it) - wasn't me who got it working (I tried the .mount first but failed)
 
chemist's Avatar
Administrator | Posts: 1,036 | Thanked: 2,019 times | Joined on Sep 2009 @ Germany
#4
Hey Leinad, (why did you delete your post? it is ok to ask questions )
I ran into problems with the-vault so I changed the order it gets mounted, but you would not need to backup your .vault to the sdcard as it is already there

my device is on its way to helsinki atm (broken vibrator) but the way you have it atm seems wrong

my last lines would show something like

Code:
tmpfs             406M     0  406M   0% /mnt/asec
tmpfs             406M     0  406M   0% /mnt/obb
/dev/mmcblk1       31G  8.6G 22.4G  26% /media/sdcard/45823f6b...
/dev/mmcblk1       31G  8.6G 22.4G  26% /data/media
/dev/fuse          31G  8.6G 22.4G  26% /home/nemo/android_storage
for my taste you mount to much around...

and now that btrfs is mounted without hassle a big fat why
pops into my head, why are you using ~slow sdcard instead of internal mmc for $HOME? All the files are now properly sourced from sdcard so anything big you can just put on the sdcard and have it mounted with the shipped-with script, if you are about backups... what you are doing is no backup, what you are doing is making a device swap easy but in terms of backup this is pretty painfully wrong

Please enlighten me why you do what you do and why you are trying it this way, and I try to figure out how I may help you.

please note that android userdata is /data/media and gets fused to ~/android_storage by aliendalvik.service if you want to have all android files off at the sdcard we need to find the proper way first

Last edited by chemist; 2014-06-17 at 10:01.
 

The Following User Says Thank You to chemist For This Useful Post:
Posts: 594 | Thanked: 1,094 times | Joined on Aug 2012 @ Rhine
#5
Hi, i deleted my post, because i wanted to investigate a little bit further before posting, but since you read it anyways, we can go on

there are 2 main reasosns, why i want the complete home-folder on the sdcard:
- i really like the behaviour of the config, because every data you put/save/download on the device is automatically saved to the sdcard, you don't need to handle big files seperately
- i have 2 devices, because the screen of the first one broke, but it's still completely usable, so now i use it as "outdoor-device", because it's already broken. with this config, i can switch between those 2 devices easily, when i put the sdcard into the other device, everything is there, because of the complete mounting of the home-folder.

... and i never noticed any limitation, regarding speed.

until 1.0.7 settings app showed 2.7G on the device were in use, now it shows 4.7G are in use. i wonder, where those extra 2G come from...

df- h looks like this:
Code:
Filesystem            Size  Used Avail Use% Mounted on
rootfs                 14G  4.3G  9.1G  32% /
/dev/mmcblk0p28        14G  4.3G  9.1G  32% /
devtmpfs              405M   64K  405M   1% /dev
tmpfs                 406M   84K  406M   1% /dev/shm
tmpfs                 406M   26M  381M   7% /run
tmpfs                 406M     0  406M   0% /sys/fs/cgroup
tmpfs                 406M  8.0K  406M   1% /tmp
/dev/mmcblk0p18        64M   45M   20M  70% /firmware
/dev/mmcblk0p28        14G  4.3G  9.1G  32% /home
/dev/mmcblk0p25       7.9M  4.2M  3.8M  53% /persist
/dev/mmcblk0p19       7.9M  4.1M  3.9M  52% /drm
/dev/mmcblk0p9         48M  6.4M   41M  14% /var/systemlog
tmpfs                 406M     0  406M   0% /mnt/asec
tmpfs                 406M     0  406M   0% /mnt/obb
/dev/mmcblk1p1         59G  6.8G   49G  13% /mnt/sd
/dev/mmcblk1p1         59G  6.8G   49G  13% /home/nemo
/dev/fuse              14G  4.3G  9.1G  32% /home/nemo/android_storage
/dev/fuse              14G  4.3G  9.1G  32% /mnt/sd/.home/android_storage
/dev/mmcblk1p1         59G  6.8G   49G  13% /media/sdcard/45823f6b-...
 
chemist's Avatar
Administrator | Posts: 1,036 | Thanked: 2,019 times | Joined on Sep 2009 @ Germany
#6
how about a slightly different approach?

partition your sdcard as one btrfs (I am just irritated by the mmcblk1p1, if btrfs I would expect mmcblk1) and add subvolumes user, home and android - set the default volume to user and use the part about android userdata (.service or .mount) of my approach for android on sdcard.

Please keep in mind that I do not have a device atm! So there might be some flaws in the part below.

write your own .service or .mount to mount subvolume home to /home/nemo after /home got mounted but before aliendalvik and your df output should get cleaned up a bit (especially not fusing stuff in circles) meaning the last entries - this still breaks with the-vault as the first sdcard partition visible to it would be mounted to /home/nemo and you would copy .vault to backup.tar in the same directory.

after tmpfs you should have then
/dev/mmcblk1 mounted to /home/nemo
/dev/mmcblk1 mounted to /media/sdcard/($UUID)
/dev/mmcblk1 mounted to /data/media
/dev/fuse mounted to /home/nemo/android_storage

You fuse the android storage a second time to your sdcard? That does not copy anything, you need to mount something to /data/media before it gets fused by aliendalvik... I try to kept the system alone to have everything still working even if the µSD is missing.
 

The Following User Says Thank You to chemist For This Useful Post:
Posts: 594 | Thanked: 1,094 times | Joined on Aug 2012 @ Rhine
#7
Thanks, i got it working correct again

I missed the part with /data/media. It seems, the update copied / moved the android-data which was on my sdcard to /data/media, which was on the device. that's why so much less space was available on the device. btw: it did not copy all files, some are lost, bu i can live with that.

now i moved all data from /data/media back to the sdcard and mounted /data/media to the android-folder on the sdcard.

the p1 is there, because i'm using ext4, not btrfs.

my df -h output now looks like this:
Code:
/dev/mmcblk1p1         59G  4.2G   52G   8% /mnt/sd
/dev/mmcblk1p1         59G  4.2G   52G   8% /home/nemo
/dev/mmcblk1p1         59G  4.2G   52G   8% /data/media
/dev/fuse              59G  4.2G   52G   8% /home/nemo/android_storage
/dev/fuse              59G  4.2G   52G   8% /mnt/sd/.home/android_storage
/dev/mmcblk1p1         59G  4.2G   52G   8% /media/sdcard/45823f6b
i have no idea, where the second fuse mount comes from, i only mount this:
Code:
  mount /dev/mmcblk1p1 /mnt/sd
  mount -o bind /mnt/sd/.home /home/nemo
  mount -o bind /mnt/sd/.android /data/media
the settings app now shows, that 2.4G are in use on the device.

so, except this second fuse mount, everything seems to be ok again thanks.
 
chemist's Avatar
Administrator | Posts: 1,036 | Thanked: 2,019 times | Joined on Sep 2009 @ Germany
#8
Ah ok, that 2nd fuse is cause of the bind mount, it shows both endpoints.
 

The Following User Says Thank You to chemist For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 11:58.