shred is very slow

Bug #279598 reported by kmvzxuwi
4
Affects Status Importance Assigned to Milestone
coreutils
Fix Released
Undecided
Unassigned
coreutils (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: coreutils

Random passes of shred are painfully slow: it takes me 571 seconds to make the first (random) pass on a 2.0GiB flash device, while only 125 seconds where needed to perform the second pass.
So, random passes are nearly _five_ times slower than other passes while erasing flash devices...

Please note that this is the same for HDDs: with different times, for course, but the difference can be even bigger (near an order of magnitude on my systems).

Tested on Intrepid beta, Hardy and (if I recall correctly) Gutsy.
Feisty (again, if I recall correctly) worked just right.

Revision history for this message
C de-Avillez (hggdh2) wrote :

Thank you for opening this bug and helping make Ubuntu better.

Indeed. From coreutils 5.x to 6.0 shred moved from an internal PRNG to /dev/urandom (i.e., the system PRNG). It seems this move is most probably the reason for the new high time. I am trying to get some times from the execution of shred to confirm.

If this is indeed the case (and I think it is, but I am still to query upstream on that) I do not think there is much for us to do. Perhaps using Fortuna (see http://en.wikipedia.org/wiki/Fortuna_(PRNG)) as the PRNG might make a difference.

Changed in coreutils:
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
kmvzxuwi (kmvzxuwi-deactivatedaccount) wrote :

Thank you for reviewing my bug report.

A temporary stop-gap fix might be to pick a single value from /dev/urandom and use it for every write of the random pass, instead of picking a different value for every write.
Of course, every random pass must pick it's own value to strengthen the process.

Revision history for this message
C de-Avillez (hggdh2) wrote :

I am unsure on the benefits of such a move: the idea behind writing the file/disk with random data is to make an eventual recovery more difficult. Fixing on a single value (albeit random) sort of defeats it -- it will be just a bit more difficult to find the pattern, and subtract it out of the signals.

Still researching.

Revision history for this message
kmvzxuwi (kmvzxuwi-deactivatedaccount) wrote :

Have you finished researching?

I ask, at least, to remove the "incomplete" status: as of 8.10 (fully updated) bug is still there, can be very easly verified by anyone and have a nice and elegant explanation, so this is all but "incomplete".

Brad Johnson (kkhww1902)
Changed in coreutils:
status: Incomplete → Confirmed
Revision history for this message
C de-Avillez (hggdh2) wrote :

I am sorry. The day-to-day "earn money" piece took a toll on my available time to keep on here. By an amazing coincidence this was brought up at the upstream mailing list just a few days ago (see http://lists.gnu.org/archive/html/bug-coreutils/2009-01/msg00123.html), and it had a bit of movement today.

Previously we had http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00318.html already pointing the current issue.

Anyway: I am going ahead and marking this as triaged, and will add in here the final position.

Changed in coreutils:
importance: Medium → Low
status: Confirmed → Triaged
Revision history for this message
kmvzxuwi (kmvzxuwi-deactivatedaccount) wrote : Re: [Bug 279598] Re: shred is very slow

Thanks for your time and for the links: "--random-source=/dev/zero" is
the stop-gap trick that I was searching.

Revision history for this message
C de-Avillez (hggdh2) wrote :

A recently committed patch to shred (coreutils trunk, 7.x) is reducing the default number of passes from 25 to 3. A quick and informal test shows a significant reduction in elapsed time. Nevertheless, all passes are now random.

Revision history for this message
C de-Avillez (hggdh2) wrote :

Another recently committed patch upstream has taken out /dev/urandom as the default random source for shred (the internal PRNG is back in). shred is now at least 10 times faster.

I have opened (and marked fixed) an upstream task to signal a fix is available on current trunk.

Changed in coreutils:
status: New → Fix Released
Revision history for this message
C de-Avillez (hggdh2) wrote :

This bug has been fixed on Karmic, coreutils 7.4.

A lingering issue is to recode the logic to select the overwrite passes (right now shred defaults to 3 passes, and all of them will be random). Nevertheless, there is no visible performance impact anymore.

Changed in coreutils (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.