How to reformat HDD & SSD to 512B Sector Size

tomaash

Active Member
Oct 11, 2016
108
50
28
Europe, Slovakia
Today I bought HP 3PAR/SanDisk SAS 1.92TB SSD with 520b sector size. I only have HP Smart Array controllers, so I set my P222 into HBA mode. At first I was getting this:

C:\sg3>sg_format --format --size=512 -v pd1
SanDisk DOPE1920S5xnNMRI 3P01 peripheral_type: disk [0x0]
PROTECT=1
<< supports protection information>>
Unit serial number: xxx
LU name: 500117310013ac9c
mode sense (10) cdb: 5a 00 01 00 00 00 00 00 fc 00
Mode Sense (block descriptor) data, prior to changes:
Number of blocks=3750748848 [0xdf8fe2b0]
Block size=520 [0x208]
mode select (10) cdb: 55 11 00 00 00 00 00 00 1a 00
mode select (10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Parameter list length error
Sense Key Specific: Error in Data parameters: byte 0
MODE SELECT command: Illegal request sense key, apart from Invalid opcode

Which didn't look good. However, after looking at command line options a bit:
--six|-6 use 6 byte MODE SENSE/SELECT to probe disk
(def: use 10 byte MODE SENSE/SELECT)

C:\sg3>sg_format --format --size=512 --six -v pd1
SanDisk DOPE1920S5xnNMRI 3P01 peripheral_type: disk [0x0]
PROTECT=1
<< supports protection information>>
Unit serial number: xxx
LU name: 500117310013ac9c
mode sense (6) cdb: 1a 00 01 00 fc 00
Mode Sense (block descriptor) data, prior to changes:
Number of blocks=3750748848 [0xdf8fe2b0]
Block size=520 [0x208]
mode select (6) cdb: 15 11 00 00 18 00

A FORMAT UNIT will commence in 15 seconds
ALL data on pd1 will be DESTROYED
Press control-C to abort

A FORMAT UNIT will commence in 10 seconds
ALL data on pd1 will be DESTROYED
Press control-C to abort

A FORMAT UNIT will commence in 5 seconds
ALL data on pd1 will be DESTROYED
Press control-C to abort
format unit cdb: 04 18 00 00 00 00

Format unit has started
Format in progress, 39.08% done
Format in progress, 81.75% done
FORMAT UNIT Complete

So... I now have nice 1.92TB for oh so cheap.

Anyway:
1. It's possible to reformat drives with recent HP SmartArray in HBA mode.
2. There's this SIX option to use in case drive cannot be formatted with default 10 byte MODE SENSE/SELECT
 

jopi

New Member
Aug 22, 2016
4
0
1
65
What is actual part number of your 2TB SSDs? I'd be interested in getting couple of those. Regardless if I'd need them to reformat to 512B/sector before I could use them.
 

jopi

New Member
Aug 22, 2016
4
0
1
65
@T_Minus
You are right, I overlooked it. On the other hand I'm bit amazed. None of the HP (non SSD) SAS drives, I ever had, was formatted with 520Bps. Those were all EMC yet.
 

alyin

New Member
Dec 7, 2016
3
0
1
58
Help needed:
I have a lot of Hitachi sas 300gb 10k 2.5" Model: DKR5C-J30SS P/N: 0B25660 CONFIG CODE: 105
I have successfully reformatted it to 512b by sg3 utility, but windows disk manager still can't create partition on it, it reported " disk I/O error"
Could it be the firmware caused the problem?
Anyone has a solution for it?
Reward provided if anyone could help me to solve this problem.
TIA.
 

Aestr

Well-Known Member
Oct 22, 2014
933
330
63
Los Angeles
Question for those who have used sg_format before. I've been reformatting a bunch of disks from 520 to 512 and so far it's been good. Now I've hit a disk where the percent hasn't changed in a long time. The updates keep scrolling, but the percent done stays the same. Is this something others have seen? If so did it eventually complete, was something else required or was the disk bad? I don't want to kill the command for fear it leaves the disk in a bad state.

Any insight would be greatly appreciated.
 

sno.cn

Active Member
Sep 23, 2016
207
73
28
I just received some used HGST SSD400M drives, and two of them turned out to be HP OEM, going by the model number HUSML4040ASS600 vs HUSML4040ASS601.

This thread surely saved me a ton of frustration! sg_format got one drive working so far, and is busy working on the second :D
 

Pete Kokkinis

New Member
Mar 9, 2017
1
0
1
48
I’ve read through these 4 pages about 20 times. Here’s my experience:
I purchased a few of the Hitachi HUS156060VLS600 formatted for NetApp with a 520 sector size. I had a Dell 2950 rack server in my lab with a Perc 6i Raid controller. While I could see the drives in Ctrl-R, I couldn’t do anything with them – no hot spare, no raid, nothing. I purchased a Dell H310 off ebay and had to flash it to be able to do anything with the drives. Before flashing, it would behave just like the embedded raid 6i raid controller. Here’s how I flashed the H310:

1) Create a USB boot disk (I used Rufus, Fat32, FreeDOS).
2) Download this zip file: www.hercnetworks.com/Misc/LSI-9211-8i.zip
3) Extract and place on boot disk (I created a folder called LSI for it on my boot disk)
4) Boot using boot disk, change dir to LSI and run:
megarec -writesbr 0 sbrempty.bin
megarec -cleanflash 0

5) Reboot. Enter boot disk again.
6) Change to LSI folder again and run:
Sas2flsh -o 6gbpsas.fw

That’s it! Reboot. I had windows installed on a disk connected directly to the motherboard. Download the SG3 utilities from http://sg.danny.cz/sg/p/sg3_utils-1.42_mw64exe.zip and extract to a folder on your C drive (I did SG3). Run an admin command prompt, change to SG3, then run:
sg_scan
You should see your drives listed as pd0, pd1, pd2, etc.
Be sure you know which drive number you want to format and run:
sg_format --format --size=512 -v pd1
if that spits out an error, try:
sg_format --format --size=512 –-six -v pd1
 
Last edited:

ceorl yip

New Member
May 4, 2017
8
0
1
Hi Pete, I too have a PE2950 with perc6i; i am having trouble getting sg_scan to list the drive. So the only way is to install the h310 controller? (did you replace the perc 6i or installed the h310 adapter version?)

I am trying to format bunch of hitachi netapp...
Using CentOS7 Live usb; but the drives aren't showing up...

Thanks.

I’ve read through these 4 pages about 20 times. Here’s my experience:
I purchased a few of the Hitachi HUS156060VLS600 formatted for NetApp with a 520 sector size. I had a Dell 2950 rack server in my lab with a Perc 6i Raid controller. While I could see the drives in Ctrl-R, I couldn’t do anything with them – no hot spare, no raid, nothing. I purchased a Dell H310 off ebay and had to flash it to be able to do anything with the drives. Before flashing, it would behave just like the embedded raid 6i raid controller. Here’s how I flashed the H310:

1) Create a USB boot disk (I used Rufus, Fat32, FreeDOS).
2) Download this zip file: www.hercnetworks.com/Misc/LSI-9211-8i.zip
3) Extract and place on boot disk (I created a folder called LSI for it on my boot disk)
4) Boot using boot disk, change dir to LSI and run:
megarec -writesbr 0 sbrempty.bin
megarec -cleanflash 0

5) Reboot. Enter boot disk again.
6) Change to LSI folder again and run:
Sas2flsh -o 6gbpsas.fw

That’s it! Reboot. I had windows installed on a disk connected directly to the motherboard. Download the SG3 utilities from http://sg.danny.cz/sg/p/sg3_utils-1.42_mw64exe.zip and extract to a folder on your C drive (I did SG3). Run an admin command prompt, change to SG3, then run:
sg_scan
You should see your drives listed as pd0, pd1, pd2, etc.
Be sure you know which drive number you want to format and run:
sg_format --format --size=512 -v pd1
if that spits out an error, try:
sg_format --format --size=512 –-six -v pd1
 

Andres Biront

New Member
May 29, 2017
2
0
1
35
I'm also having problems reformating Samsung SSDs (100GB SATA2 SSD).
I think they were in use in a NetApp storage.

I've used sg_utils and camcontrol (on FreeBSD) before, to set 512 bytes/sectors and reformat SAS HDDs. I think the problem is that the Samsung SSDs are SATA (ATAPI commands) and not SAS (SCSI commands).

When using camcontrol If I request modepage 0x03 the SSD replies "sectors = 512". Similar to what sg_format says, "Block size=512 [0x200]" but 520 logical.

This is not true. If you inquiry the disk with camcontrol inquiry or with diskinfo the SSD clearly says it's 520 bytes physical and 520 bytes logical.

To sum up:

SAS disk on SAS controller = OK to reformat.
SATA disk on SAS controller = FAILS.

sg_utils and camcontrol uses SCSI commands. How can we resize the physical blocks? I think we need an ATA tool.
 

KenBob25

New Member
Jun 14, 2017
2
0
1
69
This has worked so well for me up until today. The drives I am trying to resize provide the following message:

[root@localhost ~]# sg_format --format /dev/sg3
NETAPP X414_S15K7560A15 NA08 peripheral_type: disk [0x0]
Mode Sense (block descriptor) data, prior to changes:
Number of blocks=0 [0x0]
Block size=520 [0x208]

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

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

format unit: Fixed format, current; Sense key: Data Protect

Additional sense: Access denied - no access rights

Format command failed
FORMAT failed
try '-v' for more information
[root@localhost ~]# -v /dev/sg3

Does anyone know how to gain "access rights" to the NetApp drive so the sectors can be resized?
 

KenBob25

New Member
Jun 14, 2017
2
0
1
69
The results of sanitize


[root@localhost ~]# sg_scan -i
/dev/sg0: scsi5 channel=0 id=0 lun=0 [em]
HL-DT-ST DVDRAM GH24NSC0 LI00 [rmb=1 cmdq=0 pqual=0 pdev=0x5]
/dev/sg1: scsi6 channel=0 id=0 lun=0 [em]
TSSTcorp CDDVDW SH-S203N SB01 [rmb=1 cmdq=0 pqual=0 pdev=0x5]
/dev/sg2: scsi0 channel=0 id=0 lun=0
ATA ST3250318AS CC44 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg3: scsi0 channel=0 id=1 lun=0
NETAPP X414_S15K7560A15 NA08 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
[root@localhost ~]# sg_sanitize -B /dev/sg3
NETAPP X414_S15K7560A15 NA08 peripheral_type: disk [0x0]

A SANITIZE will commence in 15 seconds
ALL data on /dev/sg3 will be DESTROYED
Press control-C to abort

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

A SANITIZE will commence in 5 seconds
ALL data on /dev/sg3 will be DESTROYED
Press control-C to abort
Sanitize: Fixed format, current; Sense key: Medium Error
Additional sense: Medium format corrupted
Sanitize command reported medium or hardware error
[root@localhost ~]# ^C
[root@localhost ~]#


Unsure what this means.
 

mstrzyze

Member
Nov 9, 2015
40
16
8
45
Anyone is doing reverse? Loading netapp fw on ordinary devicd
I got a lot of hdd / ssd and would like to use that I netapp..

Thx
 

rune-san

Member
Feb 7, 2014
78
15
8
I'll just note what I noted from the Hitachi 100GB SSD Deal Thread:

I got an HP Spare with almost no wear (1.3TB write, 4TB read). That stated, because it was an HP spare, it had 520 byte sectors, not 512. I followed the sg_utils post on How to reformat HDD & SSD to 512B Sector Size to get it back to 512. Then I noticed that it was a reported 4K Sector size, so I thought "why not" and used sg_utils to put it to 4096. Well it didn't like that. I couldn't write anything to it because it would announce an alignment issue in linux. So I put it back to 512. Now it works, and works *great*. About 520MB/s read / write with almost any size file. But, one thing I noticed is that the drive is now showing much fewer sectors, like I've essentially short-stroked it.

Total disk size is 1946 cylinders

Cylinder size is 12544 (512 byte) blocks


Cylinders

Partition Status Type Start End Length %

========= ====== ============ ===== === ====== ===

1 EFI 0 1946 1947 100

In my brilliance, I didn't check to see what the number of cylinders was before. As such my 100GB drive is now as 12GB drive. Formatting didn't change that. I figure there's an academic thing I need to do to fix it, but I'm not terribly sure what :) Perhaps that odd sectoring is why formatting it straight as 4K didn't work (then again, it might have to be 512 byte sectors. It is an old 3PAR SSD after all).

I figure I'd post this here for others getting ready to deal with the SSDs, and if they know a way to fix the above, that'd be great too. I'm using it as a ZIL, so I don't really care about the size, but I want to do a couple more of these, and it'd be nice to have them all the same size :D

EDIT:

In case anyone sees this later, I wanted to add my own resolution. After I got 3 more of the SSDs (which turned out to be untouched Hitachi SSDs, not 3PARs, and therefore were standard 512 byte drives), I took down the SAN to experiment a bit more. I looked at a copy of the man page for sg_format at sg_format(8): format/resize SCSI disk - Linux man page and found that a resize with a count of -1 will resize the drive to its maximum block count given the currently set block size. In this case, I ran the following (the drive was sde at the time):

Code:
sg_format --resize --count=-1 /dev/sde
The drive was then extended back to the maximum block count of 195371568 512 byte sectors. Running a standard format afterwards cleaned up the drive and it was ready to go again:

Code:
sg_format --format /dev/sde
At that point the drive completely matched the 3 other non-3PAR Hitachi SSDs I received.
 
Last edited:

Servoids

New Member
Jun 26, 2017
6
0
1
41
Hi
Anybody can help with reformatting to 512b

when disk was connected to DELL PERC H310
sg_scan -i
doesnt show the drive
but at least its possible to see some SMART details

/bin/megacli -PDList -AALL | grep -B 23 -A 22 -i XTVKH0SA
Enclosure Device ID: 32
Slot Number: 2
Enclosure position: 1
Device Id: 2
WWN: 5000CCA0131FCAD7
Sequence Number: 13
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 183.444 GB [0x16ee38cd Sectors]
Non Coerced Size: 182.944 GB [0x16de38cd Sectors]
Coerced Size: 182.875 GB [0x16dc0000 Sectors]
Sector Size: 0
Firmware state: Unconfigured(good), Spun Up
Device Firmware Level: C140
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x5000cca0131fcad5
SAS Address(1): 0x0
Connected Port Number: 2(path0)
Inquiry Data: HITACHI HUSRL402 CLAR200C140XTVKH0SA
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Solid State Device
Drive: Not Supported
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Port-1 :
Port status: Active
Port's Linkspeed: Unknown
Drive has flagged a S.M.A.R.T alert : No


After that disk were connected to h730 at hba mode

and sg scan detect it like dell backpane
% sg_scan -i
/dev/sg0: scsi10 channel=0 id=0 lun=0
ATA ST1000NM0033-9ZM GA0A [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg1: scsi10 channel=0 id=1 lun=0
ATA ST1000NM0033-9ZM GA0A [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg2: scsi10 channel=0 id=2 lun=0
ATA ST1000NM0033-9ZM GA0A [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg3: scsi10 channel=0 id=3 lun=0
ATA ST1000NM0011 PA07 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg4: scsi10 channel=0 id=4 lun=0
SEAGATE ST3300657SS ES64 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg5: scsi10 channel=0 id=5 lun=0
SEAGATE ST3300657SS ES64 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
/dev/sg6: scsi10 channel=0 id=6 lun=0
SEAGATE ST3300657SS ES65 [rmb=0 cmdq=1 pqual=0 pdev=0x0]

/dev/sg7: scsi10 channel=0 id=32 lun=0
DP BP13G+ 2.25 [rmb=0 cmdq=0 pqual=0 pdev=0xd]


And its not possible to check disk details


% smartctl -a /dev/sg7
smartctl 6.3 2014-07-26 r3976 [x86_64-linux-3.14.43-std453-amd64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor: DP
Product: BP13G+
Revision: 2.25
User Capacity: 223,222,599,602,106,368 bytes [223 PB]
Logical block size: 1023463424 bytes
scsiModePageOffset: response length too short, resp_len=14 offset=22 bd_len=18
scsiModePageOffset: response length too short, resp_len=14 offset=22 bd_len=18


Is there any solution ?)

Thank you

 

Necrotyr

Active Member
Jun 25, 2017
179
47
28
Denmark
First of all, thank you for the guide.

I recently got two Hitachi 600GB disks that apparently only work in hitachi storage systems.

I've reformatted the drives and things went as they should, controllers see the drives and can make arrays on them.

But the second they start writing to them they go into fault mode, it doesn't matter if I use a HP or Dell controller, they wont play nice.

Any ideas?
 

Jeff504

New Member
Jul 31, 2017
3
0
1
30
Ok guys, so I have a Dell R610 with the PERC H700 Controller. I have 3 NetApp 450gb drives that need to be formatted. So I loaded CentOS 6 Live onto a flash drive and ran the sg3 commands. Whenever I get to the "sg_scan -i" command, it lists a DVD drive, the bootable USB, and the H700 controller but not the drives. I cannot for the life of me get the drives to show up under this list to be able to format them. Can anyone provide any insight on this issue?
 

Terry Kennedy

Well-Known Member
Jun 25, 2015
1,081
528
113
New York City
www.glaver.org
I cannot for the life of me get the drives to show up under this list to be able to format them. Can anyone provide any insight on this issue?
The PERC H700 is a RAID controller and doesn't provide a full passthru interface for sg3_utils. You will need to attach the drives to a non-RAID controller (in LSI speak, "IT mode"). This can be a bit of a pain in an Rx10 as the H700 is in a dedicated slot that complains about non-Dell cards, and the backplane cables aren't long enough to reach the regular expansion slot area where you'd temporarily install an IT-mode controller.