1

I want to do is auto mount every usb-drive to static path. But when I send kernel name with %k to shell script it returns like 1-3, 2-4 ... not sdc1, sdd1... s[b-z][1-9]

this is my udev rules 10-local.rules

SUBSYSTEM=="usb",ACTION=="add",SYMLINK+="usb_%k",RUN+="/home/etc/udev-mount.sh %k "
ACTION=="remove",SUBSYSTEM=="usb",RUN+="/home/etc/udev-umount.sh %k"
~                                                                               
~                       

and shell script

#!/bin/sh

DEVICE=$1


mkdir -p /app/$DEVICE

mount /dev/$DEVICE /app/$DEVICE

I'm using UBUNTU 16.04

please help me..

7
  • and when I set symlink to some label and mount it to other path it said "mount: /dev/bus/usb/001/023 is not a block device" Oct 10, 2018 at 10:07
  • It just mount /dev/sdd1 /other/path, it mounted well... Oct 10, 2018 at 10:08
  • Excellent reference on what OP is trying to accomplish: superuser.com/a/64970/662962 Oct 10, 2018 at 10:59
  • Thank you, But I just want how to get kernel name like sda1... not 1-3, That references doesn't answer it. Oct 11, 2018 at 2:05
  • True but in the reference it appears to be working properly using %k argument. I haven't tested it myself though. Oct 11, 2018 at 2:09

1 Answer 1

1
  • Actually, you are getting the right kernel name using %k and it is passed to the script.

  • However, your rule condition is blind SUBSYSTEM=="usb" , it filters other device nodes other than the ones you want (partition devices).

    Take a look on UDEV manpage, like the difference SUBSYSTEM=.. vs SUBSYSTEMS=.. , use udevadm info -a .. to get more info for condition.

  • You may use this simple one

    ..,KERNEL="sd[a-z][0-9]*",SUBSYSTEMS=="usb",..
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .