badblocks script against multiple drives

Need help with C, C++, perl, python, etc?

badblocks script against multiple drives

Postby cphillips » 2017-02-23 15:48

Hi all,

I have a load of disks to check for bad sectors and intend on using badblocks.

I have a server with 12 drive slots and would like to test all 12 at the same time.

I have a script but it is running through them one at a time, I'd like all 12 to run in parallel.

Here's the script at present:



Code: Select all
#!/bin/bash
if [ -f badblocks.out ];
then
           rm -f badblocks.out
   fi

   touch badblocks.out

   for drv in {b..k};
   do
               echo "SCANNING /dev/sd$drv">> badblocks.out
                   badblocks -v /dev/sd$drv >> badblocks.out
done


Can anyone advise on how I can get this to run all drives at once? Would save me a whole load of time!

Thanks in advance.
cphillips
 
Posts: 1
Joined: 2017-02-23 15:37

Re: badblocks script against multiple drives

Postby wizard10000 » 2017-02-23 16:10

Not positive, but this makes sense to me - note the two semicolons I added and the wait command.



Code: Select all
#!/bin/bash
if [ -f badblocks.out ];
then
           rm -f badblocks.out
   fi

   touch badblocks.out

   for drv in {b..k};
   do
               echo "SCANNING /dev/sd$drv">> badblocks.out;
                   badblocks -v /dev/sd$drv >> badblocks.out;
done
wait
exit 0
we see things not as they are, but as we are.
-- anais nin
User avatar
wizard10000
 
Posts: 1143
Joined: 2011-05-09 20:02
Location: midwestern us

Re: badblocks script against multiple drives

Postby dasein » 2017-02-24 11:30

cphillips wrote: I have a load of disks to check for bad sectors and intend on using badblocks.

Forcing reallocation with dd achieves the same goal in a lot less time.
User avatar
dasein
 
Posts: 7771
Joined: 2011-03-04 01:06
Location: Terra Incantationum


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable