We have moved to a new Sailfish OS Forum. Please start new discussions there.
6

[1.1.9.28] Mounting SD card as home partition and android storage [answered]

asked 2015-09-11 08:49:01 +0300

hopey gravatar image

updated 2015-10-24 00:35:22 +0300

Leinad gravatar image

Edit (Leinad): please don't change system filesand take a look here instead: http://talk.maemo.org/showthread.php?p=1486543#post1486543

(edit jolladiho) preconditions:

  1. your sd has a partitiontable
  2. your first partition has a linux filesystem
  3. your linux filesystem contains the folders .home and .android on root folder

I am using this script to mount my home dir and android folder to SD card /usr/sbin/mount-sd.custom.sh

#!/bin/bash

ACTION=$1

if [ "$ACTION" = "add" ]; then
  mount /dev/mmcblk1p1 /mnt/sd
  mount -o bind /mnt/sd/.home /home/nemo
  mount -o bind /mnt/sd/.android /data/media
else
  umount /data/media
  umount /home/nemo
  umount /mnt/sd
fi

and then mount it with /lib/systemd/system/mount-custom.service

[Unit]
Description=Handle custom sdcard
After=local-fs.target
RequiresMountsFor=/home

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/mount-sd.custom.sh add
ExecStop=/usr/sbin/mount-sd.custom.sh remove

[Install]
WantedBy=multi-user.target

(edit jolladiho): enable the service with "systemctl enable mount-custom.service"

After this to make the fusermount work properly for android storage we have to make changes in two files for 1.1.9.28, look the lines under the "#original:" tag:

/opt/alien/system/script/alien_setup_chroot.sh:

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

#original: for d in dev sys run media; do
for d in dev sys run media home; do
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        if [ $d == "sys" ]; then
            mount --make-private /sys/fs/cgroup
        fi
        mount --make-private --rbind /$d $ROOT/$d
    fi
done

/usr/sbin/apkd-mount:

if [[ "$CMD" == "apkd-umount" ]]; then
    /bin/umount "$MOUNTDIR"
else # apkd-mount
    if [ ! -d "$MOUNTDIR" ]; then
        mkdir -p "$MOUNTDIR"
    fi
    # On tablet and other non-btrfs devices, do homeification
    DATADIR="/home/.android/data"
    if [ ! -d "$DATADIR" ]; then
        # On phone and btrfs devices, use /data directly
        DATADIR="/data"
    fi
#original:   /bin/mount --bind "$DATADIR" "$MOUNTDIR"
    /bin/mount --rbind "$DATADIR" "$MOUNTDIR"
fi

The "apkd-mount"is new in 1.1.9.28 and does the "data" part, that was done in older versions in "alien_setup_chroot.sh".

Now reboot your device and check with df -h that home folder and android storage is mounted to SD card:

Filesystem            Size  Used Avail Use% Mounted on
rootfs                 14G  2,3G   11G  17% /
/dev/mmcblk0p28        14G  2,3G   11G  17% /
devtmpfs              404M   64K  404M   1% /dev
tmpfs                 405M  464K  405M   1% /dev/shm
tmpfs                 405M   30M  375M   8% /run
tmpfs                 405M     0  405M   0% /sys/fs/cgroup
tmpfs                 405M  8,0K  405M   1% /tmp
/dev/mmcblk0p19       7,9M  4,1M  3,9M  52% /drm
/dev/mmcblk0p18        64M   45M   20M  70% /firmware
/dev/mmcblk0p28        14G  2,3G   11G  17% /home
/dev/mmcblk0p25       7,9M  4,2M  3,8M  53% /persist
/dev/mmcblk0p9         48M  8,5M   39M  18% /var/systemlog
tmpfs                 405M     0  405M   0% /mnt/asec
tmpfs                 405M     0  405M   0% /mnt/obb
/dev/mmcblk1p1         59G   25G   31G  45% /mnt/sd
/dev/mmcblk1p1         59G   25G   31G  45% /home/nemo
/dev/mmcblk1p1         59G   25G   31G  45% /data/media
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/data
/dev/mmcblk1p1         59G   25G   31G  45% /opt/alien/data/media
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/bin
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/sbin
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/lib
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/usr
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/var
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/etc
tmpfs                 405M  8,0K  405M   1% /opt/alien/tmp
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/vendor
devtmpfs              404M   64K  404M   1% /opt/alien/dev
tmpfs                 405M  464K  405M   1% /opt/alien/dev/shm
tmpfs                 405M     0  405M   0% /opt/alien/sys/fs/cgroup
tmpfs                 405M   30M  375M   8% /opt/alien/run
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/media
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/home
/dev/mmcblk1p1         59G   25G   31G  45% /opt/alien/home/nemo
/dev/mmcblk0p28        14G  2,3G   11G  17% /opt/alien/system_jolla
/dev/fuse              59G   25G   31G  45% /opt/alien/home/nemo/android_storage
/dev/fuse              59G   25G   31G  45% /mnt/sd/.home/android_storage
/dev/fuse              59G   25G   31G  45% /home/nemo/android_storage

you do it at your own risk, carefuly. On mistakes you have to know, how to work with recovery mode.

This works great now. Thank you alot

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by hopey
close date 2015-09-13 16:34:43.566951

Comments

I propably should mention that most of this is taken from threads:

Leinads maemo talk thread

and

Chemists thread here

hopey ( 2015-09-11 09:51:04 +0300 )edit

nice to read the howto and that the answer helps. A vote to the answer and mark as answered would be nice too.

jolladiho ( 2015-09-13 12:56:51 +0300 )edit

Of course, sorry I'm noob :)

hopey ( 2015-09-13 16:33:36 +0300 )edit

ok, a hacking noob ;-). I am using the Jolla phone with the nemo home on sd card too and also helped in the maemo thread you mentioned above a little (alias meemorph).

jolladiho ( 2015-09-13 23:22:49 +0300 )edit
1

should the last but one line in the first script not read:

umount /mnt/sd

instead of:

umount /mnt/media

JayBeRayBearGun ( 2015-10-05 00:41:34 +0300 )edit

3 Answers

Sort by » oldest newest most voted
3

answered 2015-09-11 21:03:29 +0300

jolladiho gravatar image

updated 2015-09-11 21:09:12 +0300

You have to make changes in two files for 1.1.9.28, look the lines unter the "#original:" tag:

/opt/alien/system/script/alien_setup_chroot.sh:

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

#original: for d in dev sys run media; do
for d in dev sys run media home; do
    if [ "" == "$(grep $ROOT/$d /proc/mounts)" ]; then
        echo "mount $ROOT/$d"
        if [ $d == "sys" ]; then
            mount --make-private /sys/fs/cgroup
        fi
        mount --make-private --rbind /$d $ROOT/$d
    fi
done

/usr/sbin/apkd-mount:

if [[ "$CMD" == "apkd-umount" ]]; then
    /bin/umount "$MOUNTDIR"
else # apkd-mount
    if [ ! -d "$MOUNTDIR" ]; then
        mkdir -p "$MOUNTDIR"
    fi
    # On tablet and other non-btrfs devices, do homeification
    DATADIR="/home/.android/data"
    if [ ! -d "$DATADIR" ]; then
        # On phone and btrfs devices, use /data directly
        DATADIR="/data"
    fi
#original:   /bin/mount --bind "$DATADIR" "$MOUNTDIR"
    /bin/mount --rbind "$DATADIR" "$MOUNTDIR"
fi

The "apkd-mount"is new in 1.1.9.28 and does the "data" part, that was done in older versions in "alien_setup_chroot.sh".

you do it at your own risk, carefuly. On mistakes you have to know, how to work with recovery mode.

edit flag offensive delete publish link more
3

answered 2015-09-12 01:14:46 +0300

chemist gravatar image

your systemd.service needs to be triggered before aliendalvik or your mount will not be exported but the one that was there before (see my .mount's dependencies), altering any other file should not be necessary!

edit flag offensive delete publish link more
0

answered 2015-09-12 17:44:04 +0300

hopey gravatar image

Works great now, thanks!

edit flag offensive delete publish link more

Comments

1

Alter your starting post accordingly, please. Make it a proper how-to!

chemist ( 2015-09-12 22:28:12 +0300 )edit

Thank you for the howto, summarizing the well-known threads on a concise page! I have two questions though:

  1. File System

What file system did you choose for the SD card? Given all the balancing-pain with btrfs I cannot see a real advantage of using it on the card as well. You have to live with btrfs on the phone, but why not etx4 on the card? (In general I can totally not understand the decision for btrfs for a 16GB disk on a mobile device.)

  1. fstab for home partition?

Why not just mount /home to the card using fstab? something like: UUID=... / btrfs defaults,autodefrag,noatime 0 0 UUID=... /home btrfs noatime,subvol=@home 0 0 With android and all the fuse hodgepodge there is no way around triggered scripts, but the /home directory is not affected here.

femtopeta ( 2015-09-19 00:11:26 +0300 )edit
  1. Actually the card is EXT4.

  2. Yeah this would probably work. I just made mounting this way, so I have all changes in one place. Not really good reason though...

hopey ( 2015-09-27 12:49:58 +0300 )edit

Question tools

Follow
12 followers

Stats

Asked: 2015-09-11 08:49:01 +0300

Seen: 4,318 times

Last updated: Oct 24 '15