TransWikia.com

Overriding udisks2 /media/$USER/mount with custom fixed mount point for specific volume, under Debian Buster

Unix & Linux Asked by Vanfan64 on February 16, 2021

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-byx2duuid-3537x2d3761.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.

One Answer

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.

Answered by Vojtech Trefny on February 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP