1
I have Linux Mint 17.3 (based on Ubuntu 14.04) with 4.4.0 kernel. I own a Western Digital Caviar Green WD10EARX hard drive with 1TB capacity. The label on this drive says it is an "Advanced Format" drive. Please note that no jumper is set, so no "compatibility"/"emulation" jumper is set.
I read about Advanced Format drives and their 4k sector size (instead of the standard 512 byte one), but what I can't explain is the different behaviour I see whenever I connect this drive with different USB enclosures or docking stations.
Example 1: Sunplus USB 2 docking station
lsusb -v shows:
Bus 003 Device 013: ID 1bcf:0c31 Sunplus Innovation Technology Inc. SPIF30x Serial-ATA bridge
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1bcf Sunplus Innovation Technology Inc.
idProduct 0x0c31 SPIF30x Serial-ATA bridge
bcdDevice 1.32
iManufacturer 1 Sunplus Innovation Technology
iProduct 2 USB to Serial-ATA bridge
iSerial 3 <removed>
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 Bulk Only Configuration
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 5 Bulk Only Interface
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0001
Self Powered
fdisk -l shows:
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 testine, 63 settori/tracce, 121601 cilindri, totale 1953525168 settori
Unità = settori di 1 * 512 = 512 byte
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Identificativo disco: 0x0001cf00
Dispositivo Boot Start End Blocks Id System
/dev/sdb1 8040 498023 244992 fd Autorilevamento raid di Linux
/dev/sdb2 498024 562271 32124 fd Autorilevamento raid di Linux
/dev/sdb3 562272 809271 123500 fd Autorilevamento raid di Linux
/dev/sdb4 809272 244187999 121689364 fd Autorilevamento raid di Linux
hdparm -I shows:
ATA device, with non-removable media
Model Number: WDC WD10EARX-00N0YB0
Serial Number: <removed>
Firmware Revision: 51.0AB51
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 1953525168
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
Logical Sector-0 offset: 0 bytes
device size with M = 1024*1024: 953869 MBytes
device size with M = 1000*1000: 1000204 MBytes (1000 GB)
cache/buffer size = unknown
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
DMA Setup Auto-Activate optimization
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[7]
unknown 206[12] (vendor specific)
unknown 206[13] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
186min for SECURITY ERASE UNIT. 186min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 50014ee2b14805a5
NAA : 5
IEEE OUI : 0014ee
Unique ID : 2b14805a5
Checksum: correct
And if I cat /sys/class/block/sdb/queue/physical_block_size
and /sys/class/block/sdb/queue/logical_block_size
they both say 512.
So, when connecting the hard disk to this docking station, it seems like it's a normal 512-byte sector drive.
Example 2: USB 2 enclosure with JMicron USB to SATA & PATA Combo Bridge
When connecting the drive to this enclosure, I see a completely different story.
lsusb -v shows:
Bus 003 Device 014: ID 152d:2338 JMicron Technology Corp. / JMicron USA Technology Corp. JM20337 Hi-Speed USB to SATA & PATA Combo Bridge
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x152d JMicron Technology Corp. / JMicron USA Technology Corp.
idProduct 0x2338 JM20337 Hi-Speed USB to SATA & PATA Combo Bridge
bcdDevice 1.00
iManufacturer 1 JMicron
iProduct 2 USB to ATA/ATAPI bridge
iSerial 5 <removed>
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB Mass Storage
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 6 MSC Bulk-Only Transfer
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0001
Self Powered
fdisk -l shows:
Nota: la dimensione del settore è 4096 (non 512)
(in English: Note: the sector size is 4096 (not 512)
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 testine, 63 settori/tracce, 15200 cilindri, totale 244190646 settori
Unità = settori di 1 * 4096 = 4096 byte
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Identificativo disco: 0x0001cf00
Dispositivo Boot Start End Blocks Id System
/dev/sdb1 8040 498023 1959936 fd Autorilevamento raid di Linux
/dev/sdb2 498024 562271 256992 fd Autorilevamento raid di Linux
/dev/sdb3 562272 809271 988000 fd Autorilevamento raid di Linux
/dev/sdb4 809272 244187999 973514912 fd Autorilevamento raid di Linux
hdparm produces some sort of corrupted result:
ATA device, with non-removable media
Model Number: �����������@������������
Serial Number: ������������
Firmware Revision: �����
Standards:
Used: unknown (minor revision code 0x10fd)
Supported: 14 11 10
Likely used: 14
Configuration:
Logical max current
cylinders 0 0
heads 0 0
sectors/track 510 0
--
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 0 MBytes
device size with M = 1000*1000: 0 MBytes
cache/buffer size = unknown
Capabilities:
IORDY(may be)(cannot be disabled)
Queue depth: 32
Standby timer values: spec'd by Vendor
R/W multiple sector transfer: Max = 255 Current = 255
Recommended acoustic management value: 234, current value: 0
DMA: not supported
PIO: unknown
Cycle time: no flow control=65535ns IORDY flow control=24384ns
* reserved 69[0]
* reserved 69[1]
* reserved 69[2]
* reserved 69[4]
* reserved 69[7]
* DEVICE CONFIGURATION SET/IDENTIFY DMA commands
Security:
Master password revision code = 19648
not supported
not enabled
not locked
not frozen
not expired: security count
not supported: enhanced erase
Integrity word not set (found 0x0000, expected 0x9fa5)
If I cat /sys/class/block/sdb/queue/physical_block_size
and /sys/class/block/sdb/queue/logical_block_size
they both say 4096.
So, it seems like this enclosure uses the disk with 4k sector sizes, so as a "native" 4k Advanced Format drive. If I were to stop here, I would say that the other docking station is just "too old" to properly support 4k drives. However, what surprises me is the following.
Example 3: JMicron USB 3 docking station
When I connect this drive to a much more recent USB 3 docking station, with UASP support, I get results much more similar to the first docking station.
lsusb -v shows:
Bus 004 Device 006: ID 152d:0565 JMicron Technology Corp. / JMicron USA Technology Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 9
idVendor 0x152d JMicron Technology Corp. / JMicron USA Technology Corp.
idProduct 0x0565
bcdDevice 1.01
iManufacturer 1 JMicron
iProduct 2 JMS56x Series
iSerial 5 <removed>
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 121
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB Mass Storage
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 6 MSC Bulk-Only Transfer
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 1
bNumEndpoints 4
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 98
iInterface 10 MSC BOT/UAS Transfer
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Command pipe (0x01)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
MaxStreams 32
Status pipe (0x02)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
MaxStreams 32
Data-in pipe (0x03)
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
MaxStreams 32
Data-out pipe (0x04)
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000f0e
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 32 micro seconds
Device Status: 0x000d
Self Powered
U1 Enabled
U2 Enabled
fdisk -l shows:
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 testine, 63 settori/tracce, 121601 cilindri, totale 1953525168 settori
Unità = settori di 1 * 512 = 512 byte
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Identificativo disco: 0x0001cf00
Dispositivo Boot Start End Blocks Id System
/dev/sdb1 8040 498023 244992 fd Autorilevamento raid di Linux
/dev/sdb2 498024 562271 32124 fd Autorilevamento raid di Linux
/dev/sdb3 562272 809271 123500 fd Autorilevamento raid di Linux
/dev/sdb4 809272 244187999 121689364 fd Autorilevamento raid di Linux
hdparm -I shows:
ATA device, with non-removable media
Model Number: WDC WD10EARX-00N0YB0
Serial Number: <removed>
Firmware Revision: 51.0AB51
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 1953525168
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
Logical Sector-0 offset: 0 bytes
device size with M = 1024*1024: 953869 MBytes
device size with M = 1000*1000: 1000204 MBytes (1000 GB)
cache/buffer size = unknown
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
DMA Setup Auto-Activate optimization
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[7]
unknown 206[12] (vendor specific)
unknown 206[13] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
186min for SECURITY ERASE UNIT. 186min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 50014ee2b14805a5
NAA : 5
IEEE OUI : 0014ee
Unique ID : 2b14805a5
Checksum: correct
If I cat /sys/class/block/sdb/queue/physical_block_size
and /sys/class/block/sdb/queue/logical_block_size
they both say 512.
So, with this docking station, I again see the drive as a "normal" 512-byte sector drive.
Questions
- why hdparm is saying something different than fdisk and
/sys/class/block/sdb/queue/physical_block_size
+/sys/class/block/sdb/queue/logical_block_size
with both docking stations? hdparm is saying that the physical sector size is 4096, while the other say the physical sector size is 512 (like the logical one) - how is it possible that a very recent (bought in 2018) USB 3 docking station with a JMicron bridge supporting the newest UASP protocol is not seeing the drive as a 4k one, while a much older USB 2 SATA+PATA Bridge by JMicron too does? Is this an issue at all if I were starting to use this hard disk with these docking stations from scratch now?
- as you can see, partitions on that drive are RAID members (RAID1); the partition table and RAID array was created when the disk was used with the JMicron SATA+PATA enclosure. Whenever I try to start the RAID arrays with this enclosure, I have no problems and I can read the contents on the disk; whenever I try to do the same with both docking stations, I get a "no superblock found error", so the array does not start and I cannot read the disk contents; this scares me a bit, because I fear I won't able to read the contents of that disk back if the enclosure one day fails
To overcome problem 3. I remember I could dd the partition of interest even when using the first docking station, by playing with block starts and sector size, so I could get an image on file which I could mount as a loopback device and get the original contents back, however I was wondering whether there's a simpler solution that doesn't force me to create an image of the whole disk.
This is very similar to this question: https://unix.stackexchange.com/questions/403919/harddrive-with-4096-physical-sector-size-reported-as-512-behind-usb-bridge The answers here might help clear up the confusion ( or maybe make you more confused ;] )
– Layne Bernardo – 2018-10-29T22:04:58.327USB enclosures aren't all created equal, sounds like you just found some duds – Xen2050 – 2018-10-30T01:45:27.033
@LayneBernardo thanks Layne, I just pinged the author of that question to see if he discovered something more. – Mauro Molinari – 2018-10-30T08:22:12.167
@MauroMolinari I didn't. (I'm not the question author, it's not my hardware.) I have a feeling there are some more questions like this on the U&L site though. – sourcejedi – 2018-10-30T08:25:07.807
@Xen2050 you may be right, I'm just surprised that a recent JMicron bridge seems to behave wrong while an older JMicron one seems to behave right. And in any case, not being able to read back the contents on the disk is alarming. – Mauro Molinari – 2018-10-30T08:27:54.447
As a reference: seems like https://unix.stackexchange.com/questions/187748/recognizing-gpt-partition-table-created-with-different-logical-sector-size is suggesting a way to read contents back using losetup and specifying proper block size.
– Mauro Molinari – 2018-10-30T09:03:17.650My understanding is that the logical block size is part of the abstraction of the physical drive which is used nowadays to allow more uniform and easier access to physical drives. Basically the kernel pretends that it's writing to an imaginary disk and that gets translated into real memory locations automagically. It seems like the kernel simply selects whatever block size it feels like using for the logical block size, and probably newer USB enclosures provide a similar type of abstraction and just report abstracted values, since it normally won't make any difference to the operating system. – Layne Bernardo – 2018-11-01T02:01:00.423