I have a workstation that we have set up to sanitize multiple hard drives. I run a script that detects the hard drives and then runs the 'shred' command on each one. The problem is, if any of the hard drives fail (where Ubuntu no longer sees the drive) while 'shred' is running, rather than halting, 'shred' will output into infinity with line after line of this:
shred: /dev/sdd: error writing at offset 103456287104: Input/Output error
I don't see any options for 'shred' to enable it to exit if it encounters errors, and I obviously don't want the script to just run forever with the I/O error. Since 'shred' won't halt on it's own when it encounters this error, something else would have be running in parallel to do some kind of error-checking. In my script, I have the verbose output of 'shred' redirected to a log file, and I actually use that log file to check for successful completion of 'shred' in another part of the script. But I'm not sure how to continuously check that log file while 'shred' is still running.
Anyone have any ideas for how I can accomplish this kind of "parallel error-checking?"
I know the 'wipe' command exits when it detects I/O errors, but for reasons beyond our control, we are limited to using 'shred'. It's kind of frustrating that 'shred' doesn't do the same. It would seem like a no-brainer to have it halt upon error, but.....it doesn't.
This is the "shredding" part of my script:
#!/bin/bash
log=/root/sanilog.txt
## get disks list
drives=$(lsblk -nodeps -n -o name |grep "sd")
for d in $drives; do
shred -n 3 -v /dev/$d >> $log 2>&1
done
I'm making a script to use shred.
I have the same problem of you, but its possible to do that:
You can use a fonction to do the same task with all devices
set -e
at the top of a bash script will cause the script to exit if any commands return a non-zero exit code.you can also try a
EXIT trap
to make the script clean up after itselfif don't mind trying an alternative do
shred
,dd
can do a similar job:give it two passes if you're paranoid :)
and ubuntu also have
wipe