Skip to main content

Timeline for Linux auto-mounting USB with UDev

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Aug 26 at 8:33 comment added richstog @grawity: Regarding fstab: isn't it configured for specific devices? I should have automatic mounting of any USB devices. About the bash script: I added the script's operation to the end of the question.
Aug 26 at 8:08 comment added grawity @richstog: For udev RUN, you cannot use shell syntax features as RUN is not implemented through a shell. If you want to use &&, then either call /bin/sh -c '...' manually, or put all of that in a whole shell script. (But as written, your command will fail if /mnt/usb/sdb1 already exists, i.e. it'll only work for the 1st plug but not the 2nd.)
Aug 26 at 8:06 comment added grawity @richstog: It does – for Udisks2 the mount point locations are configured through /etc/fstab.
Aug 26 at 7:40 comment added richstog @grawity: you see what the problem is, udisks does not allow you to make a custom mount point. I need to mount devices to the folder that I specify. I tried to make soft links to udisks mount points, but it's a total pain. maybe there is some specific way to mount via pmount, mount to a specific mount point
Aug 26 at 7:27 comment added richstog @grawity: maybe I misunderstood you RUN+="mkdir /mnt/usb/%k && systemd-mount --no-block -o umask=000,rw /dev/%k /mnt/usb/%k" sdb1: Process 'mkdir /mnt/usb/sdb1 && systemd-mount --no-block -o umask=000,rw /dev/sdb1 /mnt/usb/sdb1' failed with exit code 1.
Aug 26 at 4:14 comment added grawity @davolfman: IIRC the sandboxing is reduced in non-systemd builds since there's no ENV{SYSTEMD_WANTS} to be relied on, but I don't remember the details clearly enough.
Aug 25 at 22:23 comment added davolfman Or at least it behaves that when when systemd is available. The standard set of Yocto recipes for USB live booting puts a udev rule that calls a mounting script into the initramfs to conditionally automount all new storage so a later script can look for the rootfs image. But that's a shell init system not systemd.
Aug 25 at 17:23 history edited grawity CC BY-SA 4.0
added 169 characters in body
Aug 25 at 17:04 history answered grawity CC BY-SA 4.0