Skip to main content
  1. October/

Reformatting drives with obtuse blocksizes to 512b

The Problem #

So you purchased some OEM rebranded HDD or SSDs secondhand.

It was a SUPER great deal, right?

These likely originated from major a storage vendor such as NetApp, EMC (Fuck EMC), or even HP or Dell.

You’re excited the night your order shows up; Right up until you attach one of these megacheap deals to your host….

Only to discover the drive that you’ve purchased will not initialize….

$ sudo diskinfo -v da7
da7
        520             # sectorsize
        1600321314800   # mediasize in bytes (1.5T)
        3077540990      # mediasize in sectors
        4160            # stripesize
        0               # stripeoffset
        191568          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        HITACHI HUSMM141CLAR1600        # Disk descr.
        0SYBE15A                # Disk ident.
        Yes             # TRIM/UNMAP support
        0               # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Well Fuck.

Don’t Panic #

Much of the rest of this post was paraphrased from This ServeTheHome article

The most frequent cause of this minor panic-laden moment is that the drive was formatted by the factory with a non standard sector size of 520B or 528B.

refused to initialized drive other than the normal 512B or 4Kb. I read online the reason that these drive are formatted that way is due to some proprietary software that these vendor uses needs the additional sector size for some fancy parity stuff.

Why the fuck would someone do this? #

Strangely enough… (I know, right?) This IS NOT a gimmick. There’s legit reasons that provide value in vendor-managed environs.

Pro Tip: The secret is that extra 9 of durability

The following is paraphrased from a Freebsd.org forum post:

OK, let’s go to the basics. 520b and 528b disks have existed for ages, probably since the 70s.

They probably were more common than 512-byte sector disks until the PC revolution.

The extra bytes can store all manner of things, such as checksums, keys (for CKD data), metadata that links the content (not uncommon in databases), and so on. There are also block sizes that are a little bigger than 4K, for the same reasons. Quite a few industrial-strength disk systems use them.

Today, many industrially used disks are instead formatted using T10-DIF, which also stores checksums on disk. That is kinda… sorta… similar to having 520-byte blocks, but… only kinda sorta.

Also, a lot of file systems (such as ZFS) use checksums, but they do something smarter than 520-byte blocks or T10-DIF, they store the checksums AWAY from the data, thus allowing the detection of a whole block write going missing (data and checksum).

All these technologies add real value, and aren’t just a scam to charge customers more.

If you don’t understand what sectors, logical blocks, and physical blocks are, you should probably read the Wikipedia pages about disks….

But, Really quick: At the interface level, the drivers read/write whole logical blocks.

Some disks internally aggregate logical blocks of 512 bytes into physical blocks of 4096 blocks.

The word sector really shouldn’t be used at the interface level, as it can easily be confused with

Logical block
(the unit of atomic data transfer)

and

Physical blocks
The unit of atomic IO.

I know of no common open source file system that can make use of disks with block sizes other than 512 or 4096 bytes. Candidates include ZFS, UFS, ext2/3/4, XFS..


The post continues, but you get the gist.


Okay… So…

Now we know a bit more about HOW we got here… but uh… what do I do with this paperweight?

The Solution #

After trying to attach the drive in every possible system, through every single controller you have, and still are having no luck, you probably think you’re SOL.

Luckily there is a way to reconfigure the drive: Low Level Re-Formatting #

This will coerce your hipster drive to use a sector size of 512B.

Requirements for proceeding #

You’ll need:

  • A linux host
  • A JBOD sas/scsi controller This may be more problematic than you’d think. Controllers can be VERY finicky here.
  • The sg3_utils package
  • Likely, you’ll ALSO need either:

De-Hipsterification of yer drive #

Look in /var/log/messages after booting, and you will hopefully see useful information:

Mar 9 08:08:54 vhc-carthage kernel: sd 6:0:7:0: [sdh] Attached SCSI disk
Mar 9 08:08:57 vhc-carthage kernel: ...ready
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] Unsupported sector size 520.
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] 0 512-byte logical blocks: (0 B/0 B)
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] 520-byte physical blocks
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] Write Protect is off
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] Write cache: disabled, read cache: enabled, supports DPO and FUA
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] Unsupported sector size 520.
Mar 9 08:08:57 vhc-carthage kernel: sd 6:0:8:0: [sdi] Attached SCSI disk

Sweet! Lets get to rippin off them skinny jeans!

# yum install sg3_utils

# sg_scan -i
/dev/sg8: scsi6 channel=0 id=7 lun=0
NETAPP X287_S15K5288A15 NA00 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg9: scsi6 channel=0 id=8 lun=0
NETAPP X287_S15K5288A15 NA00 [rmb=0 cmdq=1 pqual=0 pdev=0x0]

Now you should format the offending drive using the "sg_format" command.
[root@azev /]# sg_format --format --size=512 /dev/sg8

NETAPP X287_S15K5288A15 NA00 peripheral_type: disk [0x0]
Mode Sense (block descriptor) data, prior to changes:
Number of blocks=573653847 [0x22314357]
Block size=520 [0x208]

A FORMAT will commence in 10 seconds
ALL data on /dev/sg8 will be DESTROYED
Press control-C to abort

It is pretty simple, and after the format is completed, you should have no problem initializing the drive. However, some drives require a powercycle before successful usage.

Some people argue that the custom firmware on the drive is set to work with sector size 520B or 528B, but during my benchmark, the drive performance was pretty much on par with the normal retail channel.

Hopefully you find this information useful next time you come across a drive with other than 512B sector size.