Mdadm create RAID 0 quick format

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.

I got a big project lined up and would love some input on how to do it.

Basically I have around 400 hard drives that I need to test and delete the data from. I don't need sanitization or anything like that, just a basic "quick format" as we know it from Windows.

All drives are running 520 block size and I'd like to keep it that way.

I am using systemrescuecd but it could be any Linux live distro, for me it doesn't matter.

What I have thought of:
Windows can't do it for me because of 520.
sg_format is a long format, and would take too long.
Gparted could be used to create a new partition table, effectively deleting the original one. Accomplishes my goal but I need to mark each drive individually, which would again take a long time.

I then landed on mdadm, where I would create one very big RAID 0. I have used mdadm about 5 times in my life, so I need a guide, which I found here:

However in this guide it shows how to check status of the creation of the RAID 0. Would RAID 0 take a long time to make?
My HBA can only take 127 devices at a time so it won't be all 400 drives in one go.
But mdadm also wants me to specify each drive individually, it could take some time with 127 drives connected.

Is there a faster way of doing this?
 

rtech

Active Member
Jun 2, 2021
307
110
43
GNU Parallel combine it with sfdisk/sgdisk would be my first option here
Something to kickstart you.
 

Jelle458

New Member
Oct 4, 2022
26
15
3
This could be a game changer. I bet I can use GNU Parallel and then see the full one drive in Gparted, if I understood this correct. I will look into this, thank you!
 

Jelle458

New Member
Oct 4, 2022
26
15
3
So I did understand this wrong.

I would have to run:
parallel -P 5 mke2fs -t ext4 ::: /dev/sd[d-p]1

If I do understand it correctly this makes an EXT4 partition on sdd to sdp.
Now let's say I don't want to run mke2fs, but I would like to empty out the drive, so they have no partition at all.
All I can find are GUI programs and fdisk, but I am unsure if fdisk can do it, as it also sort of "opens" the drive and I would have to press d to delete.

What is the "opposite" of mke2fs? I really can't find anything.

Not new to Linux, just.... not so experienced yet.
 

rtech

Active Member
Jun 2, 2021
307
110
43
GNU Parallel combine it with sfdisk/sgdisk would be my first option here
sfdisk --delete /dev/sda
or

sgdisk
-d, --delete=partnum
Delete a partition. This action deletes the entry from the partition table but does not disturb the data within the sectors originally allocated to the partition on the disk. If a correspond‐
ing hybrid MBR partition exists, gdisk deletes it, as well, and expands any adjacent 0xEE (EFI GPT) MBR protective partition to fill the new free space.

-z, --zap
Zap (destroy) the GPT data structures and then exit. Use this option if you want to repartition a GPT disk using fdisk or some other GPT-unaware program. This option destroys only the GPT
data structures; it leaves the MBR intact. This makes it useful for wiping out GPT data structures after a disk has been repartitioned for MBR using a GPT-unaware utility; however, there's a
risk that it will damage boot loaders or even the start of the first or end of the last MBR partition. If you use it on a valid GPT disk, the MBR will be left with an inappropriate EFI GPT
(0xEE) partition definition, which you can delete using another utility.
Copied from man
 

nexox

Well-Known Member
May 3, 2023
696
284
63
First, what's the goal of removing or replacing the partition tables? I suspect there is a better way to get where you want to go. Second, you don't need to use parallel for operations that run quickly, a simple for loop would be fine, something like:
Bash:
for d in /dev/sd*; do
  sfdisk --delete $d
done
That would try to run on any existing partitions too, probably generating errors that you could ignore, but you could also just use dd to overwrite the first 1MB or so: dd if=/dev/zero of=$d count=1 bs=1M
 

Jelle458

New Member
Oct 4, 2022
26
15
3
Copied from man
This could be it, thank you!

First, what's the goal of removing or replacing the partition tables? I suspect there is a better way to get where you want to go. Second, you don't need to use parallel for operations that run quickly, a simple for loop would be fine, something like:
Bash:
for d in /dev/sd*; do
  sfdisk --delete $d
done
That would try to run on any existing partitions too, probably generating errors that you could ignore, but you could also just use dd to overwrite the first 1MB or so: dd if=/dev/zero of=$d count=1 bs=1M
The goal is to "remove" the data on all the drives. I write "remove" because I know deleting the partition won't go far, but overwriting the partition once, then deleting it, would make the drive be seen as empty. That's what I actually care about, a drive that's seen as empty, ready to fill.

I am unsure of how to run scripts though. My experience just spand from using smartctl to setblocksize where I would have to use make all.
So it isn't great experience I have. If sfdisk could be run with parallel with sda-x then I could delete the partitions on the drives pretty easy, and accomplish my goal.

However, a script would also go a long way for the future. This isn't the first time I have this many drives, but it is the first time they all run 520 block size, and they need to be kept at 520 block size.

What is your goal with "test" ?
What is your goal with "mark" ?
My apologies for not making this clear.

With "test" I just mean a long SMART self-test using smartctl, and checking for errors in the SMART log.

With "mark" I mean that in a GUI like Gparted I would have to select one drive, delete partition, select the next drive, delete partition and so on.
If I could just run one command and do what I want on all drives in one go, I could save a lot of time. Not only this time but also in the future.

If I have 512 drives that needs this, I of course first do the testing with smartctl, then I boot a windows 10 pro live I made, and here I can use storage spaces to easily select all drives in one go, and do basically a big software RAID 0 to "zero" the drives. Then delete the storage space and the drives have no partition on them, which is the goal.

So to specify for this specific project:
Delete all partitions on all drives at once
Create a new partition on all drives at once
Delete the new partition on all the drives at once

This would satisfy the person who needs these drives in a SAN.

I just started my day. I will experiment with sfdisk and parallel first. Any inputs on this is greatly appreciated. I fear my knowledge and experience may not reach as far to do this, but I will read up on it as much as possible. Whatever the solution will be, I will report back.
 

Jelle458

New Member
Oct 4, 2022
26
15
3
My progress will be in pictures, as it's on a different machine than what I am on writing here.

My first problem was to even get parallel onto my ubuntu 22.04. It kept saying it couldn't find the package, but when searching for this issue all I could find was "Just write apt install parallel" but this never worked.
Turns out you need universe repository for this. I pulled my hair out for half an hour trying to download an older version and using make install which didn't work either.
No where on the internet does it say you need universe to install, but after adding universe it just.... worked.

Anyway I believe I got parallel working, and it's actually a pretty neat thing:


Sure enough it actually goes through sdb to sde, which is exactly what I wanted it to do. However I get "No such file or directory".


... But they are there. However they tell me they are 0B, this is probably the issue.



But sg_scan can find my drives, sg4 to sg7.


Smartctl can also read the drive. 8TB with 520 block size. No problem.


But Gparted cannot find my drives. Probably because sdb to sde is 0B.

Using sfdisk --delete /dev/sdb also returns "No such file or directory", without using parallel. So it seems like parallel is doing exactly what I would like, and my original issue is effectively solved.

But now the issue is, how come the drives don't show up? Can I do something to make them show up?

sg_format is able to format the drives, it just takes waaaayyy too long to do so.
It could be a simpel thing, but my brain feels like liquid at this point.

I will do some searching, if I find the answer I will post it, but if someone has the magic answer I'd be extremely greatful!
 

rtech

Active Member
Jun 2, 2021
307
110
43
--delete device [partition-number...]

You need to put number behind sdX that would be the partition number to delete
 

Jelle458

New Member
Oct 4, 2022
26
15
3
This did not work either.

" Linux cannot read disks formatted with 520-byte sectors. (Nor does Windows.) If you want to use this drive with Linux, you need to reformat it to 512-byte sectors. Instructions to do this are very easy to find on the Internet. "

TrueNAS is not helpful either, it still needs 512 bytes:

" After some sleuthing, I discovered that the disk was SCSI formatted to 520 byte sectors. Linux does not accept sector sizes that are not a power of 2, and so i was unable to do anything with the disk using fdisk, kpartx, etc. Research pointed me to the sg_format utility, but I was unable to make that work. "

It is simply not possible.

I have reformatted 520 drives to 512 many times, I know how that works, and most of the time sg_format works, but sometimes it doesn't so the utility setblocksize helps me there.
This time was different though. For the first time I wanted to keep them 520 byte size for a SAN, and I figured I didn't need a low-level format on them.

Turns out, I can't do ANYTHING to these drives, except a low-level reformat, keeping the 520 size, but takes forever. There is no "quick" option with sg_format.

I did sg_format on some drives already, these are 960GB SSD's and didn't take very long, I was trying to avoid having the big drives spinning for a long time to low-level format them.

Another options is to get a NetApp SAN, set it up and just have it ready to fire up whenever drives like these come across my table. Using the actual SAN these drives should run in, I could create a big RAID 0, then delete it again, to make the drives seem empty.
I am looking into this option. I have knowledge of many different SAN from IBM and HP, but not NetApp. I am sure I can get it set up with some research and time.

Thanks to all who posted here, I actually learned a lot, and this parallel utility is just awesome, I might use to it start the low-level format on all future drives to be faster.