Reply
Thread Tools
Posts: 594 | Thanked: 1,094 times | Joined on Aug 2012 @ Rhine
#61
rsync works out of the box
 

The Following User Says Thank You to Leinad For This Useful Post:
Posts: 16 | Thanked: 2 times | Joined on Jun 2013 @ Germany Oberschwaben
#62
Thanks a lot, looks like everything works fine.
Time for testing.....
 

The Following User Says Thank You to RR_aus_H For This Useful Post:
Posts: 284 | Thanked: 661 times | Joined on Aug 2013 @ Finland
#63
After tinkering with my btrfs-microsd and researching about btrfs in general, here's how I decided to handle my btrfs-microsd.

My guide to using btrfs-formatted microsd on Jolla

NOTE: You do this with your own discretion! Something can always go wrong and it may not work for you even though it works for me.

(1.) First you'll want to format your microsd inside Jolla

Code:
mkfs.btrfs -f -L Insertlabel /dev/mmcblk1
At this point we have two choices, depending on your needs.

(2.) For basic functions, just use vi to edit one line of the script in mount-sd.sh (located in /usr/sbin/) to be like this:

Code:
vi /usr/sbin/mount-sd.sh
Code:
mount $SDCARD $MNT -o uid=$DEF_UID,gid=$DEF_GID || mount -o relatime $SDCARD $MNT
More info here
With this you'll achieve the basic software support for your sdcard (Sailfish applications find your music/pictures/videos/etc, pay attention to file permissions if they won't). Next move to step 10 if you chose this way.

---

Now to the more advanced 'command-lining' to achieve similar results as per the title & OP of this thread.

First do step #1, omit step #2.

(3.) Mount the default 'root' volume of the btrfs.

Code:
mount -o subvolid=0 /dev/mmcblk1 /media/sdcard
(4.) Then let's move to the mounted directory for easy subvolume creation.
Code:
cd /media/sdcard
ls -la
Now you'll see the device ID of your microsd and can continue:
Code:
cd /media/sdcard/your-microsd-id

(5.) Now create subvolumes 'Jolla' and 'Other':
Code:
btrfs subvolume create Jolla
btrfs subvolume create Other
After that we'll create subvolumes inside the 'Jolla' subvolume:
Code:
cd /media/sdcard/you-microsd-id/Jolla
btrfs subvolume create Desktop
btrfs subvolume create Documents
btrfs subvolume create Downloads
btrfs subvolume create Music
btrfs subvolume create Pictures
btrfs subvolume create Public
btrfs subvolume create Templates
btrfs subvolume create Videos
btrfs subvolume create android
(6.) Then we'll need to modify file permissions of the subvolumes to be the same as their counterparts in /home/nemo to avoid permission conflicts (I had to do factory reset once when these were not right):
PS: You might want to check who owns the /data/sdcard folder in your Jolla and chown that btrfs subvolume accordingly, I can't check it as I don't have one (no Android runtime installed) EDIT: chmod 777 is needed.

Code:
chown -R nemo:nemo /media/sdcard/you-microsd-id/Jolla
chmod -R 775 /media/sdcard/you-microsd-id/Jolla
chmod -R 777 /media/sdcard/you-microsd-id/Jolla/android

(7.) Next we need to find the subvolume ID of the 'Other' subvolume and change it to be the default mounting-point of the btrfs-volume:

Code:
btrfs subvolume list /media/sdcard/you-microsd-id
For example I found the ID was 269 in my sdcard, so the command was like this in my case:
Code:
btrfs subvolume set-default 269 /media/sdcard/you-microsd-id
(8.) Next is the copying of files from /home/nemo to their counterpart-subvolumes:

Code:
cp -r -a -v /home/nemo/Documents/* /media/sdcard/you-microsd-id/Jolla/Documents

cp -r -a -v /home/nemo/Downloads/* /media/sdcard/you-microsd-id/Jolla/Downloads

cp -r -a -v /home/nemo/Music/* /media/sdcard/you-microsd-id/Jolla/Music

cp -r -a -v /home/nemo/Pictures/* /media/sdcard/you-microsd-id/Jolla/Pictures

cp -r -a -v /home/nemo/Public/* /media/sdcard/you-microsd-id/Jolla/Public

cp -r -a -v /home/nemo/Templates/* /media/sdcard/you-microsd-id/Jolla/Templates

cp -r -a -v /home/nemo/Videos/* /media/sdcard/you-microsd-id/Jolla/Videos

cp -r -a -v /data/sdcard/* /media/sdcard/you-microsd-id/Jolla/android
(9.) Now we get to the final stage, getting the subvolumes to mount to /home/nemo:
(unmount your sdcard first)
Code:
umount /dev/mmcblk1
Edit the mount-sd.sh to be like this with vi:

Code:
vi /usr/sbin/mount-sd.sh
Code:
#!/bin/bash

SDCARD=/mnt/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 -o uid=$DEF_UID,gid=$DEF_GID || mount -o relatime $SDCARD $MNT 
        mount -o subvol=Jolla/Desktop /dev/mmcblk1 /home/nemo/Desktop/
        mount -o subvol=Jolla/Documents /dev/mmcblk1 /home/nemo/Documents/
        mount -o subvol=Jolla/Downloads /dev/mmcblk1 /home/nemo/Downloads/
        mount -o subvol=Jolla/Music /dev/mmcblk1 /home/nemo/Music/
        mount -o subvol=Jolla/Pictures /dev/mmcblk1 /home/nemo/Pictures/
        mount -o subvol=Jolla/Public /dev/mmcblk1 /home/nemo/Public/
        mount -o subvol=Jolla/Templates /dev/mmcblk1 /home/nemo/Templates/
        mount -o subvol=Jolla/Videos /dev/mmcblk1 /home/nemo/Videos/
        mount -o subvol=Jolla/android /dev/mmcblk1 /data/sdcard/
else
        umount $SDCARD

        if [ $? = 0 ]; then
                rm -f $SDCARD
        else
                umount -l $MNT
                rm -f $SDCARD
        fi
fi
Final step. (10.) Reboot your phone.

If you did the advanced command-line editing, you should now be able to copy everything to your sdcard with MTP-mode from your computer, and Sailfish applications should instantly find any music/pictures/videos/etc. from sdcard.

Pros of the approach:
+automount-behaviour
+Easy handling of files via MTP
+Sailfish applications are able to find the contents of your card
+Your phone's internal memory won't get cluttered with files
+'Other' subvolume being mounted by default (more info below)

Cons of the approach:
-Complicated approach
-'Other' subvolume being mounted by default (more info below)

What do these modifications do?

You actually create two 'main' subvolumes of btrs in your microsd. Coupled with the changes to btrfs default mounting point of your microsd and changes to the mount-sd.sh script, This means your Jolla actually mounts two subvolumes of btrfs, 'Other' to /run/user/100000/media/sdcard/ and subvolumes within 'Jolla' subvolume to /home/nemo. What this means is that if you ever happen to mount your microsd to another device, it always mounts the 'Other' subvolume, contents of the 'Jolla' subvolume will be invisible to that device unless you mount the btrfs root subvolume of your microsd like this:

Code:
umount /your/microsd/
mount -o subvolid=0 /your/microsd /your/mounting/point
All subvolumes and their contents are visible when the root subvolume is mounted. Note that because Jolla mounts both the 'Other' and 'Jolla' subvolumes, you should avoid keeping duplicate files in them as for example Jolla's default music player searches the 'Other' subvolume as well as Music sub-subvolume (except if you modify the permissions of 'Other' subvolume, which I haven't tried, but it will undoubtedly stop that behaviour if you so wish. It's up to you.)

If you don't like this dual-subvolume setup and prefer to keep it all visible and bundled in the same mounting point, please refer to my links to J4ZZ's and bob_bipbip's posts below (but I'd still change the file permissions of the subvolumes and their mounting folders to be identical with each other before mounting as this at least forced me to do a factory reset when the copying of files via MTP-mode jammed.

bob_bipbip and J4ZZ have also good guides and offer different options when it comes to this topic & btrfs (& I learned a lot from their posts )
Some references:

FUNTOO's great article about btrfs (still valid)
A good guide by Oracle
Guide to basic vim commands

Also, if you have a suggestion to make this guide better and/or more secure, go ahead and make a suggestion.

Last edited by Thoke; 2014-03-19 at 19:01.
 

The Following 2 Users Say Thank You to Thoke For This Useful Post:
Posts: 284 | Thanked: 661 times | Joined on Aug 2013 @ Finland
#64
Bumped because there are possible problems with my setup. If anyone uses it and experiences booting problems, remove your sdcard while your phone is off and remove all subvolume mount-commands from your mount-sd.sh script. Change your default btrfs mounting point to 0 (with btrfs subvolume set-default) and you can use your microsd like normal microsds.

By the way, I noted strange behaviour with my music files in my microsd with my setup: when Jolla's default media player played any track, it changed it's owner group to 'privileged'. This happens with file permissions set to 775 and owners set to nemo:nemo (so they are identical with content in home:nemo).

Last edited by Thoke; 2014-02-12 at 20:24.
 
Posts: 594 | Thanked: 1,094 times | Joined on Aug 2012 @ Rhine
#65
interesting side-effect, i just noticed:

with my configuration, i have full mass storage access to the sdcard, even on windows (pictures attached).

edit: for the home-part, not for the android-part
Attached Images
  

Last edited by Leinad; 2014-02-13 at 10:32.
 
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#66
Another comment is that if you are doing this just to access the SD card via MTP, then you should know that some future update will allow the builtin MTP server to do this out-of-box.
 

The Following User Says Thank You to javispedro For This Useful Post:
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#67
Missed this I think...

Originally Posted by Leinad View Post
Or more concrete:
is it right, that mount-sd.sh is called twice?
why is the default mountpoint ready so late, in comparison to another mountpoint?
are there important reasons to use only the default mountpoint?
i know, a lot of questions. maybe you have some answers
I don't think that mount-sd.sh is called twice (other than add/remove). If you are experiencing this I think you need to give more information.

The "default mountpoint" /run/user/$USER/.. happens to be on $XDG_RUNTIME_DIR, which "officially" does not exist (you should always access it through $XDG_RUNTIME_DIR). In practice, it is often created after $USER has logged in (specially on kitchensinkd/systemd systems). That is quite late on the boot process.

Currently, the only reason to use the default mountpoint is because programs/"apps" are hardcoding this (e.g. the filebrowser on Harbour).

I personally change it to /media/sdcard and I believe future versions of Sailfish will do that too.
 

The Following User Says Thank You to javispedro For This Useful Post:
Posts: 284 | Thanked: 661 times | Joined on Aug 2013 @ Finland
#68
Reposted my guide as it turned out my problems are related to this topic.
 
Posts: 16 | Thanked: 2 times | Joined on Jun 2013 @ Germany Oberschwaben
#69
I have done all your instructions and transferred my /home and my /android directories to a 64GB SD-Card. It works well with no problems since about 1 week.
Now I want to delete a few big files and directories on the original memory of the Jollaphone. Where do I find them. I use the ssh-connection and mc.
Thankfull for a hint, because I´m not very familiar with these lot of mountpoints and symbolic links ;-)
 
Posts: 33 | Thanked: 25 times | Joined on Sep 2011 @ grenoble
#70
Originally Posted by Leinad View Post
@bob_bipbip: what's the advantage of using subvolumes instead of bind mounts? did you also try to mount the whole home/nemo-folder? did you have any problems with it?
sorry for the late answer
1) because binds are useless when you have subvolumes
2) for several reason:
- "dot folder", i don't want to have them on my sd, it can cause troubles, these are system profiles files, your phone needs them, always. so umount your /home folder and you will running into troubles.
-speed, i don't know my sd card transfer rate compare to my system internal memory. but it's qui obvious that internal memory is faster. so keeping only files that need slow transfer rate is better
-the main goal is to be able to use sdcard like the good ol' floppy

 

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


 
Forum Jump


All times are GMT. The time now is 12:30.