使用 udev 自动挂载外部硬盘

使用 udev 自动挂载外部硬盘

我刚刚在我的 Linux 机器上安装了 Plex Media Server,对这个服务器的想法很满意。我的问题是 Plex 无法发现我外部硬盘上的任何文件。有问题的驱动器是 Western Digital My Passport (500GB),格式化为 NTFS,上面已经有大约 200+GB 的电影。

在搜索 Plex 论坛后,我发现我没有正确的文件权限,无法让 Plex 服务器访问驱动器。在寻找答案的过程中,我已经了解到 udev 规则是我的最佳选择(使用 fstab 是不可能的,毕竟驱动器是可移动的。:) )。我甚至已经写好了大部分规则;它只是没有自动挂载(例如,我插入驱动器,它会挂载到正常的 Ubuntu 挂载点 /media/$USERNAME/My Passport/)。:(

以下是我目前所制定的规则:

/etc/udev/rules.d/71-my-passport.rules

KERNEL=="sd?[0-9]", ATTRS{manufacturer}=="Western Digital", ATTRS{product}=="My Passport 0748", ACTION=="add", RUN+="mount -o dmask=007,fmask=117,gid=1001,uid=1000 /dev/%k /media/My Passport/"

其他随机内容:

/dev/sda1: UUID="d3ebc281-e885-4770-9ef9-f69651f54a12" TYPE="ext4" 
/dev/sda5: UUID="3569aee9-c16a-49ad-ba03-199180c59f60" TYPE="swap" 
/dev/sdb1: LABEL="My Passport" UUID="948251618251493E" TYPE="ntfs"

udevadm 信息 -a -n /dev/sdb1

Udevadm info starts with the device specified by the devpath and then

遍历父设备链。它针对找到的每个设备打印所有可能的属性(udev 规则键格式)。要匹配的规则可以由设备的属性和单个父设备的属性组成。

looking at device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1':
KERNEL=="sdb1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{ro}=="0"
ATTR{size}=="976705536"
ATTR{stat}=="     389    30494    32584     3040        0        0        0        0        0     1180     3040"
ATTR{partition}=="1"
ATTR{start}=="2048"
ATTR{discard_alignment}=="0"
ATTR{alignment_offset}=="0"
ATTR{inflight}=="       0        0"

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb':
KERNELS=="sdb"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{ro}=="0"
ATTRS{size}=="976707584"
ATTRS{stat}=="     467    30494    33208     3084        0        0        0        0        0     1224     3084"
ATTRS{range}=="16"
ATTRS{discard_alignment}=="0"
ATTRS{events}==""
ATTRS{ext_range}=="256"
ATTRS{events_poll_msecs}=="-1"
ATTRS{alignment_offset}=="0"
ATTRS{inflight}=="       0        0"
ATTRS{removable}=="0"
ATTRS{capability}=="50"
ATTRS{events_async}==""

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0':
KERNELS=="14:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{rev}=="1019"
ATTRS{type}=="0"
ATTRS{scsi_level}=="7"
ATTRS{model}=="My Passport 0748"
ATTRS{state}=="running"
ATTRS{queue_type}=="none"
ATTRS{iodone_cnt}=="0x1fb"
ATTRS{iorequest_cnt}=="0x1fb"
ATTRS{timeout}=="30"
ATTRS{evt_media_change}=="0"
ATTRS{max_sectors}=="240"
ATTRS{ioerr_cnt}=="0x1"
ATTRS{queue_depth}=="1"
ATTRS{vendor}=="WD      "
ATTRS{device_blocked}=="0"
ATTRS{dh_state}=="detached"
ATTRS{iocounterbits}=="32"

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0':
KERNELS=="target14:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14':
KERNELS=="host14"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0':
KERNELS=="1-1.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="usb-storage"
ATTRS{bInterfaceClass}=="08"
ATTRS{bInterfaceSubClass}=="06"
ATTRS{bInterfaceProtocol}=="50"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="MSC Bulk-Only Transport"

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1':
KERNELS=="1-1.1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="1.1"
ATTRS{idVendor}=="1058"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="12"
ATTRS{configuration}=="USB Mass Storage"
ATTRS{bMaxPower}=="500mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="80"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="1019"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="575832314336324C38343535"
ATTRS{version}==" 2.10"
ATTRS{urbnum}=="1578"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Western Digital"
ATTRS{removable}=="removable"
ATTRS{idProduct}=="0748"
ATTRS{bDeviceClass}=="00"
ATTRS{product}=="My Passport 0748"

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devpath}=="1"
ATTRS{idVendor}=="8087"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="2"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="0mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="6"
ATTRS{bcdDevice}=="0000"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="310"
ATTRS{ltm_capable}=="no"
ATTRS{removable}=="fixed"
ATTRS{idProduct}=="0024"
ATTRS{bDeviceClass}=="09"

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="0"
ATTRS{idVendor}=="1d6b"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{authorized_default}=="1"
ATTRS{busnum}=="1"
ATTRS{devnum}=="1"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="0mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="3"
ATTRS{bcdDevice}=="0308"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="0000:00:1a.0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="53"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 3.8.0-30-generic ehci_hcd"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0002"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="EHCI Host Controller"

looking at parent device '/devices/pci0000:00/0000:00:1a.0':
KERNELS=="0000:00:1a.0"
SUBSYSTEMS=="pci"
DRIVERS=="ehci-pci"
ATTRS{irq}=="16"
ATTRS{subsystem_vendor}=="0x17aa"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x0c0320"
ATTRS{companion}==""
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{dma_mask_bits}=="32"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x1e2d"
ATTRS{uframe_periodic_max}=="100"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x3977"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""

udevadm 测试 $(udevadm 信息 -q 路径 -n /dev/sdb1) 2>&1

run_command: calling: test
adm_test: version 175
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

parse_file: reading '/lib/udev/rules.d/40-crda.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-gnupg.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-hplip.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-ia64.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-inputattach.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-libgphoto2-2.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-libsane.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-ppc.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-usb-media-players.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-usb_modeswitch.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-virtualbox-dkms.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-virtualbox-guest-dkms.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-virtualbox.rules' as rules file
parse_file: reading '/lib/udev/rules.d/42-qemu-usb.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-firmware.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-udev-default.rules' as rules file
parse_file: reading '/lib/udev/rules.d/55-dm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/56-hpmud_support.rules' as rules file
parse_file: reading '/lib/udev/rules.d/56-lvm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-btrfs.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-cdrom_id.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-pcmcia.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-alsa.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-input.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-serial.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-dm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-lvm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-tape.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-v4l.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-accelerometer.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-gnome-bluetooth-rfkill.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-xorg-xkb.rules' as rules file
parse_file: reading '/lib/udev/rules.d/66-xorg-synaptics-quirks.rules' as rules file
parse_file: reading '/lib/udev/rules.d/69-cd-sensors.rules' as rules file
add_rule: IMPORT found builtin 'usb_id', replacing /lib/udev/rules.d/69-cd-sensors.rules:85
parse_file: reading '/lib/udev/rules.d/69-libmtp.rules' as rules file
parse_file: reading '/lib/udev/rules.d/69-xorg-vmmouse.rules' as rules file
parse_file: reading '/lib/udev/rules.d/69-xserver-xorg-input-wacom.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-power-switch.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-printers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-uaccess.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-udev-acl.rules' as rules file
parse_file: reading '/etc/udev/rules.d/71-my-passport.rules' as rules file
parse_file: reading '/lib/udev/rules.d/71-seat.rules' as rules file
parse_file: reading '/lib/udev/rules.d/73-seat-late.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-cd-aliases-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-net-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-persistent-net-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-probe_mtd.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-tty-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-ericsson-mbm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-longcheer-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-nokia-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-platform-serial-whitelist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-qdl-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-simtech-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-usb-device-blacklist.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-x22x-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-mm-zte-port-types.rules' as rules file
parse_file: reading '/lib/udev/rules.d/77-nm-olpc-mesh.rules' as rules file
parse_file: reading '/lib/udev/rules.d/78-graphics-card.rules' as rules file
parse_file: reading '/lib/udev/rules.d/78-sound-card.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-btrfs-lvm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-drivers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-mm-candidate.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-udisks.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-udisks2.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-brltty.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-hdparm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-hplj10xx.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-keyboard-configuration.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-lvm2.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-regulatory.rules' as rules file
parse_file: reading '/lib/udev/rules.d/85-usbmuxd.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-alsa-restore.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-alsa-ucm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-libgpod.rules' as rules file
parse_file: reading '/lib/udev/rules.d/90-pulseaudio.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-cd-devices.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keyboard-force-release.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keymap.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-kpartx.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-udev-late.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-dell.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-fujitsu.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-gateway.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-ibm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-lenovo.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-battery-recall-toshiba.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-csr.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-hid.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-upower-wup.rules' as rules file
parse_file: reading '/lib/udev/rules.d/97-bluetooth-hid2hci.rules' as rules file
parse_file: reading '/lib/udev/rules.d/97-dmraid.rules' as rules file
parse_file: reading '/lib/udev/rules.d/99-steam-controller-perms.rules' as rules file
udev_rules_new: rules use 304140 bytes tokens (25345 * 12 bytes), 48779 bytes buffer
udev_rules_new: temporary index used 83960 bytes (4198 * 20 bytes)
udev_device_new_from_syspath: device 0x7f5a65af2b70 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1'
udev_device_new_from_syspath: device 0x7f5a65af58b0 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1'
udev_device_read_db: device 0x7f5a65af58b0 filled with db file data
udev_device_new_from_syspath: device 0x7f5a65af7de0 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb'
udev_device_new_from_syspath: device 0x7f5a65af8610 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0'
udev_device_new_from_syspath: device 0x7f5a65af8e30 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0'
udev_device_new_from_syspath: device 0x7f5a65af9640 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14'
udev_device_new_from_syspath: device 0x7f5a65af9e30 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0'
udev_device_new_from_syspath: device 0x7f5a65afa620 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1'
udev_device_new_from_syspath: device 0x7f5a65afae10 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1/1-1'
udev_device_new_from_syspath: device 0x7f5a65afb600 has devpath '/devices/pci0000:00/0000:00:1a.0/usb1'
udev_device_new_from_syspath: device 0x7f5a65afbde0 has devpath '/devices/pci0000:00/0000:00:1a.0'
udev_device_new_from_syspath: device 0x7f5a65afc590 has devpath '/devices/pci0000:00'
udev_rules_apply_to_event: GROUP 6 /lib/udev/rules.d/50-udev-default.rules:67
udev_device_read_db: device 0x7f5a65af7de0 filled with db file data
udev_rules_apply_to_event: LINK 'disk/by-id/usb-WD_My_Passport_0748_575832314336324C38343535-0:0-part1' /lib/udev/rules.d/60-persistent-storage.rules:46
udev_rules_apply_to_event: LINK 'disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' /lib/udev/rules.d/60-persistent-storage.rules:64
udev_rules_apply_to_event: IMPORT '/sbin/blkid -o udev -p /dev/sdb1' /lib/udev/rules.d/60-persistent-storage.rules:75
udev_event_spawn: starting '/sbin/blkid -o udev -p /dev/sdb1'
spawn_read: '/sbin/blkid -o udev -p /dev/sdb1'(err) 'error: /dev/sdb1: Permission denied'
spawn_wait: '/sbin/blkid -o udev -p /dev/sdb1' [28479] exit with return code 2
udev_rules_apply_to_event: RUN 'mount -o dmask=007,fmask=117,gid=1001,uid=1000 /dev/%k /media/My Passport/' /etc/udev/rules.d/71-my-passport.rules:1
udev_rules_apply_to_event: IMPORT 'udisks-part-id /dev/sdb1' /lib/udev/rules.d/80-udisks.rules:88
udev_event_spawn: starting 'udisks-part-id /dev/sdb1'
spawn_read: 'udisks-part-id /dev/sdb1'(err) 'using device_file=/dev/sdb syspath=/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb, offset=1048576 ao=0 and number=1 for /dev/sdb1'
spawn_read: 'udisks-part-id /dev/sdb1'(err) 'Error opening /dev/sdb: Permission denied'
spawn_wait: 'udisks-part-id /dev/sdb1' [28480] exit with return code 0
udev_rules_apply_to_event: RUN '/sbin/modprobe -qba dm-multipath' /lib/udev/rules.d/95-kpartx.rules:10
udev_event_execute_rules: no node name set, will use kernel supplied name 'sdb1'
udev_node_update_old_links: update old name, '/dev/disk/by-label/My\x20Passport' no longer belonging to '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1'
link_find_prioritized: found 'b8:17' claiming '/run/udev/links/disk\x2fby-label\x2fMy\x5cx20Passport'
link_update: no reference left, remove '/dev/disk/by-label/My\x20Passport'
udev_node_update_old_links: update old name, '/dev/disk/by-uuid/948251618251493E' no longer belonging to '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1'
link_find_prioritized: found 'b8:17' claiming '/run/udev/links/disk\x2fby-uuid\x2f948251618251493E'
link_update: no reference left, remove '/dev/disk/by-uuid/948251618251493E'
udev_node_add: creating device node '/dev/sdb1', devnum=8:17, mode=0660, uid=0, gid=6
udev_node_mknod: preserve file '/dev/sdb1', because it has correct dev_t
udev_node_mknod: preserve permissions /dev/sdb1, 060660, uid=0, gid=6
node_symlink: preserve already existing symlink '/dev/block/8:17' to '../sdb1'
link_find_prioritized: found 'b8:17' claiming '/run/udev/links/disk\x2fby-id\x2fusb-WD_My_Passport_0748_575832314336324C38343535-0:0-part1'
link_update: creating link '/dev/disk/by-id/usb-WD_My_Passport_0748_575832314336324C38343535-0:0-part1' to '/dev/sdb1'
node_symlink: preserve already existing symlink '/dev/disk/by-id/usb-WD_My_Passport_0748_575832314336324C38343535-0:0-part1' to '../../sdb1'
link_find_prioritized: found 'b8:17' claiming '/run/udev/links/disk\x2fby-path\x2fpci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1'
link_update: creating link '/dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' to '/dev/sdb1'
node_symlink: preserve already existing symlink '/dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1' to '../../sdb1'
udev_device_update_db: unable to create temporary db file '/run/udev/data/b8:17.tmp': Permission denied
ACTION=add
DEVLINKS=/dev/disk/by-id/usb-WD_My_Passport_0748_575832314336324C38343535-0:0-part1 /dev/disk/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0-part1
DEVNAME=/dev/sdb1
DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/host14/target14:0:0/14:0:0:0/block/sdb/sdb1
DEVTYPE=partition
ID_BUS=usb
ID_INSTANCE=0:0
ID_MODEL=My_Passport_0748
ID_MODEL_ENC=My\x20Passport\x200748
ID_MODEL_ID=0748
ID_PART_TABLE_TYPE=dos
ID_PATH=pci-0000:00:1a.0-usb-0:1.1:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_1a_0-usb-0_1_1_1_0-scsi-0_0_0_0
ID_REVISION=1019
ID_SERIAL=WD_My_Passport_0748_575832314336324C38343535-0:0
ID_SERIAL_SHORT=575832314336324C38343535
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=WD
ID_VENDOR_ENC=WD\x20\x20\x20\x20\x20\x20
ID_VENDOR_ID=1058
MAJOR=8
MINOR=17
SUBSYSTEM=block
UDEV_LOG=6
UDISKS_PRESENTATION_NOPOLICY=0
USEC_INITIALIZED=19772580387
run: 'mount -o dmask=007,fmask=117,gid=1001,uid=1000 /dev/sdb1 /media/My Passport/'
run: '/sbin/modprobe -qba dm-multipath'

答案1

也许您尝试安装驱动器的目录尚未创建 (/media/MY PASSAPORT);请尝试像这样更改您的 udev 规则:

..., RUN+="/bin/mkdir -p /media/My_Passport", RUN+="/bin/mount -o dmask=007,fmask=117,gid=1001,uid=1000 /dev/%k /media/My_Passport/"

如果文件夹已经存在,-p 参数不会给你一个错误;我把你的“mount”改成了“/bin/mount”(这是我在 udev 规则中得到的方式)我还改变了你想要挂载驱动器的目录的名称(没有空格;空格需要转义);像这样试试

答案2

这不是 udev 的工作。在 /etc/fstab 中添加一个条目,通过标签或 uuid 而不是设备来标识驱动器,并使用 nofail 选项来防止系统在启动时没有驱动器时发出抱怨,并且驱动器会在连接时自动挂载。

相关内容