gpt4 book ai didi

ubuntu - 如何使用 udev 规则自动挂载 USB block 设备?

转载 作者:行者123 更新时间:2023-12-04 18:49:46 30 4
gpt4 key购买 nike

每当 USB 驱动器连接到计算机时,我都想执行“mount -a”。我在文件'/etc/udev/rules.d/85-my_rule.rules'中创建了一个简单的规则:

SUBSYSTEM=="block", RUN+="/bin/mount -a"

如果我手动调用“sudo mount -a”,一切正常。使用“dmesg”我还看到了我的驱动器:
[503534.272219] usb 4-2: new SuperSpeed Gen 1 USB device number 10 using xhci_hcd
[503534.297237] usb 4-2: New USB device found, idVendor=152d, idProduct=0539, bcdDevice= 1.00
[503534.297244] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[503534.297248] usb 4-2: Product: USB to ATA/ATAPI Bridge
[503534.297252] usb 4-2: Manufacturer: JMicron
[503534.297255] usb 4-2: SerialNumber: A787E1EFFFFF
[503534.301848] usb-storage 4-2:1.0: USB Mass Storage device detected
[503534.303131] usb-storage 4-2:1.0: Quirks match for vid 152d pid 0539: 4000000
[503534.303196] scsi host8: usb-storage 4-2:1.0
[503535.336866] scsi 8:0:0:0: Direct-Access Sharkoon H/W RAID5 PQ: 0 ANSI: 5
[503535.337941] sd 8:0:0:0: Attached scsi generic sg2 type 0
[503535.338353] sd 8:0:0:0: [sde] Very big device. Trying to use READ CAPACITY(16).
[503535.338589] sd 8:0:0:0: [sde] 62511906816 512-byte logical blocks: (32.0 TB/29.1 TiB)
[503535.339571] sd 8:0:0:0: [sde] Write Protect is off
[503535.339577] sd 8:0:0:0: [sde] Mode Sense: 28 00 00 00
[503535.340649] sd 8:0:0:0: [sde] No Caching mode page found
[503535.340664] sd 8:0:0:0: [sde] Assuming drive cache: write through
[503535.481112] sde: sde1
[503535.484634] sd 8:0:0:0: [sde] Attached SCSI disk

block 设备也在那里,但似乎没有执行规则。我应该怎么办?我正在使用 Ubuntu Server 20.04 LTS。

最佳答案

也许您需要添加 ACTION遵守规则,例如:

 SUBSYSTEM=="block", ACTION=="add", RUN+="/bin/mount -a" 

关于ubuntu - 如何使用 udev 规则自动挂载 USB block 设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62104523/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com