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...


All times are GMT. The time now is 14:09.

vBulletin® Version 3.8.8