There is enough explanation in @vanadium's answer as well as in this answer ... So, I'm here to offer a workaround ... A UDEV rule can automatically check and delete the mount point if it exists under /media/user
.
You, basically, create a file under /etc/udev/rules.d/
like so:
sudo nano /etc/udev/rules.d/70-label.rules
and to make it effective for a certain user, add these two lines in it changing user
in both lines to the desired username e.g. your username:
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/user/%E{ID_FS_LABEL}"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/user/%E{ID_FS_UUID}"
or to make it effective for all users, add these two lines instead:
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/sh -c '/bin/rmdir /media/*/%E{ID_FS_LABEL}'"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/sh -c '/bin/rmdir /media/*/%E{ID_FS_UUID}'"
then save the file and reload UDEV like so:
sudo systemctl restart udev
That should work with both labeled and unlabeled partitions/filesystems.
Notice: the above rule will be triggered by inserting a USB disk that has partition(s) on it and will run regardless of the currently logged-in user and will run commands as root
so, you might want to keep that in mind and I used /bin/rmdir
as a safety measure as it will remove only empty directories as well as the specified real path so it should only remove directories under /media/user
... Also sd[b-z][0-9]
assumes that when you insert the first USB disk, it's given sdb
as a name by the kernel ... If however that is not the case and naming on your system starts from e.g. sdc
because you have more than one hard disk in your machine, then change it accordingly to e.g. sd[c-z][0-9]
for performance reasons.