Advance reformat 4Kn HDD to 512 Bytes

4Kn HDD to 512 Bytes sectora

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ smartctl -a -d scsi /dev/sdd
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.30.3.el6_lustre.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

Vendor: HGST
Product: HUH728080AL4200
Revision: A7J0
User Capacity: 8,001,563,222,016 bytes [8.00 TB]
Logical block size: 4096 bytes

$ smartctl -a -d scsi /dev/sdc
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-504.30.3.el6_lustre.x86_64] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

Vendor: HGST
Product: HUH728080AL4200
Revision: A7J0
User Capacity: 8,001,563,222,016 bytes [8.00 TB]
Logical block size: 512 bytes

sg3_utils format

Update: If you have a lot of drives to format, it may take a long time with sg_format as it wait until it finished before doing the next one (with a while loop I mean). Useful tip is to use the “-e” flag with sg_format then monitor operations with sg_turs -p but it may hang you tty as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ sg_format --format --size=512 /dev/sdc
HGST HUH728080AL4200 A7J0 peripheral_type: disk [0x0]
<< supports protection information>>
Mode Sense (block descriptor) data, prior to changes:
Number of blocks=1953506646 [0x74702556]
Block size=4096 [0x1000]

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

Format has started
FORMAT Complete

It ‘s not complete, just backend operate
sdparm ,smartctl, /sys could not access the device, when format complete, it’s ok.

Read cap

1
2
3
4
5
6
7
8
9
10
$ sg_readcap -l /dev/sdc
Read Capacity results:
Protection: prot_en=0, p_type=0, p_i_exponent=0
Thin provisioning: tpe=0, tprz=0
Last logical block address=15628053167 (0x3a3812aaf), Number of logical blocks=15628053168
Logical block length=512 bytes
Logical blocks per physical block exponent=3
Lowest aligned logical block address=0
Hence:
Device size: 8001563222016 bytes, 7630885.3 MiB, 8001.56 GB

Get HDD status

1
2
3
4
5
6
sg_turs -v /dev/sdb
test unit ready cdb: 00 00 00 00 00 00
test unit ready: Descriptor format, current; Sense key: Not Ready Additional sense: Logical unit not ready, format in progress
Descriptor type: Information 00 00 00 00 00 00 00 00 00 00
Descriptor type: Command specific 0x0000000000000000
device not ready

After 18 hours, format finish , I ‘m not sure what time it complete.

1
2
3
4
5
$ cat /sys/class/block/sdc/queue/hw_sector_size 
512

$ cat /sys/class/block/sdd/queue/hw_sector_size
4096

Security erasing SAS/SATA SSD

1
sg_format --format /dev/sdx
1
hdparm --user-master u --security-set-pass password /dev/sdx