1

I'm trying to automount a USB device upon plugin but it refuses to mount. I set a rule to execute the following script :

#!/bin/bash mkdir /media/mnt echo AFTER MKDIR > /home/output sleep 5 echo AFTER SLEEP >> /home/output mount /dev/sdb1 /media/mnt echo $? >> /home/output echo AFTER MOUNT >> /home/output 

The script gets executed nicely, lsblk shows that /dev/sdb1 is present, output contain all the echoes, yet sdb1 won't be mounted in /media/mnt. The mount command exit code is 0

When I execute the mount command in that script manually after the USB device is plugged in it mounts it without problem.

5
  • Where did you set that rule? Is it run by root? Perhaps adding a line in your script to validate the effective UID might be a good idea: id >> /home/output Commented Jul 31, 2016 at 18:10
  • @JuliePelletier in /etc/udev/rules.d both the script and the rule where made by root. id returns root Commented Jul 31, 2016 at 18:30
  • 1
    Are you using systemd? Commented Jul 31, 2016 at 18:31
  • @meuh no I'm using udev that calls the script in OP Commented Jul 31, 2016 at 18:35
  • But is your archlinux configured to use systemd for most things? Commented Jul 31, 2016 at 18:36

1 Answer 1

2

Had to add MountFlags=shared in /usr/lib/systemd/system/systemd-udevd.service, whatever this is. See mount is not executed when called by udev

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.