Joni Junni

Disabling Type 2 Protection in SAS HDDs

Tale of the ill-behaving ZFS...

Categories: [blog]
Tags: [sg_utils], [SAS], [HDD], [howto], [storage], [NAS]

Sometimes old enterprise SAS disks come with Type 1 or 2 Protection enabled. This is based on T10 Data Protection Information specification, which aims to ensure end-to-end-data integrity for data storage by using different (520 byte) block size where the disk controller can use the extra bytes for parity checking etc. In some cases this configuration can result problems with software RAID setups, like ZFS.

To disable Type 2 Protection in modern SAS hard disks, you can use sg3_utils-package found in most Linux distributions.

Disclaimer: This procedure will DESTROY all data on the disk. Using these commands can make your disk unusable. Use on your own risk! You have been warned.

You can use sg_readcap command to check if you have the protection feature on:

root@parzival ~]# sg_readcap /dev/sdYOURDISK
READ CAPACITY (10) indicates device capacity too large
  now trying 16 byte cdb variant
Read Capacity results:
   Protection: prot_en=1, p_type=1, p_i_exponent=0 [type 2 protection]
   Logical block provisioning: lbpme=0, lbprz=0
   Last LBA=22961717247 (0x5589fffff), Number of logical blocks=22961717248
   Logical block length=512 bytes
   Logical blocks per physical block exponent=3 [so physical block length=4096 bytes]
   Lowest aligned LBA=0
Hence:
   Device size: 11756399230976 bytes, 11211776.0 MiB, 11756.40 GB, 11.76 TB

So here we can see that [type 2 protection] is mentioned in the command output, which indicates that the Type 2 protection is currently enabled.

Disabling Type 2 protection

So how we can disable it? With sg_format command. This will send a FORMAT UNIT command the controller on the hard disk itself, which will start a low-level formatting process to change the layout on the disk. Note: This will take a loong time to complete depending on hard disk size and it will delete all data on the disk. You have been warned.

The command:

sg_format -F -f 0 -v /dev/sdYOURDISK

Where the arguments I’m using are:

You can find more in-depth command definitions in the sg_format man page.

[root@parzival ~]# sg_format -F -f 0 -v /dev/sdYOURDISK
    SEAGATE   ST12000NM0158     RSL5   peripheral_type: disk [0x0]
      PROTECT=1
      << supports protection information>>
      Unit serial number: MAG1CA7
      LU name: 5000c
    mode sense(10) cdb: [5a 00 01 00 00 00 00 00 fc 00]
Mode Sense (block descriptor) data, prior to changes:
block count maxed out, set <<longlba>>
    mode sense(10) cdb: [5a 10 01 00 00 00 00 00 fc 00]
  <<< longlba flag set (64 bit lba) >>>
  Number of blocks=23081319440 [0x55fc0fc10]
  Block size=512 [0x200]

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

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

A FORMAT UNIT will commence in 5 seconds
    ALL data on /dev/sdYOURDISK will be DESTROYED
        Press control-C to abort
    Format unit cdb: [04 18 00 00 00 00]
Format unit command launched without error

After the command was run successfully, it will print out the status info every few seconds. You can Ctrl-C out of the command if you like, it will continue the format in the background. You can check the status of the formatting with sg_requests:

[root@parzival ~]# sg_requests /dev/sdYOURDISK
data-in decoded as sense:
Fixed format, current; Sense key: Not Ready
Additional sense: Logical unit not ready, format in progress
  Progress indication: 0.37%

Number of data-in errors detected: 1, most recent sense_key=2

Sources

« Previous