Page 1 of 1
How to create new file in udev
Posted: Sun Nov 13, 2016 5:21 pm
by nebulloyd
Simple question here from someone that has never used udev. How can I create a new file for a new udev rule and rsync? No explanation is too simple! I've tried combinations of cat, > and touch. no luck with anything I can dream up. Please help or I may melt.
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 5:40 pm
by DougieLawson
/etc/udev/rules.d/71-usb-stick
Code: Select all
KERNEL=="sd*", SUBSYSTEMS=="scsi", DRIVERS=="sd", SYMLINK+="stick", RUN+="/usr/local/bin/stick_drive $kernel'"
SUBSYSTEMS=="usb", ATTRS{removable}=="removable", RUN+="/usr/local/bin/flash_drive $kernel'"
Your biggest problem will be that what ever program you start from a RUN+= clause only gets about ten seconds before udev kills it. So you need to make it trigger some other process within a long running daemon.
udev man page wrote: This can only be used for very short-running foreground tasks.
Running an event process for a long period of time may block all
further events for this or a dependent device.
Starting daemons or other long-running processes is not appropriate
for udev; the forked processes, detached or not, will be
unconditionally killed after the event handling has finished.
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 6:55 pm
by nebulloyd
Thank you very much for you response, but I still don't understand how the file is made to which I could paste that code. I am really asking for a key by key explanation I guess. I just tried using that file path but I get the same error as always...(see below)
Code: Select all
pi@raspberrypi:~ $ /etc/udev/rules.d/71-garmingps
bash: /etc/udev/rules.d/71-garmingps: No such file or directory
pi@raspberrypi:~ $ /etc/udev/rules.d/71-garmingps.rules
bash: /etc/udev/rules.d/71-garmingps.rules: No such file or directory
pi@raspberrypi:~ $
it is for this device
Code: Select all
Bus 001 Device 004: ID 091e:2459 Garmin International GPSmap 62/78 series
any suggestions?
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 7:12 pm
by nebulloyd
ok so I created a file using the following command
Code: Select all
sudo nano /etc/udev/rules.d/71-garmingps.rules
will there be any issue down the line with this??
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 7:31 pm
by DougieLawson
It depends what you do with the RUN+= clause. That's where your problems will appear. Those things get killed very quickly after the USB stick gets inserted.
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 7:39 pm
by karrika
DougieLawson wrote:It depends what you do with the RUN+= clause. That's where your problems will appear. Those things get killed very quickly after the USB stick gets inserted.
That is news for me. I am constantly doing 4 - 6 hour update runs without anyone trying to interrupt the action. Has it changed since Lucid?
This RUN+ has worked for me just fine (running time between 1 min 30 sec - 6 hours):
Code: Select all
ACTION=="add", \
RUN+="/usr/local/bin/blink", \
RUN+="/bin/mkdir -p /tmp/usb", \
RUN+="/bin/chmod a+rwx /tmp/usb", \
RUN+="/bin/mount -o $env{mount_options} /dev/%k /tmp/usb", \
RUN+="/usr/local/bin/processusb" \
RUN+="/usr/local/bin/light"
Re: How to create new file in udev
Posted: Sun Nov 13, 2016 7:52 pm
by nebulloyd
Ok this thread has become very similar to my other one. I think for the sake of everyone's sanity we should continue the conversation here:
viewtopic.php?f=91&t=165326&p=1067335#p1067335