Can't mount a filesystem with a UDEV rule

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











up vote
0
down vote

favorite












I don't know what I am doing wrong...



My udev rule:



ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host2/target2:0:0/2:0:0:0/block/sdb/sdb1", RUN+="/bin/bash -c '/bin/mount -v --target /path/to/mount/point > /path/to/debug/file/1 2>&1; echo $? > /path/to/debug/file/2 2>&1'"


My /etc/fstab contains the line:



UUID=XXXXXXXX /path/to/mount/point vfat noauto,noexec,rw,user,uid=1000,gid=1000 0 2




After the device is plugged in:

Debug file 1 contains:



mount: /path/to/mount/point: permission denied.


Debug file 2 contains:



32


And here's the thing:



When I run



mount /path/to/mount/point


manually (after the devices is plugged in), it gets mounted without problems!






Error code "32" is not very informative in the mount man pages. It just states "mount failure"...

I also chose the DEVPATH key after monitoring the uevents with "udevadm monitor", such that it is the last event which triggers the rule. Such that the environment is fully built when the rule gets triggered.



I've experimented with different rules/scripts/configs for days now, without any effort. I tried many HDDs and several file systems. I get this "permission denied" error every. single. time.



I am utterly frustrated/devastated/embittered/defeated/insertnegativeadjectivehere with this issue and asking you guys now as my last hope...










share|improve this question























  • IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
    – dirkt
    Aug 27 at 6:10














up vote
0
down vote

favorite












I don't know what I am doing wrong...



My udev rule:



ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host2/target2:0:0/2:0:0:0/block/sdb/sdb1", RUN+="/bin/bash -c '/bin/mount -v --target /path/to/mount/point > /path/to/debug/file/1 2>&1; echo $? > /path/to/debug/file/2 2>&1'"


My /etc/fstab contains the line:



UUID=XXXXXXXX /path/to/mount/point vfat noauto,noexec,rw,user,uid=1000,gid=1000 0 2




After the device is plugged in:

Debug file 1 contains:



mount: /path/to/mount/point: permission denied.


Debug file 2 contains:



32


And here's the thing:



When I run



mount /path/to/mount/point


manually (after the devices is plugged in), it gets mounted without problems!






Error code "32" is not very informative in the mount man pages. It just states "mount failure"...

I also chose the DEVPATH key after monitoring the uevents with "udevadm monitor", such that it is the last event which triggers the rule. Such that the environment is fully built when the rule gets triggered.



I've experimented with different rules/scripts/configs for days now, without any effort. I tried many HDDs and several file systems. I get this "permission denied" error every. single. time.



I am utterly frustrated/devastated/embittered/defeated/insertnegativeadjectivehere with this issue and asking you guys now as my last hope...










share|improve this question























  • IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
    – dirkt
    Aug 27 at 6:10












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I don't know what I am doing wrong...



My udev rule:



ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host2/target2:0:0/2:0:0:0/block/sdb/sdb1", RUN+="/bin/bash -c '/bin/mount -v --target /path/to/mount/point > /path/to/debug/file/1 2>&1; echo $? > /path/to/debug/file/2 2>&1'"


My /etc/fstab contains the line:



UUID=XXXXXXXX /path/to/mount/point vfat noauto,noexec,rw,user,uid=1000,gid=1000 0 2




After the device is plugged in:

Debug file 1 contains:



mount: /path/to/mount/point: permission denied.


Debug file 2 contains:



32


And here's the thing:



When I run



mount /path/to/mount/point


manually (after the devices is plugged in), it gets mounted without problems!






Error code "32" is not very informative in the mount man pages. It just states "mount failure"...

I also chose the DEVPATH key after monitoring the uevents with "udevadm monitor", such that it is the last event which triggers the rule. Such that the environment is fully built when the rule gets triggered.



I've experimented with different rules/scripts/configs for days now, without any effort. I tried many HDDs and several file systems. I get this "permission denied" error every. single. time.



I am utterly frustrated/devastated/embittered/defeated/insertnegativeadjectivehere with this issue and asking you guys now as my last hope...










share|improve this question















I don't know what I am doing wrong...



My udev rule:



ACTION=="add", DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0/host2/target2:0:0/2:0:0:0/block/sdb/sdb1", RUN+="/bin/bash -c '/bin/mount -v --target /path/to/mount/point > /path/to/debug/file/1 2>&1; echo $? > /path/to/debug/file/2 2>&1'"


My /etc/fstab contains the line:



UUID=XXXXXXXX /path/to/mount/point vfat noauto,noexec,rw,user,uid=1000,gid=1000 0 2




After the device is plugged in:

Debug file 1 contains:



mount: /path/to/mount/point: permission denied.


Debug file 2 contains:



32


And here's the thing:



When I run



mount /path/to/mount/point


manually (after the devices is plugged in), it gets mounted without problems!






Error code "32" is not very informative in the mount man pages. It just states "mount failure"...

I also chose the DEVPATH key after monitoring the uevents with "udevadm monitor", such that it is the last event which triggers the rule. Such that the environment is fully built when the rule gets triggered.



I've experimented with different rules/scripts/configs for days now, without any effort. I tried many HDDs and several file systems. I get this "permission denied" error every. single. time.



I am utterly frustrated/devastated/embittered/defeated/insertnegativeadjectivehere with this issue and asking you guys now as my last hope...







mount udev






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 26 at 20:37









jasonwryan

47.3k14128178




47.3k14128178










asked Aug 26 at 19:11









de_dust

101




101











  • IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
    – dirkt
    Aug 27 at 6:10
















  • IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
    – dirkt
    Aug 27 at 6:10















IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
– dirkt
Aug 27 at 6:10




IIRC udev scripts get executed in a somewhat restricted environment, so /path/to/mount/point may indeed have some parts in it that are not accessible. An obvious workaround is to execute a setuid script with the correct user/group. Running mount manually as root will of course execute without problems. The (no longer maintained) Debian package usbmount does the same thing, so you can also have a look at how they solved it.
– dirkt
Aug 27 at 6:10















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%2f464955%2fcant-mount-a-filesystem-with-a-udev-rule%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%2f464955%2fcant-mount-a-filesystem-with-a-udev-rule%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay