maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [HowTo][WIP] use real sdcard as home-partition and/or for android data (https://talk.maemo.org/showthread.php?t=92449)

Leinad 2014-01-17 21:59

[HowTo][WIP] use real sdcard as home-partition and/or for android data
 

Updated for Salfish >= 1.0.4

If you had it running before and problems after the last Update (1.0.4), you only need to do step 6!


First of all: this config is meant to be used with UNIX filesystems like ext4. There are also some suggestions for btrfs in this thread. I guess, it needs to be handled differently.
Second: i'm not sure, how it affects speed with slow sdcards, but i'd recommend using a real fast (and big) sdcard

Everything you do, you do at your own risk! I tried to write everything correct, but mistakes happen...

So, here we go:
x.a is always for using as home partition
x.b is always for android data

1. create new folder for custom mountpoint
Code:

devel-su
Code:

mkdir /mnt/sd
2. mount sdcard to that folder (assuming you have formatted as p1)
Code:

mount /dev/mmcblk1p1 /mnt/sd
3. create folders
3.a in the mounted sdcard create a hidden folder for home
Code:

mkdir /mnt/sd/.home
Code:

chown nemo:nemo /mnt/sd/.home
(home folder should be owned by nemo)
3.b in the mounted sdcard create a hidden folder for android
Code:

mkdir /mnt/sd/.android
Code:

chmod 777 /mnt/sd/.android
(android apps need right access)

4. sync new folders with your existing data
4.a sync home folder
Code:

rsync -a /home/nemo/ /mnt/sd/.home
4.b sync android folder (if you want)
Code:

rsync -a /data/sdcard/ /mnt/sd/.android
5. at this point, you could delete the old data stored on the device. i deletet only images and videos in home + android data.
i would not recommend to delete folders in home-folder, just the big files
of course you can also do this later, after some days of testing.

6. create out own bootscript
6.1. create a file mount-sd.custom.sh with this content:
Code:

#!/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/sdcard
else
  umount /data/sdcard
  umount /home/nemo
  umount /mnt/sd
fi

and move it to /usr/sbin
Code:

cp mount-sd.custom.sh /usr/sbin/mount-sd.custom.sh
chown root:root /usr/sbin/mount-sd.custom.sh
chmod +x /usr/sbin/mount-sd.custom.sh

6.2. create a file mount-custom.service with this content:
Code:

[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

and move it to /lib/systemd/system
Code:

cp mount-custom.service /lib/systemd/system/mount-custom.service
chown root:root /lib/systemd/system/mount-custom.service
systemctl enable mount-custom.service

7. reboot your device and check, if everything is working as expected
Code:

df -h
should show something like this:
Code:

Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  1.9G  12G  15% /
/dev/mmcblk0p28        14G  1.9G  12G  15% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  360K  406M  1% /dev/shm
tmpfs                407M  28M  380M  7% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  20K  407M  1% /tmp
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p9        48M  9.2M  39M  20% /var/systemlog
/dev/mmcblk0p28        14G  1.9G  12G  15% /swap
/dev/mmcblk0p28        14G  1.9G  12G  15% /home
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1p1        60G  8.3G  49G  15% /mnt/sd
/dev/mmcblk1p1        60G  8.3G  49G  15% /home/nemo
/dev/mmcblk1p1        60G  8.3G  49G  15% /data/sdcard
/dev/mmcblk1p1        60G  8.3G  49G  15% /media/sdcard/4582345364s...


Q&A

Why do you put android data in a hidden folder?
Otherwise, my Gallery was full of map tiles. But if you like this, just remove the dot ;)

Why do you put home data in a hidden folder?
Otherwise, my Gallery showed every image twice. But if you like this, just remove the dot ;)

meemorph 2014-01-18 11:05

Quote:

Originally Posted by Leinad (Post 1407186)
So.....


the solution is really simple:
i created a folder /mnt/sdcard2/ (chmod 777)
then just mounted the sdcard the "traditional way" to that folder:
Code:

mount /dev/mmcblk1p1 /mnt/sdcard2/
then mounted the "real" sdcard on the android folder
Code:

mount -o bind /mnt/sdcard2 /data/sdcard/
... and that's it!
i added those two lines at the end of /usr/sbin/mount-sd.sh and it works without any problems (till now )
...

Don't forget to unmount on reboot or shutdown. Here an other cite:

http://talk.maemo.org/showpost.php?p=1404380

it uses a hidden directory and unmounts it on reboot - writes cached data.

Leinad 2014-01-18 12:29

Re: [HowTo] use sdcard for android apps
 
Thanks for the hint, i missed that!

I added the unmounting and also liked the idea of the hidden folder, because otherwise my gallery was full of map tiles :)

so i moved all android stuff to /mnt/sdcard2/.android and adapted the script.

also, i want my pictures and videos to be stored on the real sdcard, so i creadet the needed folder and added the mount (and unmounts).

i will update the first post.

meemorph 2014-01-18 20:13

Re: [HowTo] use sdcard for android apps
 
Quote:

Originally Posted by Leinad (Post 1407290)
Thanks for the hint, i missed that!

I added the unmounting and also liked the idea of the hidden folder, because otherwise my gallery was full of map tiles :)

...

Yes thats why I am using a hidden directory too. Your update looks good.

Schturman 2014-01-18 20:45

Re: [HowTo] use real sdcard for camera, android data, etc
 
Leinad, can you update the first post for noobs please.
* full scrip,where to place (permissions etc)
* create/not create folders manually, transfer/not transfer files, before/after script etc..
* how to run it (full command)

Thanks

bob_bipbip 2014-01-18 21:13

Re: [HowTo] use real sdcard for camera, android data, etc
 
i've formated my sd card in btrfs, and maked subvolume, and mount with this script:
mount -o subvol=sdcard,compress /dev/mmcblk1 /data/sdcard/
mount -o subvol=Videos /dev/mmcblk1 /home/nemo/Videos/
mount -o subvol=Desktop /dev/mmcblk1 /home/nemo/Desktop/
mount -o subvol=Documents /dev/mmcblk1 /home/nemo/Documents/
mount -o subvol=Downloads /dev/mmcblk1 /home/nemo/Downloads/
mount -o subvol=Music /dev/mmcblk1 /home/nemo/Music/
mount -o subvol=Pictures /dev/mmcblk1 /home/nemo/Pictures/
mount -o subvol=Public /dev/mmcblk1 /home/nemo/Public/
mount -o subvol=Templates /dev/mmcblk1 /home/nemo/Templates/

Thoke 2014-01-19 12:04

Re: [HowTo] use real sdcard for camera, android data, etc
 
Noticed the problem with using run/ for transferring data to sdcard the hard way, tried moving my music to it via mtp (symlinked run/user/10000/media/sdcard so it showed up in mtp-mode). The transfer got stuck and I cancelled it. It stuck completely after that. Now the device complains that the memory is full -even after reboot- and there's nothing in my sd-card.

NEVER USE run/user/10000/media/sdcard TO TRANSFER DATA TO YOUR MICROSD.

PS: It was a lot of music.


EDIT: The problem isn't related to topic at hand

rannari 2014-01-19 12:21

Re: [HowTo] use real sdcard for camera, android data, etc
 
Quote:

Originally Posted by Thoke (Post 1407483)
...
NEVER USE run/user/10000/media/sdcard TO TRANSFER DATA TO YOUR MICROSD.

I haven't got any problems with symlink to /home/nemo/ -folder. Sdcard is formatted as btrfs and I am using Ubuntu Linux for connection.

Leinad 2014-01-19 13:38

Re: [HowTo] use real sdcard for camera, android data, etc
 
Quote:

Originally Posted by Schturman (Post 1407381)
Leinad, can you update the first post for noobs please.
* full scrip,where to place (permissions etc)
* create/not create folders manually, transfer/not transfer files, before/after script etc..
* how to run it (full command)

Thanks

i will, but ATM it's more like finding out "best practice" to do it, with a lot of renaming / moving files and folders...
when i / we found a "final" way to go, i will post a "noob-proof" receipe.

for now, i think it's better, when only people, who are knowing what they do try this out.

edit: please check out update in first post (mounting complete nemo-home-folder) and tell, what you think. can it be done this way without any problems?

Thoke 2014-01-19 15:14

Re: [HowTo] use real sdcard for camera, android data, etc
 
Quote:

Originally Posted by rannari (Post 1407485)
I haven't got any problems with symlink to /home/nemo/ -folder. Sdcard is formatted as btrfs and I am using Ubuntu Linux for connection.

Yes, it seems the problem is in permissions, not in copying to sdcard through /run/... Somehow my microsd has some strange permissions set in it denying every change made to it...

egnat69 2014-01-20 09:57

Re: [HowTo] use real sdcard for camera, android data, etc
 
Quote:

Originally Posted by Leinad (Post 1407503)
edit: please check out update in first post (mounting complete nemo-home-folder) and tell, what you think. can it be done this way without any problems?

no expert on this topic but not entirely sure about performance issues due to the speed of that sd-port in general... would be really happy if you could look into this a bit during testing your solutions ;D

Leinad 2014-01-20 19:30

Re: [HowTo] use real sdcard for camera, android data, etc
 
Quote:

Originally Posted by egnat69 (Post 1407637)
no expert on this topic but not entirely sure about performance issues due to the speed of that sd-port in general... would be really happy if you could look into this a bit during testing your solutions ;D

yes, i had the same thought, but could not notice any difference in speed the last day, using it.

This is, what df -h now puts out with my configuration:
Code:

[nemo@localhost ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  4.1G  9.2G  31% /
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  268K  406M  1% /dev/shm
tmpfs                407M  23M  384M  6% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  24K  407M  1% /tmp
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /swap
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /home
/dev/mmcblk0p9        48M  7.5M  40M  16% /var/systemlog
/dev/mmcblk1p1        60G  2.6G  54G  5% /mnt/sdcard2
/dev/mmcblk1p1        60G  2.6G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.6G  54G  5% /data/sdcard
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1p1        60G  2.6G  54G  5% /run/user/100000/media/sdcard
/dev/mmcblk1p1        60G  2.6G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.6G  54G  5% /data/sdcard

before encouraging other people to use it this way, i really would like to hear the opinion of at least one, who is more expert than me :)

edit: i don't understand, why /home/nemo and /data/sdcard are listed 2 times for example...

Leinad 2014-01-21 13:37

Re: [HowTo] use real sdcard for camera, android data, etc
 
There was at least one little problem with my config:
all media (pictures, videos, documents, ...) was shown twice.

my assuption was, it's because it's found in
/home/nemo and in /mnt/sdcard2/home

so i renamed /mnt/sdcard2/home to /mnt/sdcard2/.home and adapted the script.

now everything seems to work fine again. will update first post.

javispedro 2014-01-21 20:15

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Leinad (Post 1407186)
it uses tmpfs and is limited to ~400MB on Jolla and will be gone after every reboot, so IMHO absolutely not usefull for mounting the sdcard.

Errrrrr.... WHY?

The limits you describe are correct... for the tmpfs mount itself! They will not apply to whatever you store inside the sdcard mountpoint.

If you let the default mountpoint, then your changes simplify quite a lot: you just need to bind mount the Android sdcard directory, and that's about it.

Leinad 2014-01-22 07:33

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by javispedro (Post 1408026)
Errrrrr.... WHY?

Well, there are 2 main reasons :)
  1. i want to be able to store more than 400M on my 64G card
  2. i want the stored data to be still there after a reboot

Quote:

Originally Posted by javispedro (Post 1408026)
The limits you describe are correct... for the tmpfs mount itself! They will not apply to whatever you store inside the sdcard mountpoint.

If you let the default mountpoint, then your changes simplify quite a lot: you just need to bind mount the Android sdcard directory, and that's about it.

by default, there is no other mountpoint than the tmpfs-mountpoint. When i bind mount folders to the default tmpfs mountpoint, they have the same limitations!
Just to show you, what i mean, i mounted it the way you suggested and here's the output:
Code:

[root@localhost nemo]# mount -o bind /run/user/100000/media/sdcard /home/nemo
[root@localhost nemo]# mount -o bind /run/user/100000/media/sdcard /data/sdcard

Code:

[root@localhost nemo]# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  4.1G  9.2G  31% /
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  72K  407M  1% /dev/shm
tmpfs                407M  33M  374M  9% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  8.0K  407M  1% /tmp
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p9        48M  7.1M  41M  15% /var/systemlog
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /swap
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /home
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
tmpfs                407M  33M  374M  9% /home/nemo
tmpfs                407M  33M  374M  9% /data/sdcard

Not using the tmpfs mountpoint is the main point of this thread :)

javispedro 2014-01-22 07:54

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Obviously, you need to mount the sd card ...

Also, you must mount the sdcard before creating the bind mount. Mounts don't propagate over to bind mounts by default. Alternatively, you might use --make-shared to ensure they are propagated, but this option is poorly documented.

Leinad 2014-01-22 08:17

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Sorry, i'm afraid, i don't understand, what you mean...

Quote:

Originally Posted by javispedro (Post 1408117)
Obviously, you need to mount the sd card ...

that's what i do with
Code:

mount /dev/mmcblk1p1 /mnt/sdcard2
Quote:

Originally Posted by javispedro (Post 1408117)
Also, you must mount the sdcard before creating the bind mount.

i do...

What exactly would you do different? Could you please provide some lines of Code to show, what you mean?

As i said, i'm no expert and happy for every improvement!

javispedro 2014-01-22 09:30

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
In the df output you attached there is no sd card mounted.

An example:

If you undo your modifications, after reboot, your sdcard gets mounted to
/run/user/100000/media/sdcard .

Afterwards, just run:
Code:

mount -o bind /run/user/100000/media/sdcard /data/sdcard
Are there any problems with the above (except that it is not automated)?


To automate it all you have to do is to ensure it is done _after_ mounting the SD card. That means that either you edit the mount-sd.sh script or insert a new udev event handler.

Leinad 2014-01-22 10:02

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
i'm not sure, why the mount of the sdcard is missing in the output above, but it was mounted on /run/user/100000/media/sdcard

i undid all my modifications and ran
Code:

mount -o bind /run/user/100000/media/sdcard /data/sdcard
i tried the same some days ago and the output looked like
Code:

...
tmpfs                407M  33M  374M  9% /run/user/100000/media/sdcard
tmpfs                407M  33M  374M  9% /data/sdcard

and that's exactly the main problem:
i was not able to store more than 400MB on the sdcard, because the limitations of /run/user/100000/media/sdcard go over to /data/sdcard if mounted that way!

HolgerN 2014-01-22 11:20

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
The problem is that /run/user/100000/media/sdcard is not mounted to the sdcard /dev/mmcblk1p1.

All subfolder of /run are tmpfs. This means that a mount -o bind /run/... /media/sdcard leads to that /media/sdcard points also to tmpfs.

Be sure that /run/user/100000/media/sdcard is mounted with
Quote:

findmnt /run/user/100000/media/sdcard
The SOURCE must be /dev/mmcblk1p1!

Then, mount -o /run/user/100000/media/sdcard /data/sdcard should work correctly.

On my Jolla i have access to 59G on /run/user/100000/media/sdcard and /data/sdcard/sdcard and both are pointing to /dev/mmcblk1p1.

javispedro 2014-01-22 14:58

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Leinad (Post 1408144)
i'm not sure, why the mount of the sdcard is missing in the output above, but it was mounted on /run/user/100000/media/sdcard

Well, if it is missing from that list, then it is not mounted. Can you elaborate on how do you detect is mounted? Maybe it simply isn't...

Quote:

Originally Posted by Leinad (Post 1408144)
i was not able to store more than 400MB on the sdcard, because the limitations of /run/user/100000/media/sdcard go over to /data/sdcard if mounted that way!

Do you realize this would make mount completely useless?
You would not be able to use an SD card if your internal memory was full!

Obviously, it does not work this way. Something is wrong and I suggest you carefully verify your setup.

Leinad 2014-01-22 22:10

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
would you mind sharing your df output after mounting everything the way you suggested?

J4ZZ 2014-01-22 23:03

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
should look similar to this:
Code:

[root@Jolla nemo]# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  5.0G  8.3G  38% /
/dev/mmcblk0p28        14G  5.0G  8.3G  38% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  72K  407M  1% /dev/shm
tmpfs                407M  34M  373M  9% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  8.0K  407M  1% /tmp
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p9        48M  8.3M  40M  18% /var/systemlog
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p28        14G  5.0G  8.3G  38% /swap
/dev/mmcblk0p28        14G  5.0G  8.3G  38% /home
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1          60G  288K  56G  1% /run/user/100000/media/sdcard
[root@Jolla nemo]#

:)

Edit: This is the script (also posted at jollausers.com)

Code:

#!/bin/bash

SDCARD=/dev/sdcard
DEF_UID=$(grep "^UID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)
DEF_GID=$(grep "^GID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)
DEVICEUSER=$(getent passwd $DEF_UID | sed 's/:.*//')
MNT=/run/user/$DEF_UID/media/sdcard

if [ "$ACTION" = "add" ]; then
        if [ -b /dev/mmcblk1p1 ]; then
                ln -sf /dev/mmcblk1p1 $SDCARD
        elif [ -b /dev/mmcblk1 ]; then
                ln -sf /dev/mmcblk1 $SDCARD
        else
                exit $?
        fi       
        su $DEVICEUSER -c "mkdir -p $MNT"
        case "${ID_FS_TYPE}" in
                vfat|ntfs|exfat)
                        mount $SDCARD $MNT -o uid=$DEF_UID,gid=$DEF_GID
                        ;;
                *)
                        mount $SDCARD $MNT
                        chown $DEVICEUSER: $MNT
                        ;;
        esac
else
        umount $SDCARD

        if [ $? = 0 ]; then
                rm -f $SDCARD
        else
                umount -l $MNT
                rm -f $SDCARD
        fi
fi

or a similar modification here in the: Jolla User Experience Thread

Leinad 2014-01-24 11:11

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Well, that's really strange... i know i had this problem a week ago, but now i can't reproduce it.
I played around a lot with the configuration and also reformatted the sdcard several times with different FS, so maybe the problem was present, when the sdcard was on FAT32 (don't want to reformat for testing, because now there's a lot of data on it), ATM it's on ext4.

So i guess, javispedro is right and i mixed something up, while playing around with the sdcard... so i removed my own mountpoint and use the standard mountpoint instead.

Now my mount-sd.sh looks like this:
Code:

#!/bin/bash

SDCARD=/dev/sdcard
DEF_UID=$(grep "^UID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)
DEF_GID=$(grep "^GID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)
DEVICEUSER=$(getent passwd $DEF_UID | sed 's/:.*//')
MNT=/run/user/$DEF_UID/media/sdcard

if [ "$ACTION" = "add" ]; then
        if [ -b /dev/mmcblk1p1 ]; then
                ln -sf /dev/mmcblk1p1 $SDCARD
        elif [ -b /dev/mmcblk1 ]; then
                ln -sf /dev/mmcblk1 $SDCARD
        else
                exit $?
        fi
        su $DEVICEUSER -c "mkdir -p $MNT"
  mount $SDCARD $MNT
  mount -o bind ${MNT}/.home /home/nemo
  mount -o bind ${MNT}/.android /data/sdcard
else
  umount /data/sdcard
  umount /home/nemo
        umount $SDCARD

        if [ $? = 0 ]; then
                rm -f $SDCARD
        else
                umount -l $MNT
                rm -f $SDCARD
        fi
fi

and my df output looks like this:
Code:

[nemo@localhost ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  4.1G  9.2G  31% /
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  72K  407M  1% /dev/shm
tmpfs                407M  20M  387M  5% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  8.0K  407M  1% /tmp
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /swap
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /home
/dev/mmcblk0p9        48M  6.6M  41M  14% /var/systemlog
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1p1        60G  2.6G  54G  5% /run/user/100000/media/sdcard
/dev/mmcblk1p1        60G  2.6G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.6G  54G  5% /data/sdcard

...looks good to me :)

i think, now it's time to rewrite first post to "noob-proof" receipe, or are there any problems with this conf? on my device, it works without problems.

javispedro 2014-01-24 11:57

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Moving $HOME (/home/nemo) to the sdcard may be dangerous. First, it means your sdcard must use a UNIXy filesystem (ext4, btrfs, ...). Otherwise result is probably going to be a reboot loop.

Second, I don't know enough of systemd to know if the sdcard will be always mounted before the user stuff starts launching. But if it works for you...

meemorph 2014-01-24 12:00

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Leinad (Post 1408619)
... cut done by meemorph ...

i think, now it's time to rewrite first post to "noob-proof" receipe, or are there any problems with this conf? on my device, it works without problems.

The script looks good.

You are asking for problems: It could be, that mount-sd.sh is executed very late at startup of the device. If other processes, that are started before mount-sd.sh is done, need some files from /home/nemo, they would read the "old" files from the tempfs.

At the moment, I am only using the /data/sdcard rebind for android (cite from post #2) and have some symbolic links at music, videos and pictures. I had two issues with that.

1. If I create an ambience from a picture on the sd-card, this ambience is gone after reboot. Thats why I think, the mount-sd.sh is executed too late. If I copy the picture to the picture folder (tempfs) and create the ambience, it is persistent. You should try, If an ambience if persistent with your conf.

2. I advise to use the .android subdirectory for the /data/sdcard rebind, like you did in your script. Because: I did an uninstall of the android support an all android apps. Then I did a new install of the android support. After that the /data/sdcard folder was *completly* empty. The android support deleted the hole folder, I think. I had some pictures before uninstalling and installing the androis support in that folder, but everything was gone, not only the folders of the android apps. If someone binds the root of the sdcard to /data/sdcard, do not uninstall and install android support, before you have a backup.

Leinad 2014-01-25 12:03

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by meemorph (Post 1408628)
1. If I create an ambience from a picture on the sd-card, this ambience is gone after reboot. Thats why I think, the mount-sd.sh is executed too late. If I copy the picture to the picture folder (tempfs) and create the ambience, it is persistent. You should try, If an ambience if persistent with your conf.

Hm, that's interesting: now i have this problem too. I never had it, when using my own mountpoint (/mnt/sdcard2). Just tried it again with own mountpoint and the problem is gone again...
are there important reasons not to use an own mountpoint?

Quote:

Originally Posted by meemorph (Post 1408628)
2. I advise to use the .android subdirectory for the /data/sdcard rebind, like you did in your script. Because: I did an uninstall of the android support an all android apps. Then I did a new install of the android support. After that the /data/sdcard folder was *completly* empty. The android support deleted the hole folder, I think. I had some pictures before uninstalling and installing the androis support in that folder, but everything was gone, not only the folders of the android apps. If someone binds the root of the sdcard to /data/sdcard, do not uninstall and install android support, before you have a backup.

that's good to know!


Edit: it totally seems like the mount-sd.sh is called twice during bootup process.
One time at an early stage, where the ambiance stuff works (but default mountpoint is not ready).
And one time later, where the default mountpoint is ready, but it's too late for the ambiance stuff.

When i add these lines at the end of the file
Code:

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

my df output looks like this:
Code:

[nemo@localhost ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  4.1G  9.2G  31% /
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  268K  406M  1% /dev/shm
tmpfs                407M  23M  384M  6% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  24K  407M  1% /tmp
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /swap
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /home
/dev/mmcblk0p9        48M  7.5M  40M  16% /var/systemlog
/dev/mmcblk1p1        60G  2.6G  54G  5% /mnt/sdcard2
/dev/mmcblk1p1        60G  2.6G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.6G  54G  5% /data/sdcard
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1p1        60G  2.6G  54G  5% /run/user/100000/media/sdcard
/dev/mmcblk1p1        60G  2.6G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.6G  54G  5% /data/sdcard

Now i added a condition:
Code:

if [ "$ACTION" = "add" ]; then
  if [ $(mount | grep -c /mnt/sdcard2) != 1 ]; then
    mount /dev/mmcblk1p1 /mnt/sdcard2
    mount -o bind /mnt/sdcard2/.home /home/nemo
    mount -o bind /mnt/sdcard2/.android /data/sdcard
  fi
else
  umount /data/sdcard
  umount /home/nemo
  umount /mnt/sdcard2
fi

and the output looks like this:
Code:

[nemo@localhost ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                14G  4.1G  9.2G  31% /
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /
devtmpfs              406M  64K  406M  1% /dev
tmpfs                407M  204K  406M  1% /dev/shm
tmpfs                407M  33M  374M  9% /run
tmpfs                407M    0  407M  0% /sys/fs/cgroup
tmpfs                407M  8.0K  407M  1% /tmp
/dev/mmcblk0p19      8.0M  4.1M  3.9M  52% /drm
/dev/mmcblk0p25      8.0M  4.2M  3.8M  54% /persist
/dev/mmcblk0p9        48M  6.6M  41M  14% /var/systemlog
/dev/mmcblk0p18        64M  45M  20M  70% /firmware
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /swap
/dev/mmcblk0p28        14G  4.1G  9.2G  31% /home
/dev/mmcblk1p1        60G  2.7G  54G  5% /mnt/sdcard2
/dev/mmcblk1p1        60G  2.7G  54G  5% /home/nemo
/dev/mmcblk1p1        60G  2.7G  54G  5% /data/sdcard
tmpfs                407M    0  407M  0% /mnt/asec
tmpfs                407M    0  407M  0% /mnt/obb
/dev/mmcblk1p1        60G  2.7G  54G  5% /run/user/100000/media/sdcard


bob_bipbip 2014-01-25 13:45

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
mine is better :D

Code:

/dev/mmcblk0p28 on / type btrfs (rw,noatime,thread_pool=4,ssd,noacl,space_cache,autodefrag)
devtmpfs on /dev type devtmpfs (rw,relatime,size=415332k,nr_inodes=103833,mode=755)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/debug type cgroup (rw,nosuid,nodev,noexec,relatime,debug)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
tmpfs on /tmp type tmpfs (rw)
mtp on /dev/mtp type functionfs (rw,relatime)
/dev/mmcblk0p25 on /persist type ext4 (ro,nosuid,nodev,relatime,data=ordered)
/dev/mmcblk0p19 on /drm type ext4 (rw,nosuid,nodev,relatime,data=ordered)
/dev/mmcblk0p9 on /var/systemlog type ext4 (rw,nosuid,nodev,relatime,data=ordered)
/dev/mmcblk0p18 on /firmware type vfat (ro,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro)
/dev/mmcblk0p28 on /swap type btrfs (rw,relatime,thread_pool=4,ssd,noacl,space_cache,autodefrag)
/dev/mmcblk0p28 on /home type btrfs (rw,relatime,thread_pool=4,ssd,noacl,space_cache,autodefrag)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
statefs on /run/state type fuse.statefs (rw,nosuid,nodev,relatime,user_id=0,group_id=100,default_permissions,allow_other)
statefs on /run/user/100000/state type fuse.statefs (rw,nosuid,nodev,relatime,user_id=100000,group_id=100000,default_permissions,allow_other)
/dev/mmcblk1 on /data/sdcard type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Videos type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Desktop type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Documents type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Downloads type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Music type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Pictures type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Public type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)
/dev/mmcblk1 on /home/nemo/Templates type btrfs (rw,relatime,thread_pool=4,compress=zlib,ssd,noacl,space_cache)


bob_bipbip 2014-01-25 14:24

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
ok, so someone here asked me how i have made all these subvolume ****, here is a exact copy of the pm i replied to:

ok, so here it goes.

first, i have to say that my jolla have a problem. sd card never mounted in the default folder (/run/user/100000/media/sdcard) so, i don't know how it will works on a "correct" jolla. but whatever, i "don't think" there will be more problem. still ...

second, i'm seeing a lot of misconception about btrfs. everyone is speeking about /dev/mmcblk1p1. btrfs do NOT need classical partition. everything you must heard about is just /dev/mmcblk1, NOT ....p1.
so first, format it in the right way:

mkfs.btrfs -f /dev/mmcblk1

yeah right, WITHOUT any p1. direct from the block ;)
(the "-f" is not mandatory, it useful when you have problem because the device don't want to release it or something, whatever. try first without, if it works congrats, if you need it, use it)

we could check if it is a real btfrs file system:

btrfs filesystem show /dev/mmcblk1

then, you will be forced to mount the entire "disk" in a folder to create the subvolume:

mkdir /mnt/microsd
mount /dev/mmcblk1 /mnt/microsd/

we create can now create all the subvolume

btrfs subvolume create /mnt/microsd/Desktop
btrfs subvolume create /mnt/microsd/Documents
btrfs subvolume create /mnt/microsd/Downloads
btrfs subvolume create /mnt/microsd/Music
btrfs subvolume create /mnt/microsd/Public
btrfs subvolume create /mnt/microsd/Templates
btrfs subvolume create /mnt/microsd/Videos
btrfs subvolume create /mnt/microsd/sdcard
btrfs subvolume create /mnt/microsd/Pictures

to check if it's correct:

btrfs subvolume list /mnt/microsd/

now, you must copy all data to the new directorys:

cp -r -a -v /data/sdcard/ /mnt/microsd/sdcard
cp /home/nemo/Pictures/Jolla/* /mnt/microsd/Pictures/Jolla/
cp /home/nemo/Video/Jolla/* /mnt/microsd/Videos/Jolla/
cp /home/nemo/Videos/Jolla/* /mnt/microsd/Videos/
(if you already have any music or something to those old directory:
cp /home/nemo/Music/*
etc ....)

then, we can mount ;)
as you can see, the compress argument is here. btrfs is able to compress "on the fly", and, more, if the data is incompressible, it remain the same. afterward, btrfs as a flaw, it's "compress all the volume/subvolume or nothing" that why i mantioned it only time

mount -o subvol=sdcard,compress /dev/mmcblk1 /data/sdcard/
mount -o subvol=Videos /dev/mmcblk1 /home/nemo/Videos/
mount -o subvol=Desktop /dev/mmcblk1 /home/nemo/Desktop/
mount -o subvol=Documents /dev/mmcblk1 /home/nemo/Documents/
mount -o subvol=Downloads /dev/mmcblk1 /home/nemo/Downloads/
mount -o subvol=Music /dev/mmcblk1 /home/nemo/Music/
mount -o subvol=Pictures /dev/mmcblk1 /home/nemo/Pictures/
mount -o subvol=Public /dev/mmcblk1 /home/nemo/Public/
mount -o subvol=Templates /dev/mmcblk1 /home/nemo/Templates/

Voila.

Pardon my bad english ;)


EDIT1:
there were some mistake, the green come from below, wich is ok, the blue is the true good correction.

sorry again :o

Thoke 2014-01-25 18:16

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by bob_bipbip (Post 1408865)
ok, so someone here asked me how i have made all these subvolume ****, here is a exact copy of the pm i replied to:

[...]

mkfs.btrfs -f /dev/mmcblk1

yeah right, WITHOUT any p1. direct from the block ;)
(the "-f" is not mandatory, it useful when you have problem because the device don't want to release it or something, whatever. try first without, if it works congrats, if you need it, use it)

[...]

btrfs subvolume create /mnt/microsd/Desktop
btrfs subvolume create /mnt/microsd/Documents
btrfs subvolume create /mnt/microsd/Downloads
btrfs subvolume create /mnt/microsd/Music
btrfs subvolume create /mnt/microsd/Public
btrfs subvolume create /mnt/microsd/Templates
btrfs subvolume create /mnt/microsd/Videos
btrfs subvolume create /mnt/microsd/sdcard
btrfs subvolume create /mnt/microsd/Pictures

[...]

cp -r -a -v /home/nemo/sdcard/ /mnt/microsd/sdcard
cp /home/nemo/Pictures/Jolla/* /mnt/microsd/Pictures/Jolla/
cp /home/nemo/Video/Jolla/* /mnt/microsd/Videos/Jolla/
cp /home/nemo/Videos/Jolla/* /mnt/microsd/Videos/
(if you already have any music or something to those old directory:
cp /home/nemo/Music/*
etc ....)

then, we can mount ;)
as you can see, the compress argument is here. btrfs is able to compress "on the fly", and, more, if the data is incompressible, it remain the same. afterward, btrfs as a flaw, it's "compress all the volume/subvolume or nothing" that why i mantioned it only time

mount -o subvol=sdcard,compress /dev/mmcblk1 /home/nemo/sdcard/ [?]
mount -o subvol=Videos /dev/mmcblk1 /home/nemo/Videos/
mount -o subvol=Desktop /dev/mmcblk1 /home/nemo/Desktop/
mount -o subvol=Documents /dev/mmcblk1 /home/nemo/Documents/
mount -o subvol=Downloads /dev/mmcblk1 /home/nemo/Downloads/
mount -o subvol=Music /dev/mmcblk1 /home/nemo/Music/
mount -o subvol=Pictures /dev/mmcblk1 /home/nemo/Pictures/
mount -o subvol=Pictures /dev/Public /home/nemo/Public/
mount -o subvol=Public /dev/mmcblk1 /home/nemo/Public/
mount -o subvol=Templates /dev/mmcblk1 /home/nemo/Templates/

I assume the green text is what you actually meant, red too but I'm not so sure of it. Could you confirm? (I'm not that good with commandline stuff yet, so I try not to do stuff I don't understand)

Also, if my Jolla will now automount my btrfs sdcard after these mods, a thosand thanks goes to you :D

bob_bipbip 2014-01-25 18:31

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
holy mother of fkng copy pasta :eek::eek::eek::eek:

i HAVE TO CORRECT IT NOW !!!!


sorry :(

rannari 2014-01-25 18:46

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Too complicated changes to script for my taste. Odd thing is that the basic changes to mount-sd.sh script, work for some and others not. I have no problems with mounting, but I still need symlinks, and yes I have tested and tried several times.

I don't use android stuff, which makes my life easier ;-)

Thoke 2014-01-25 19:01

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
@bob_bipbip, at least in my Jolla there'a no sdcard folder in /data/ (checked with ls -a), should I make one then, or what is it's importance in this?

bob_bipbip 2014-01-25 19:34

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Thoke (Post 1408907)
@bob_bipbip, at least in my Jolla there'a no sdcard folder in /data/ (checked with ls -a), should I make one then, or what is it's importance in this?

strange, but i think you don't have android virtual machine installed, so that's why you don't have this folder ;)

Thoke 2014-01-25 19:57

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Ohh... yes, that's true :D so no subvolumes there then :rolleyes:

Bubbless 2014-01-25 20:19

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by bob_bipbip (Post 1408865)
mkfs.btrfs -f /dev/mmcblk1

Error: unable to open /deb/mmcblk1: Device or resource busy :confused:

Thoke 2014-01-25 20:36

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Bubbless (Post 1408924)
Error: unable to open /deb/mmcblk1: Device or resource busy :confused:

umount /dev/mmcblk1

Now it should be unmounted. Make sure none of your applications use data from the sdcard before unmounting it. Note that all your data will be wiped from the sdcard after formatting.

bob_bipbip 2014-01-26 01:45

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Thoke (Post 1408920)
Ohh... yes, that's true :D so no subvolumes there then :rolleyes:

Just remove all lines about /data/sdcard :cool:

javispedro 2014-01-26 02:10

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by Thoke (Post 1408899)
Also, if my Jolla will now automount my btrfs sdcard after these mods, a thosand thanks goes to you :D

The only modification required to automount a btrfs formatted sdcard is the one commented in the bug report.

This thread is about over-complicating things to gain features such as the one mentioned in the thread title.

Thoke 2014-01-26 10:20

Re: [HowTo][WIP] use real sdcard as home-partition and/or for android data
 
Quote:

Originally Posted by javispedro (Post 1408971)
The only modification required to automount a btrfs formatted sdcard is the one commented in the bug report.

This thread is about over-complicating things to gain features such as the one mentioned in the thread title.

Yeah, I understand. I've never edited a script before before now I've been very cautious about doing any changes to scripts. I have vim on device but no instructions anywhere inside the application. So I chose the way of doing things I at least have some knowledge of.

Now I just learned how to open mount-sd.sh in vim and edit it.

So it should look like this:

Code:

mount $SDCARD $MNT -o uid=$DEF_UID,gid=$DEF_GID || mount -o relatime $SDCARD $MY_MOUNTPOINT
no line-breaks anywhere.

I'm using this as a guide, seems to be relevant and work.

PS: If you want to label your microsd when formatting it use the command
Code:

mkfs.btrfs -L insertlabel /dev/mmcblk1

Don't know if the drive label can be altered afterwards.


All times are GMT. The time now is 10:04.

vBulletin® Version 3.8.8