udisks icon indicating copy to clipboard operation
udisks copied to clipboard

Error creating mount point `/media/$filesystem_name': No such file or directory

Open milahu opened this issue 6 months ago • 6 comments

the udisks daemon fails to create the /media directory and there is no error message in syslog

$ udisksctl mount -p block_devices/sdb
Error mounting /dev/sdb: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error creating mount point `/media/ZCT01TB4_8tb': No such file or directory

$ stat /media
stat: cannot statx '/media': No such file or directory

$ sudo mkdir /media

$ udisksctl mount -p block_devices/sdb
Mounted /dev/sdb at /media/ZCT01TB4_8tb

$ sudo journalctl -u udisks2.service | grep ' /media'
Jul 02 16:35:55 laptop udisksd[1785]: Mounted /dev/sdb at /media/ZCT01TB4_8tb on behalf of uid 1000

$ cat /etc/udev/rules.d/99-udisks2.rules
# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/$filesystem_name)
# ==0: mount filesystem to a private directory (/run/media/$USER/$filesystem_name)
# see also: man udisks
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

see also: Udisk - Error creating mount point no such file or directory

milahu avatar Jul 02 '25 14:07 milahu

the udisks daemon fails to create the /media directory

~~Correct, UDisks is not supposed to create that directory. If it's missing, then it's a distribution issue. Also depends how udisks is configured in build-time - the configure --enable-fhs-media options is off by default, meaning the distributor needs to deliberately choose /media mounting and it's their task to have this directory available and set up with proper ownership and permissions.~~

Right, it's the UDISKS_FILESYSTEM_SHARED attribute bypassing creation of the mount base. Is the 99-udisks2.rules file yours or supplied by the distribution?

tbzatek avatar Jul 07 '25 12:07 tbzatek

99-udisks2.rules is a custom file created by me so apparently its my responsibility to create /media

maybe the output of udisksctl mount and/or journalctl -u udisks2.service could be more helpful

milahu avatar Jul 07 '25 13:07 milahu

Well this is one of the things vaguely defined in the documentation, let me try to find more context why it is done this way and any historical context, if there's any.

tbzatek avatar Jul 07 '25 13:07 tbzatek

in my case, udisksd is run by root, so it would have the necessary permissions to mkdir /media

$ ps -AF | grep udisks2 | grep -v grep
root        1785       1  0 238623 7252  11 Jul02 ?        00:01:22 /nix/store/wl368fmmrn4ciy2lhg733kk9xx521wjf-udisks-2.10.1/libexec/udisks2/udisksd

milahu avatar Jul 07 '25 14:07 milahu

The error occurs because the /media directory does not exist by default, and udisks does not create it automatically. To resolve this, please manually create the /media directory with the appropriate permissions:

sudo mkdir /media
sudo chmod 755 /media

After creating the directory, the mount operation should succeed. This is expected behavior, as the responsibility for managing the /media directory lies with the distribution or system administrator, not udisks.

ermezavx avatar Sep 02 '25 02:09 ermezavx

udisks does not create it automatically

ok, but ...

udisks should print a syslog message like "please run sudo mkdir /media"

udisks should have an option to create missing directories to avoid workarounds like systemd tmpfiles so i can fully automate the OS installation (NixOS Linux...)

this option should be part of the custom udev rule to have everything in one place, something like

ENV{ID_FS_USAGE}=="filesystem|other|crypto",
ENV{UDISKS_FILESYSTEM_SHARED}="1",
ENV{UDISKS_CREATE_MISSING_DIRECTORIES}="1"

milahu avatar Sep 02 '25 05:09 milahu