You are not logged in.

#1 2025-07-27 08:13:05

Moshiur
Member
Registered: 2025-06-19
Posts: 13

Can't trash files from bind mounts

I have my user directories bind mounted from another disk (like `/mnt/Files/Downloads to` `~/Downloads` for example). When I try to delete something from that bind mount path, like `~/Downloads`, it only gives me the option to permanently delete, I can't move to trash. I tried different file managers like nautilus and thunar.

So for example, this is in my fstab:

UUID=B4DA8928DA88E7C6 /mnt/Files ntfs-3g defaults,nofail,uid=1000,gid=wheel,umask=007 0 0

# User Directories
/mnt/Files/Dme/adiownloads /home/adib/Downloads none bind,nofail,x-gvfs-hide 0 0
/mnt/Files/Music /home/adib/Music none bind,nofail,x-gvfs-hide 0 0
/mnt/Files/Pictures /home/Pictures none bind,nofail,x-gvfs-hide 0 0
/mnt/Files/Videos /home/adib/Videos none bind,nofail,x-gvfs-hide 0 0
/mnt/Files/Document\040Files /home/adib/Documents none bind,nofail,x-gvfs-hide 0 0

But that's not needed to see this problem, I can try this:

mkdir 1
mkdir 2
touch 1/file
sudo mount --bind 1 2

Now when I try to delete `file` from `1`, it works and goes to trash. But if I try to delete `file` from `2`, it only lets me permanently.

What am I doing wrong? Is there a solution to this? Or should I just not bind mount those directories like that? Is there a better solution to what I'm trying to do then?

Last edited by Moshiur (2025-07-27 08:13:39)

Offline

#2 2025-07-27 08:30:52

frostschutz
Member
Registered: 2013-11-15
Posts: 1,619

Re: Can't trash files from bind mounts

Moving files only works within the same filesystem and bind mounts tend to interfere with that (even if it is, in fact, the same filesystem).  This is a problem on the kernel level already (the mv, rename() syscall itself fails).

You might have more luck with symlinks instead of bind mounts.

Otherwise no choice but to re-think your storage layout in a way that is compatible with your file manager.

Offline

#3 2025-07-27 08:46:54

mpan
Member
Registered: 2012-08-01
Posts: 1,571
Website

Re: Can't trash files from bind mounts

If frostschutz’s reply is not clear, due to assuming reader’s knowledge on how trash works, some more explanation.

In Freedesktop, “moving” to a trash means nothing more than renaming a file. The new name is located in the trash directory.⁽¹⁾ This guarantees that both moving to and from trash is atomic, can’t fail,⁽²⁾ and is quick. But that also implies the operation must take place on a single filesystem. And from file operations view, a bind mount is still a separate mount.

If you wish to continue using bind mounts, you may see if your file manager supports global trash directories. This feature is completely optional, so it may not, but for example Thunar supports it.⁽³⁾ To do this:

  • Create a directory name “.Trash” at the top level of a given filesystem.

  • Set sticky bit on it.

  • Give all relevant users permissions to that directory.

Mind that everybody having access to that directory is able to see trashed files.
____
⁽¹⁾ Which is “$XDG_DATA_HOME/Trash”, usually “~/Trash”.
⁽²⁾ Except for I/O errors.
⁽³⁾ In fact it sets up global trash for you, if only you’re the owner of the top-level directory of the filesystem.

Last edited by mpan (2025-07-27 08:49:26)


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

Board footer

Powered by FluxBB