3

I'd like to mount an ext4 partition with subfolders for multiple users

/data
  user1/
  user2/
  ...

just like /home. Thus I copied the fstab entry of the /home mouting,

UUID=...   /data    ext4    defaults    0    2

manually created the mount point

sudo mkdir /data

and created subfolders with the appropriate rights:

sudo mkdir /data/user1 && chown user1:user1 /data/user1
sudo mkdir /data/user2 && chown user2:user2 /data/user2
...

Though this allows the users to create files in their subfolder, they are not able to move them to trash.

I manually created the lost+found folder with no luck.

# ls -al /data/ | grep lost
drwx------  2 root        root        4096 Okt 15 11:55 lost+found

What do I need to change to enable the trash?

3 Answers3

2

the trash directory needs to be named in this format to make this work: .Trash-$UID Allow for 'Move to trash' instead of 'permanently delete' for mounted partition?

#######################################################################

According to this archlinux post referring to the FreeDesktop Trash Specification we can use trash folders for each user, that are located in the top folder

/data
  .Trash-<user1.uid>
  .Trash-<user2.uid>
  ...

and that are owned by the respective user.

chown user1:user1 /data/.Trash-<user1.uid>
chown user2:user2 /data/.Trash-<user2.uid>
...

After this modification users are able to create files, to delete files to the trash and to recover them.

Update: You have to re-log to make this work.

  • 2
    The Trash-Spec and KDE are very picky about the permissions on these files. Trash-Spec says, .Trash/ must be 1777. KDE wants .Trash/ and .Trash- to be 700 (until a patch of Sept 2020) – JPT Oct 08 '20 at 16:17
0

the correct format for the said trash directory is

.Trash-$UID

mkdir -p .Trash-$UID/{expunged,files,info} chown $UID:$GID -Rv .Trash-$UID chmod 750 -Rv .Trash-$UID

The above works for me in ubuntu, arch, and fedora references:

Allow for 'Move to trash' instead of 'permanently delete' for mounted partition?

https://wiki.archlinux.org/title/Trash_management

https://bbs.archlinux.org/viewtopic.php?id=207042

-1

I created a script named mktrash.sh to mkdir the trash-folder.

#!/bin/bash

if [ "$1" = "" ]; then echo "Parameter: <mount path> - the top directory" exit fi

TRASH=$1/.Trash UTRASH=$TRASH/$UID

echo Creating Trash Directory: $UTRASH echo Ctrl-C to Cancel, Enter to Continue echo You will need to enter your SUDO password for creating $TRASH read VAR

sudo mkdir -v $TRASH sudo chmod -v 1777 $TRASH mkdir -v $UTRASH chmod -v 700 $UTRASH

Would be nice to have this automated for any mounts.

Once the .Trash dir exists, new users should be added automatically as Trash is world writeable.

JPT
  • 369