Using parallel to sg_format 300+ drives

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Jelle458

New Member
Oct 4, 2022
26
15
3
Hello.

Some time ago I learned about the software parallel: https://forums.servethehome.com/ind...create-raid-0-quick-format.41161/#post-389210

Now I have almost the same goal as previous, but I want to try and do it differently.

For setup I have:
Dell SFF desktop with single port SAS2 HBA
Total of 14 NetApp SAS3 disk shelf
Each disk shelf has 24x 960GB 12G SAS SSD's mounted
The drives run 520 sector size

The goal is to run sg_format --format -e /dev/sgXX on all the drives, preferably using parallel.

It could be done one by one but I'd like to do it using parallel to learn how it functions and potentially get this done faster for all future projects like this.

I use Ubuntu 23.10, added universe repository, used apt update and apt install parallel. Parallel is now installed as well as sg3-utils and smartmontools.

My HBA can handle 128 devices, where device 1 (or 0) is the HBA itself, so I have a total of 5 disk shelves running in a chain, which means I have 120 drives attached. They start at /dev/sg2 and end at /dev/sg126.

The command I used is:
Code:
parallel sg_format --format -e ::: /dev/sg[2-126]
When running it, the terminal freeze up for a few seconds, which is to be expected I guess.

However it is only /dev/sg2 and /dev/sg6 that are actually running, see image below.


All the drives are exactly the same, but only 2 of them want to actually start the format. I get no errors or any reason why all of them are not starting.

I have tried to start the drives "manually" so just using the sg_format command, and all of them start with no issues here.

If I run the command
Code:
parallel sg_format --format -e ::: /dev/sg[2-10]
It runs sg_format on /dev/sg2 and then on /dev/sg0, only those two.
Surely I have a problem when entering multiple devices.

Does anyone know?
 
Last edited:

Jelle458

New Member
Oct 4, 2022
26
15
3
I have found the answer.

When using [ ] it assumes letters. For numbers you need to use { } with two dots between the numbers. The correct command is:

Code:
parallel sg_format --format -e ::: /dev/sg{2..126}
All drives started the format immidiately.
 

jabuzzard

Member
Mar 22, 2021
45
18
8
I use a Bash script to do this that hunts down and reformats all the 520 byte sector size disks attached. You would need to fiddle with the awk pattern matching, this is just to make sure it leaves the system disks on my "Drivenator 1000000" machine alone.

Code:
#!/bin/bash
for dev in $(lsscsi | awk '($3!="ATA" && $3!="SanDisk") {print $NF}')
do
    if [[ "`blockdev --getpbsz $dev`" == "520" ]]; then
        echo $dev
        screen -S ${dev:5:4} -d -m sg_format -v --format --size=512 $dev
    fi
done
 
  • Like
Reactions: Marsh