Error creating mount point `/media/$filesystem_name': No such file or directory
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
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?
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
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.
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
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.
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"