我正在使用udev规则在我的Raspberry Pi上自动挂载USB闪存驱动器。几个月前我找到this solution并且我工作得非常好,直到我开始使用 Raspbian Stretch lite 。
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="\$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/usbstick", RUN+="/bin/mount -o \$env{mount_options} /dev/%k /media/usbstick"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/usbstick", RUN+="/bin/rmdir /media/usbstick"
# Exit
LABEL="media_by_label_auto_mount_end"
以下是我在dmesg
[ 524.042731] usb 1-1.4: new high-speed USB device number 6 using dwc_otg
[ 524.174634] usb 1-1.4: New USB device found, idVendor=090c, idProduct=1000
[ 524.174649] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 524.174658] usb 1-1.4: Product: Flash Disk
[ 524.174666] usb 1-1.4: Manufacturer: USB
[ 524.174674] usb 1-1.4: SerialNumber: SCY0000000105542
[ 524.175515] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 524.175994] scsi host0: usb-storage 1-1.4:1.0
[ 525.399056] scsi 0:0:0:0: Direct-Access USB Flash Disk 1100 PQ: 0 ANSI: 4
[ 525.399986] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 525.400243] sd 0:0:0:0: [sda] 15974400 512-byte logical blocks: (8.18 GB/7.62 GiB)
[ 525.401232] sd 0:0:0:0: [sda] Write Protect is off
[ 525.401259] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 525.401948] sd 0:0:0:0: [sda] No Caching mode page found
[ 525.401965] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 525.415578] sda: sda1
[ 525.418642] sd 0:0:0:0: [sda] Attached SCSI removable disk
是否有人有类似的解决方案适用于Raspbian Stretch lite?