0

I am using Debian Buster, 10.7, and I am relatively new to udev/udisks2/systemd and have been making a effort to get to know them better and have learned quite a lot, though I cannot seem to figure out how to both prevent udisks2 from auto mounting a particular volume (an SD card) as /media/$USER/foo, as well as mount it instead as /data.

Here is what I have tried so far:

$ grep /data /etc/fstab
UUID="3537-3761"      /data     exfat-fuse    defaults,nofail,x-systemd.device-timeout=2ms  0       0

$ cat /etc/systemd/system/data-sdcard-mount.service   
[Unit]
Description=Mount Data SD Card on /data
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/mount /data
ExecStop=/bin/umount /data

$ cat /etc/udev/rules.d/99-data-sdcard.rules
ACTION=="add", \
    SUBSYSTEM=="block", \
    ENV{DEVTYPE}=="partition", \
    ENV{ID_DRIVE_MEDIA_FLASH_SD}=="1", \
    ENV{ID_NAME}=="SF256", \
    ENV{ID_SERIAL}=="0x3db0a775", \
    RUN+="/bin/systemctl start data-sdcard-mount", \
    ENV{UDISKS_IGNORE}="1", \
    OPTIONS="last_rule"

ACTION=="remove", \
    SUBSYSTEM=="block", \
    ENV{DEVTYPE}=="partition", \
    ENV{ID_DRIVE_MEDIA_FLASH_SD}=="1", \
    ENV{ID_NAME}=="SF256", \
    ENV{ID_SERIAL}=="0x3db0a775", \
    RUN+="/bin/systemctl stop data-sdcard-mount", \
    OPTIONS="last_rule"

Here is what I see syslog in another terminal window, when the card is inserted (though after logging in to MATE):

Feb  4 13:25:51 localhost kernel: [508706.027711] mmc3: new high speed SDXC card at address aaaa
Feb  4 13:25:51 localhost kernel: [508706.044472] mmcblk3: mmc3:aaaa SF256 238 GiB 
Feb  4 13:25:51 localhost kernel: [508706.058372]  mmcblk3: p1
Feb  4 13:25:51 localhost systemd[1]: Starting Mount Data SD Card on /data...
Feb  4 13:25:51 localhost mount[1734]: FUSE exfat 1.3.0
Feb  4 13:25:51 localhost mount[1734]: WARN: volume was not unmounted cleanly.
Feb  4 13:25:51 localhost mount.exfat-fuse: volume was not unmounted cleanly
Feb  4 13:25:51 localhost systemd[1]: data.mount: Unit is bound to inactive unit dev-disk-by\x2duuid-3537\x2d3761.device. Stopping, too.
Feb  4 13:25:51 localhost systemd[1]: Started Mount Data SD Card on /data.
Feb  4 13:25:51 localhost systemd[1]: Unmounting /data...
Feb  4 13:25:51 localhost systemd[14720]: data.mount: Succeeded.
Feb  4 13:25:51 localhost systemd[2920]: data.mount: Succeeded.
Feb  4 13:25:51 localhost systemd[1]: data.mount: Succeeded.
Feb  4 13:25:51 localhost systemd[1]: Unmounted /data.
Feb  4 13:25:52 localhost systemd[1]: Started Clean the /media/vanfan/Data mount point.
Feb  4 13:25:52 localhost udisksd[2010]: Mounted /dev/mmcblk3p1 at /media/vanfan/Data on behalf of uid 1000

It looks like it mounts to /data but gets unmounted for some reason.

Here is the out of udisksctl info -b /dev/mmcblk3p1:

$ udisksctl info -b /dev/mmcblk3p1
/org/freedesktop/UDisks2/block_devices/mmcblk3p1:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/mmcblk3p1
    DeviceNumber:               45825
    Drive:                      '/org/freedesktop/UDisks2/drives/SF256_0x3db0a775'
    HintAuto:                   true
    HintIconName:               
    HintIgnore:                 false
    HintName:                   
    HintPartitionable:          true
    HintSymbolicIconName:       
    HintSystem:                 false
    Id:                         by-uuid-3537-3761
    IdLabel:                    Data
    IdType:                     exfat
    IdUUID:                     3537-3761
    IdUsage:                    filesystem
    IdVersion:                  1.0
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/mmcblk3p1
    ReadOnly:                   false
    Size:                       255835766784
    Symlinks:                   /dev/disk/by-id/mmc-SF256_0x3db0a775-part1
                                /dev/disk/by-label/Data
                                /dev/disk/by-path/platform-4809c000.mmc-part1
                                /dev/disk/by-uuid/3537-3761
    UserspaceMountOptions:      uhelper=udisks2
  org.freedesktop.UDisks2.Filesystem:
    MountPoints:        /media/vanfan/Data
    Size:               0
  org.freedesktop.UDisks2.Partition:
    Flags:              0
    IsContained:        false
    IsContainer:        false
    Name:               
    Number:             1
    Offset:             33554432
    Size:               255835766784
    Table:              '/org/freedesktop/UDisks2/block_devices/mmcblk3'
    Type:               0x07
    UUID: 

Might I be missing something? Is there a better approach to this? I have tried to research this topic before and while trying to get this to work, and I really do't understand why this isn't working.

3
  • If you have an entry in fstab (which you have), UDisks should honor it and mount the device to /data, if it isn't doing that, it's a bug in UDisks and I recommend to report it. Are yiu sure the UUID in fstab is correct? Can you add output of udisksctl info -b /dev/mmcblk3p1 to your question? Commented Feb 4, 2021 at 20:07
  • @VojtechTrefny, thanks, I have added the output of udisksctl info -b /dev/mmcblk3p1 to my question as requested.
    – Vanfan64
    Commented Feb 4, 2021 at 21:25
  • @VojtechTrefny I have made another update. Right after posting that output, I was looking at the post and noticed a typo I had made in the udev rule RUN+= where I had stop instead of start, and after that it mounts to /media/vanfan/Data instead of /data so something is still not right.
    – Vanfan64
    Commented Feb 4, 2021 at 21:34

1 Answer 1

1

Looks like I found why is UDisks ignoring your fstab entry -- UDisks can't parse your fstab:

UUID="3537-3761"      /data     exfat-fuse    defaults,nofail,x-systemd.device-timeout=2ms  0       0

The quotation marks in the UUID="3537-3761" are causing the problem. Quick test on my system:

With quotation marks:

$ udisksctl mount -b /dev/sdb1
Mounted /dev/sdb1 at /run/media/vojta/E2FC-EAE3

Without:

$ udisksctl mount -b /dev/sdb1
Mounted /dev/sdb1 at /mnt/test

I'm not sure if this is supposed to be working, all examples (including man fstab) say to specify entries with UUID as UUID=<uuid> so without the quotation marks, but mount does work so UDisks probably should too so you might consider reporting this as a UDisks bug.

3
  • Thanks, after removing the quotes from the UUID in fstab and reinserting, it no longer mounts to /media/vanfan/..., it doesn't mount at all. I can do sudo udisksctl mount -b /dev/mmcblk3p1 and then it mouns to /data. Any idea why it isn't mounting automatically? I have also tried adding auto to the fstab options defaults,auto,nofail,x-systemd.device-timeout=2ms.
    – Vanfan64
    Commented Feb 5, 2021 at 8:18
  • I forgot to mention that I had disabled the /etc/udev/rules.d/99-data-sdcard.rules udev rule (I commented everything in it and renamed it to /etc/udev/rules.d/99-data-sdcard.rules.disabled)
    – Vanfan64
    Commented Feb 5, 2021 at 8:40
  • Problem with UDisks and automounting is that UDisks actually doesn't do the "automount" part, it only sets the HintAuto property (which in your case is correctly set to true) and the "upper" layer (GVFs in GNOME) decides if it wants to mount the device immediately or wait for user to click the icon. Commented Feb 5, 2021 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .