0

My file manager needs gvfs for the trash functionality,, but after installing gvfs my drive, which is mounted at /media/storage is read as an external 4tb volume at /dev/dm1 rather than just 'storage'.

These are my mount options in fstab:

/dev/mapper/luks-0d6e1116-38ba-4852-baa2-ef2935d0d26e /media/storage    f2fs    nofail,compress_algorithm=lz4,compress_chksum,gc_merge,lazytime,inline_xattr,inline_data,inline_dentry,flush_merge,atgc 0 2

Why is it behaving this way? (The main reason this is an annoyance, besides the mount name not being used, is that when I try to delete files to trash, the very reason I am using gvfs, it says because the drive is external it can't move to trash and will just delete the file entirely instead)

How do I tell gvfs that the drive is internal?

8
  • 1
    I don't know if there's a way to configure or modify it in any sense, but "trash" here doesn't work like the equivalent in Windows AFAIK (which is backed by a Recycle Bin folder at the root of each drive/volume). Instead essentially it moves the file to somewhere under the home directory of the current user. In other words at least typically it isn't backed by "filesystem-specific" directories, which in turns means trashing from a filesystem that is a different from which your home directory resides in, would result in file copying, which isn't exactly a good idea. Commented Oct 3 at 9:27
  • Is there no per-drive trash functionality in gvfs? Commented Oct 3 at 10:26
  • @Cestarian there is functionality somewhere. And I think Tom Yan is wrong here, and as you describe, there's different functionality depending on which media is detected in nemo and nautilus. I haven't verified this is implemented on the gvfs side of things, though! Commented Oct 3 at 11:16
  • My file manager definitely is implementing it that way, I checked, so this is basically off topic and Tom Yan is either wrong or just wrong in the case of the file manager I'm using at least. Commented Oct 3 at 12:47
  • You may try to add x-gvfs-trash to the fstab entry: docs.gtk.org/gio/method.File.trash.html. Or see if simply removing the fstab entry (which should instead let your DE, assuming you are using one, automount it through udisks2) makes a difference. Commented Oct 3 at 13:17

1 Answer 1

2

It does not have any options for this

As far as I can see here, it does, assuming "this" refers to the fact that whether to create / leverage trash cans on "removable media":

enter image description here

With at least the current version (2.2.0), the default of this setting is false. (For the record, apparently the program setting suppresses / overrides ~/.config/libfm/libfm.conf and the default library setting.)

I assume this is the error popup you saw, and it was your assumption that it is entirely about whether the drive is considered "removable":

enter image description here

The truth is that would be irrelevant if mentioned the setting is false.

So, let's just assume that somehow on your system the setting is true and for reasons, you want to keep it that way. In that case, the first thing you need to do is to make libfm-qt / gio consider the drive non-removable.

As far as I can tell, the reason that it considers your crypt removable, is simply because you have a directory under /media to be its mountpoint. I don't know the exact details behind the scene, but probably because /media (and /run/media/$UID) is somewhere udisks2 consider special, because that's where it create mountpoints when asked to mount stuff. Apparently even if you did not mount a drive through udisks2 (or even if it is configured to mount things under /run/media/$UID), it will still consider it special.

So if you want a drive to be considered non-removable, do not have your fstab entry mount it under somewhere /media. (Obviously if you do not have an fstab entry for it at all and let udisks2 "decides" its mountpoint, it would be considered removable.)

Yet even if the setting is false and/or the drive is considered non-removable, trashing could still fail. One of the reasons would be that the current user does not have permission to create a directory (for trashing, obviously) directly under the root of the filesystem (e.g. it is owned by root:root and has the mode of 0755 / rwxr-xr-x).

Suppose you do not want to change the mode or owner, you run as root either:

mkdir /media/storage/.Trash && chmod 1777 /media/storage/.Trash

(see this regarding the 1)

or:

mkdir /media/storage/.Trash-$UID && chmod 0700 /media/storage/.Trash-$UID

(in which $UID is the numeric id of the current user)

Obviously with the latter only the current user would be able to trash stuff, until you do it again for another user.

Note that if you do not have the drive considered removable (i.e. mounted somewhere under /media), very likely you would need to add x-gvfs-trash to the mount option, otherwise g_file_trash() would still fail because g_unix_mount_entry_is_system_internal() would then return true (except maybe you have it mounted somewhere under e.g. the home directory of the current user, idk).

Ref.: https://specifications.freedesktop.org/trash-spec/latest/

3
  • This is a decent answer for my specific situation, and it is actually what I have already been doing (unticking the "Erase files on removable media" box so the trash can works for the drive). The point of my question is not to find a compromise however, it is to get rid of the compromise. I want my drive mounted where it is, I want files deleted on it to be moved to trash, and I want files on actual removable media like usb drives to be deleted instead of trashed. That is the behavior I expect and desire on any system. I suppose it is possible that there is no way to do it though. Commented Oct 3 at 22:53
  • I believe though since you pointed to the line of code that is the problem that I will accept your answer, this is a problem with the file manager and not gvfs. Commented Oct 3 at 22:59
  • With the information you gave me, I dug a bit further and figured out a solution, I created a PR to fix this issue github.com/lxqt/libfm-qt/pull/1077 Commented Oct 3 at 23:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.