Symptoms and Issue
August 10, 2024 ยท View on GitHub
After installing a hard disk drive, the disk is not recognized by the system despite the disk being functional and correctly seated.
Warnings
:exclamation: This guide is solely for SAS or SCSI disks and does not apply to SATA disks.
:exclamation: An interuption of the process can destroy your disk, assure correct functioning of all other components, stable energy supply and.
:exclamation: Avoid using remote access to shells As soon as you close the shell the process might be (prematurely) terminated.
:exclamation: Study the drives you want to reformat carefully to avoid data loss.
Strategy to reformat the block size of a physical disk for one drive
Hardware Requirements
:exclamation: Only use HBA / PCI Mode controllers that allow to loop through all information of the disk and all data streams directly to the operating system. Don't use under any circumstance Raid Controllers to perform these operations. You can find more information about HBA and Raid Controllers here
Software Requierements
Instructions
- List disks using lsblk
- Identify the device with the wrong block size by executing
sg_format <device> - Run
sg_format -f --format --size=<512 / 4096> <device> --quick - Wait till the process terminated and check by executing
sg_format <device>again.
Strategy to reformat the block size of a physical disk for multiple drives at the same time
Requierements
Instructions
- List disks using lsblk
- Identify the device with the wrong block size by executing
sg_format <device> - Run
for i in {1..28}; do echo "sg_format --format --size=512 /dev/sg$i"; done | parallel -j40
Additional Information for systems using letters to denominate drives
The same command would work also with systems using a drive letter system:
for i in {a..z}; do echo "sg_format --format --size=512 /dev/sg$i"; done | parallel -j40
Additional Information for formating multiple drives that are not in a sequence
Given that the nomenclation of the drives is not always sequential, for i in can be adapted to that use case:
If I want to format drives /dev/sga to /dev/sgc and the drives /dev/sge/ to /dev/sgf/ the command could look like this:
for i in {{a..c},{e..f}}; do echo "sg_format --format --size=512 /dev/sg$i"; done | parallel -j40