ENV vs ATTR in udev rules?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm trying to automount a usb to my raspberry pi, but I can't seem to get my udev rule to work.



The code I'm using is:



ACTION=="add", ENVID_MODEL=="Flash_Drive", RUN+="bin/mkdir /home/pi/heyimhere"


This doesn't work as no directory at that location is created as the flash drive is being plugged in.



I had luck using usb to shut down using the same rules, this time shutting it down using this line:



ACTION=="remove", ENVID_MODEL=="Flash_Drive", RUN+="sbin/shutdown -h now"


Which works - as soon as you remove the usb it shuts down.



Why? Should I use ATTR for add?







share|improve this question


















  • 2




    A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
    – jasonwryan
    Nov 5 '17 at 21:50














up vote
2
down vote

favorite












I'm trying to automount a usb to my raspberry pi, but I can't seem to get my udev rule to work.



The code I'm using is:



ACTION=="add", ENVID_MODEL=="Flash_Drive", RUN+="bin/mkdir /home/pi/heyimhere"


This doesn't work as no directory at that location is created as the flash drive is being plugged in.



I had luck using usb to shut down using the same rules, this time shutting it down using this line:



ACTION=="remove", ENVID_MODEL=="Flash_Drive", RUN+="sbin/shutdown -h now"


Which works - as soon as you remove the usb it shuts down.



Why? Should I use ATTR for add?







share|improve this question


















  • 2




    A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
    – jasonwryan
    Nov 5 '17 at 21:50












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm trying to automount a usb to my raspberry pi, but I can't seem to get my udev rule to work.



The code I'm using is:



ACTION=="add", ENVID_MODEL=="Flash_Drive", RUN+="bin/mkdir /home/pi/heyimhere"


This doesn't work as no directory at that location is created as the flash drive is being plugged in.



I had luck using usb to shut down using the same rules, this time shutting it down using this line:



ACTION=="remove", ENVID_MODEL=="Flash_Drive", RUN+="sbin/shutdown -h now"


Which works - as soon as you remove the usb it shuts down.



Why? Should I use ATTR for add?







share|improve this question














I'm trying to automount a usb to my raspberry pi, but I can't seem to get my udev rule to work.



The code I'm using is:



ACTION=="add", ENVID_MODEL=="Flash_Drive", RUN+="bin/mkdir /home/pi/heyimhere"


This doesn't work as no directory at that location is created as the flash drive is being plugged in.



I had luck using usb to shut down using the same rules, this time shutting it down using this line:



ACTION=="remove", ENVID_MODEL=="Flash_Drive", RUN+="sbin/shutdown -h now"


Which works - as soon as you remove the usb it shuts down.



Why? Should I use ATTR for add?









share|improve this question













share|improve this question




share|improve this question








edited Nov 5 '17 at 21:43

























asked Oct 30 '17 at 15:58









Rocky

113




113







  • 2




    A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
    – jasonwryan
    Nov 5 '17 at 21:50












  • 2




    A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
    – jasonwryan
    Nov 5 '17 at 21:50







2




2




A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
– jasonwryan
Nov 5 '17 at 21:50




A udev rule is the wrong approach. You want SYSTEMD_WANTS; see man systemd.device.
– jasonwryan
Nov 5 '17 at 21:50















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401432%2fenv-vs-attr-in-udev-rules%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401432%2fenv-vs-attr-in-udev-rules%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

The Forum (Inglewood, California)

Palaiologos