From fd08e597a03c83e7855aef6c45d2985fd1a4b1fb Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Wed, 30 Oct 2019 15:54:47 -0600 Subject: [PATCH] Added the ability to wipe raid metadata... hopefully --- wipe.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wipe.pl b/wipe.pl index 78a40fc..07c5ecf 100755 --- a/wipe.pl +++ b/wipe.pl @@ -100,14 +100,18 @@ sub wipethemdrives { # Write say "$disks->{$diskid}{path} - Serial:$disks->{$diskid}{serial} is being wiped..."; my $disksum; + my $disksum2; my $spacer = 29; if ($notreally) { $spacer = 18; print "Pretend wipe complete, pretending to check..."; $disksum = $clobsum; + $disksum2 = $clobsum; } else { open(my $diskw, ">", $disks->{$diskid}{path}) or return warning("could not open $disks->{$diskid}{path}"); print $diskw $clobber; + seek($diskw,-10240000,2); + print $diskw $clobber; close($diskw); system("sync"); print "Wipe attempt complete, checking..."; @@ -116,18 +120,27 @@ sub wipethemdrives { my $diskdata; read($diskr, $diskdata, 10240000); $disksum = md5_base64($diskdata); + seek($diskr,-10240000,2); + read($diskr, $diskdata, 10240000); + $disksum2 = md5_base64($diskdata); close($diskr); } # say "Disk Checksum: $disksum"; if ($disksum eq $clobsum) { say +("."x$spacer)."Checksum $color{green}PASSED$color{reset}"; -# say "$disks->{$diskid}{path} is clean."; - return 1; + print " Checking raid wipe..."; + if ($disksum2 eq $clobsum) { + say +("."x$spacer)."Checksum $color{green}PASSED$color{reset}"; + return 1; + } else { + say +("."x$spacer)."Checksum $color{red}FAILED$color{reset}"; + return 0; + } } else { -# say "Wipe Checksum: $clobsum"; say +("."x$spacer)."Checksum $color{red}FAILED$color{reset}"; return 0; } +# If long flag than zero whole disk and give a progress bar } # to test a drive