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

Howto automount according to SD label instead of UUID ? [answered]

asked 2016-05-07 16:05:54 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2016-10-26 15:22:08 +0300

jiit gravatar image

Hi,

On my Ubuntu, the default is to automount the SD card according to it's UUID.

But if I set up a label on a the first partition of a SD card, it automounts it according to it's label.

I have labeled my SD card with a FAT32 label, but SailFish 2.x still mounts it according to it's UUID.

How can I change this behavior ?

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by SebM
close date 2016-05-08 16:11:19.918080

Comments

As far as I can tell, this is default Linux behaviour. Try to find something about how this is done with Ubuntu. Chances are that will work with Sailfish.

Xmasjos ( 2016-05-08 01:41:21 +0300 )edit

@Xmasjos: Nope. It's not a "default Linux behaviour". There are lots of different automounting scripts out there, each with its own specificities. And Sailfish uses a different one that hasn't much in common with Ubuntu (it's not like Palm/HP's WebOS which was inspired by Ubuntu up to some point)

DrYak ( 2016-05-08 15:36:55 +0300 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2016-05-08 15:50:57 +0300

DrYak gravatar image

updated 2016-05-08 16:11:02 +0300

In Sailfish OS, the automounting is handled by the script /usr/sbin/mount-sd.sh from package sd-utils. This is the thing you'd want to edit to add newer behaviours (we've already hacked it a bit with @V10lator - like adding support for swap partitions, NTFS/exFAT/etc. - have a look on our githubs, his openrepo, etc.)

The general flow of it is:

It's this last part that you want to change. You should add more logic to check whether $LABEL is set, and then name the mounting point based either on $LABEL or $UUID depending on availability. (Don't forget to also change the unmounting logic accordingly).

An alternate solution would be to leave the current logic as-is and add code to create symlinks named with $LABEL and pointing to $UUID. (If I manage to find some free time, I would add this one).

In theory, it's better to use UUIDs rather than labels, because the former are supposed to be unique to each media (in theory. in practice FAT32 uses rather short 32bits ones, so collisions / birthday paradoxes are a likelyhood) whereas labels are user defined, and it can get really confusing if some end-user decide to call all their memory cards "My data" (or in case of constructors who use the product name for every single item).

In practice, as the Jolla phone has only 1 single SD-card slot, and as very few people use external readers (as the OTG port isn't powered), you won't find that many situations where having two partitions with the same name is problematic.

edit flag offensive delete publish link more

Comments

@DrYak Ok. If the Jolla and current SailFish based phones (and other phones as well) have only one SD-card slot, why not mount the SD card in /media/sdcard instead of /media/sdcard/$UUID ? I would like to create an feature request on your github but I couldn't because the "Issue" button is not available.

SebM ( 2016-05-08 16:35:04 +0300 )edit

@SebM: you still need a way to distinguish between the card, if you want to make a Card-specific symlink.

e.g.: I use ModRana as mapping GPS application, and I store all the tile cache databases on my SD card. (Both to put less stress on the eMMC of the smartphone, and to have way more free space). But I have the symlink from ModRana's directory to /media/sdcard/${UUID} so it only works with my big huge BTRFS-formatted SD card. ModRana won't start writing a new cache database by accident on whatever SD card I happen to have plugged in at that time (e.g.: my photocamera's SD card) because it will be mounted as a different UUID.

A possible addition would be to go the "LABEL as symlink"-route I mention and also add symlink describing which device (i.e.: reader) is being mounted, so can also address the mountpoint as "whatever card is currently in the internal SD card reader (aka in mmcblk1p1)".

NOTE: that's the way Android does it in my limited experience, the various cards can be addressed as sdcard0, sdcard1, usbotg, etc.

DrYak ( 2016-05-08 19:51:56 +0300 )edit
3

@SebM I implemented mounting by /media/sdcard/$LABEL with fallback for /media/sdcard/$UUID at bleeding edge sd-utilsv0.3.0.1-0.

The reason it isn't mounted to /media/sdcard (and never will be) is SailfishOS doesn't only look at current phones but portability.

V10lator ( 2016-05-08 19:53:18 +0300 )edit

... and don't forget, you may have more than one partition on a SD card.

jolladiho ( 2016-05-09 19:35:34 +0300 )edit

Question tools

Follow
2 followers

Stats

Asked: 2016-05-07 16:05:54 +0300

Seen: 1,097 times

Last updated: May 08 '16