0

I have two disks, disk 1 and disk 2

disk 1 is a bulk storage disk mounted at /home

disk 2 is smaller, mounted as a subfolder of /home (/home/Username/blah) and gets more activities

Currently, When I delete a file from disk 2, it stores it in a folder inside disk2 called .Trash-1004(/home/Username/blah/.Trash-1004). That fills up the disk relatively quickly.

I would like to make the deleted files go to the normal Trash folder at /home/Username/.local/share/Trash

What are my options here? Could I write a script that automatically moves the files? Or is there a more native way of doing it?

Any help will be greatly appreciated :)

2 Answers 2

1

When you 'delete' the file, it's being copied to the Trash directory. That much is obvious, but what might not be obvious is that this is a very quick operation because the file stays on the same disk and same partition.

If you delete a file and move it to another disk, this will increase the time it takes to delete the file.

If deleted files are taking up too much disk space, you could always just actually delete the files. Hold Shift when you delete the files to delete them, skipping the Trash. You could also clean your Trash regularly with a tool such as autotrash via cron.

I don't want to discourage you from exploring and having your system do exactly what you want, but you can run into weird issues with moving files to different disks when you delete them and I think your problem would be best solved by properly cleaning your Trash.

1
  • 1
    Thanks for your answer and I understand your point, but I feel this question should stay open for others who might want this implemented. Again thanks for taking your time and answering!
    – Kenivia
    Jan 25, 2020 at 3:18
0

I have written a simple script that does this.

It replys on inotify, install it using sudo apt install inotify-tools

trash_path="/home/Kenivia/gdrive/.Trash-1004/"
move_path="/home/Kenivia/.local/share/Trash"
inotifywait -m "$trash_path"files -e create -e moved_to |
    while read path action file; do
        mv "$trash_path"files/"$file" $move_path'/files'
    mv "$trash_path"info/"$file"'.trashinfo' $move_path'/info'
    done

Change your paths accordingly.

To run this silently on startup, save the above code in a shell script and add this command to the startup applications:

nohup bash /PATH/TO/SHELL/SCRIPT/Move_trash.sh >/dev/null 2>&1 &

I am very new to shell scripts, please point out any mistakes if there is any, but it seems to work perfectly on my machine. In terms of performance impact, it consistently uses 0% CPU even when it is moving files which is rather a pleasant surprise.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .