在 Debian Buster 下使用特定卷的自定义固定安装点覆盖 udisks2 /media/$USER/mount

在 Debian Buster 下使用特定卷的自定义固定安装点覆盖 udisks2 /media/$USER/mount

我在用Debian 巴斯特,10.7,我对 udev/udisks2/systemd 相对较新,并且一直在努力更好地了解它们并且学到了很多东西,尽管我似乎无法弄清楚如何阻止 udisks2 自动安装特定的卷(SD 卡)为/media/$USER/foo,以及将其挂载为/data

这是我到目前为止所尝试过的:

$ 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"

以下是插入卡时我在另一个终端窗口中看到的系统日志(尽管是在登录 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

它看起来像是挂载到 /data 但由于某种原因被卸载。

这是出来的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: 

我可能错过了什么吗?有更好的方法吗?我之前曾尝试研究这个主题,并试图让它发挥作用,但我真的不明白为什么这不起作用。

答案1

看来我找到了为什么 UDisks 忽略您的fstab条目 - UDisks 无法解析您的fstab

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

中的引号UUID="3537-3761"引起了问题。在我的系统上快速测试:

带引号:

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

没有:

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

我不确定这是否应该有效,所有示例(包括man fstab)都说用 UUID 指定条目,UUID=<uuid>不带引号,但mount确实有效,因此 UDisks 可能也应该如此,因此您可能会考虑将其报告为 UDisks bug。

相关内容