WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: udev usb automount doesnt after reboot  (Read 3979 times)

Offline halma

  • Full Member
  • ***
  • Posts: 164
udev usb automount doesnt after reboot
« on: September 21, 2018, 07:16:01 PM »
Hi, i have an external usb hdd, and this udev rule for automounting an external usb hard drive, connect after tc has booted.

Code: [Select]
KERNEL!="sd[a-z][0-9]", GOTO="mnt_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 /mnt/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /mnt/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /mnt/%E{dir_name}", RUN+="/bin/rmdir /mnt/%E{dir_name}"
# Exit
LABEL="mnt_by_label_auto_mount_end"

if i connect the external hdd after TC has booted the drive will be mounted, but if i reboot and the drive is not fast enough to be recognized at boot, i dont want to use waitusb=XX cause slows down booting, udev does not mount the drive again, even if i try
Code: [Select]
sudo udevadm control --reload-rules && sudo udevadm trigger
is there anyway that the drive will be mounted from the udev rule or do i need a script running in the background and waits till found the drive and mount them ?
thanks.
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: udev usb automount doesnt after reboot
« Reply #1 on: September 22, 2018, 04:45:03 AM »
I think it's the ACTION clause, something about "udevadm trigger" causing a change action vs an add action. It was complicated in that you didn't want everything to "add" twice, which could cause issues.

Try udev's monitor command, you'll see what events your drive sends when it spins up.
The only barriers that can stop you are the ones you create yourself.

Offline halma

  • Full Member
  • ***
  • Posts: 164
Re: udev usb automount doesnt after reboot
« Reply #2 on: September 22, 2018, 03:48:28 PM »
hi curaga,

this is what happend after picore is done booting, then turning on the external usb hdd by hand,

Code: [Select]
sudo udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[468.327208] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3 (usb)
UDEV  [468.335850] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3 (usb)
KERNEL[468.340699] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
UDEV  [468.345231] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
KERNEL[468.349717] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0 (scsi)
KERNEL[468.350161] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/scsi_host/host0 (scsi_host)
UDEV  [468.354260] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0 (scsi)
UDEV  [468.358860] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/scsi_host/host0 (scsi_host)
KERNEL[469.367579] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0 (scsi)
KERNEL[469.367868] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[469.368060] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
UDEV  [469.373615] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0 (scsi)
KERNEL[469.374267] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
KERNEL[469.375351] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
KERNEL[469.386881] add      /devices/virtual/bdi/8:0 (bdi)
UDEV  [469.393703] add      /devices/virtual/bdi/8:0 (bdi)
UDEV  [469.426215] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0 (scsi)
KERNEL[469.430256] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[469.432678] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda2 (block)
UDEV  [469.439681] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk)
UDEV  [469.444060] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device)
UDEV  [469.465221] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg)
UDEV  [471.408363] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV  [473.714382] add      /devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda2 (block)
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol