Ubuntu: Trash extremely slow ubuntu 16.04 when used for big files



Question:

I am re writing the question to avoid confusion... On Ubuntu 16.04 I had to delete about 6500 files. 50% were RAW images and 50% were associated .XML files. Totalling 72GB. I am using Samsung Evo SSD 500GB. I actually moved the files to rash first and then deleted them. I noticed that just moving the files to the trash consumed all my RAM (8GB) and all my SWAP (8GB). Is there a setting that can make the Trash in Ubuntu behave more efficiently? I know I can force delete the files and bypass trash altogether but that defeats the purpose of the trash completely. Or is this behaviour expected?


Solution:1

This behavior is expected, because when you delete something using nautilus, it just moves it to the trash, as you know.

Correction: This is not the expected behavior. As BB1 points out, 'moving' a file to the trash doesn't actually move it anywhere, it just updates it's inode to reflect the location.

I would guess that your ram is being eaten because it takes much more system resources to delete (or do anything with) a bunch of small files than it does to delete one bigger file.

The behavior of Trash doesn't appear to be very customizable. There's not much that be done about that, unfortunately. You could look into trash-cli, but I don't know if it would be more efficient or not.

When I have to delete a bunch of small files, I always do it from the shell, because it's faster. Even then, I have encountered an error while trying to delete nearly a 100k files, something along the lines of "rm: argument list too long". To get around that, I ran rm in a for loop and iterated through the files like:

for letter in {a..z};do rm -f $letter*;done  

If you wanted to emulate the trash functionality in the shell, you could try something like this:

#!/bin/bash  ## pseudotrash  elsewhere=/media/$USER/some-external-drive/pseudo-trash  for file in "$@";do    cp $file $elsewhere    if [ "$?" -eq "0" ] ; then      rm -f $file && echo "Backed up and deleted $file"||\      (echo "Could not delete $file , aborting";exit 1)    else      echo "Could not copy $file,aborting" ;exit 1    fi  done  

And than run it like:

pseudotrash `ls`  

or

pseudotrash 'file1 file2 file3'  

I hope that answers your question and offers some insight to help solve your problem.


Solution:2

This is (was) a very annoying bug in Nautilus (package gvfs):

But just 3 days ago this bug was fixed and the fix version added to repositories.

2017-08-28: This bug was fixed in the package gvfs - 1.28.2-1ubuntu1~16.04.2

Run sudo apt-get update && sudo apt-get upgrade to update to the new version.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »