21 March 2021

Reformatting 520B sector size EMC drives

For my new VM server I acquired a couple of 100GB retired EMC SSDs. These are formatted with 520byte sectors, and are not usable in most normal hardware without reformatting them.

OS Detection

Whether these will actually show up depends on the SAS controller, in my Dell/Lenovo x3650 M4 they were found by the onboard RAID controller, but did not show up in the OS (Proxmox) in any way.

On another machine, also running Proxmox, with an LSI2008 based HBA this showed up in the logs:

[919353.253564] scsi 7:0:4:0: Direct-Access     SAMSUNG  SS162511 CLAR100 DC0D PQ: 0 ANSI: 6
[919353.253573] scsi 7:0:4:0: SSP: handle(0x000d), sas_addr(0x5002538453b04ee2), phy(16), device_name(0x5002538453b04ee1)
[919353.253575] scsi 7:0:4:0: enclosure logical id (0x500304800024fdbf), slot(4)
[919353.253577] scsi 7:0:4:0: qdepth(254), tagged(1), scsi_level(7), cmd_que(1)
[919353.253896] scsi 7:0:4:0: Power-on or device reset occurred
[919353.261531] sd 7:0:4:0: Attached scsi generic sg22 type 0
[919353.262333] sd 7:0:4:0: [sdu] Spinning up disk...
[919353.262957]  end_device-7:0:4: add: handle(0x000d), sas_addr(0x5002538453b04ee2)
[919354.285403] .ready
[919354.285755] sd 7:0:4:0: [sdu] Unsupported sector size 520.
[919354.289912] sd 7:0:4:0: [sdu] 0 512-byte logical blocks: (0 B/0 B)
[919354.289913] sd 7:0:4:0: [sdu] 8320-byte physical blocks
[919354.295266] sd 7:0:4:0: [sdu] Write Protect is off
[919354.295268] sd 7:0:4:0: [sdu] Mode Sense: b7 00 10 08
[919354.296247] sd 7:0:4:0: [sdu] Write cache: enabled, read cache: enabled, supports DPO and FUA
[919354.322140] sd 7:0:4:0: [sdu] Unsupported sector size 520.
[919354.331985] sd 7:0:4:0: [sdu] Attached SCSI disk

Reformat to 512byte blocks

To be able to use these drives they need to be reformatted to a usable block size, namely a multiple of 512 bytes.

Note that this resets some of the SMART information.

  1. Install sg3 utils:
apt-install sg3-utils
  1. Find our device's sg device
# sg_scan -i
...
/dev/sg22: scsi7 channel=0 id=5 lun=0
    SAMSUNG   SS162511 CLAR100  DC0D [rmb=0 cmdq=1 pqual=0 pdev=0x0]
  1. Verify the block size of said device
# sg_readcap /dev/sg22
Read Capacity results:
   Last LBA=192365851 (0xb77451b), Number of logical blocks=192365852
   Logical block length=520 bytes
Hence:
   Device size: 100030243040 bytes, 95396.3 MiB, 100.03 GB
  1. Reformat
sg_format --format --size=512 /dev/sg22
    SAMSUNG   SS162511 CLAR100  DC0D   peripheral_type: disk [0x0]
      << supports protection information>>
      Unit serial number: 10NEADB00535
      LU name: 5002538453b03a10
Mode Sense (block descriptor) data, prior to changes:
  Number of blocks=192365852 [0xb77451c]
  Block size=520 [0x208]

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

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

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

Format unit has started
Format in progress, 58.43% done
FORMAT UNIT Complete
  1. Verify block size has been successfully changed
# sg_readcap /dev/sg22
Read Capacity results:
   Last LBA=195371567 (0xba5222f), Number of logical blocks=195371568
   Logical block length=512 bytes
Hence:
   Device size: 100030242816 bytes, 95396.3 MiB, 100.03 GB

ZFS block size issue

Installing Proxmox on these resulted in this zpool output:

root@vanagloria:~# zpool status
  pool: rpool
 state: ONLINE
status: One or more devices are configured to use a non-native block size.
        Expect reduced performance.
action: Replace affected devices with devices that support the
        configured block size, or migrate data to a properly configured
        pool.
config:

        NAME                              STATE     READ WRITE CKSUM
        rpool                             ONLINE       0     0     0
          mirror-0                        ONLINE       0     0     0
            scsi-35002538453b04ee0-part3  ONLINE       0     0     0  block size: 4096B configured, 8192B native
            scsi-35002538453b03a10-part3  ONLINE       0     0     0  block size: 4096B configured, 8192B native

errors: No known data errors

smartctl confirms this SSD does indeed use 8k sectors:

root@vanagloria:~# smartctl -a /dev/sda
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.4.103-1-pve] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               SAMSUNG
Product:              SS162511 CLAR100
Revision:             DC0D
Compliance:           SPC-4
User Capacity:        100,030,242,816 bytes [100 GB]
Logical block size:   512 bytes
Physical block size:  8192 bytes
LU is resource provisioned, LBPRZ=1
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      0x5002538453b04ee0
Serial number:        10NEADB00868
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Thu Mar 18 16:56:23 2021 CET
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled

ZFS is supposed to automatically detect the correct ashift to use, so either that mechanism failed in this instance, or Proxmox blindly sets asfhif=12, whereas in this case it should have been ashift=13. In either case, reinstalling and manually setting ashift to 13 fixes this issue.

References

Tags: hardware GNU/Linux