This is not an answer but might help. I have a similar situation with a USB external hard drive reporting different capacity when queried in different ways.
smartctl -i -d scsi /dev/sdb
gives:
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.14.27-std-def-alt1] (ALT Linux 6.2-alt0.M70P.1)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: BUFFALO
Product: HD-PNTU3
Revision: 0001
User Capacity: 1,000,173,428,736 bytes [1.00 TB]
Logical block size: 512 bytes
Logical Unit id: 0x6000039426a846b30000000000000000
Device type: disk
Local Time is: Thu Jan 22 19:57:29 2015 JST
SMART support is: Unavailable - device lacks SMART capability.
However, smartctl -i -d sat /dev/sdb
gives:
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.14.27-std-def-alt1] (ALT Linux 6.2-alt0.M70P.1)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Toshiba 2.5" HDD MQ01ABD...
Device Model: TOSHIBA MQ01ABD100
Serial Number: 72D7F1JHS
LU WWN Device Id: 5 000039 426a846b3
Firmware Version: AX0A1U
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 2.6, 3.0 Gb/s (current: 3.0 Gb/s)
Local Time is: Thu Jan 22 19:57:36 2015 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
They differ not only in the capacity, but also the model name, and whether or not it is reported that the physical sector size is 4096 bytes. Now, in my case:
hdparm -I /dev/sdb
seems to see the larger capacity / 4KiB-physical-sector information.
hdparm -g /dev/sdb
, fdisk -l /dev/sdb
, cat /sys/block/sdb/size
and cat /sys/block/sdb/queue/physical_block_size
all show the smaller capacity / 512B-physical-sector information.
As for the security issue, it should be OK if nobody has ever written sensitive data to the "inaccessible" sectors. fdisk
can't see them, and, in my case, Windows isn't seeing them either. Probably they've never belonged to a partition.
However, it seems that some LVM tools do get confused by the discrepancy: https://unix.stackexchange.com/questions/139705/why-does-hdparm-see-two-different-values-for-the-size-of-a-drive/180808
root@ubuntu:/home/ubuntu# sg_readcap --16 /dev/sdd
READ CAPACITY (16) not supported
This means when your USB docking translate the capacity from the drive's ATA IDENTIFY DEVICE data (seen in hdparm -I
/ smartctl -i
), it can at most report a size up to 32-bit (i.e. 0xffffffff, 4294967295) in terms of number of logical sectors. This is an inherit limitation of SCSI READ CAPACITY (10):
Logical Sector Size | Maximum capacity supported (TiB / TB)
512 | ~2.0 / ~2.2
4096 | ~16.0 / ~17.6
Since your drive is an AF 512e drive that has totally 5860533168 / 0x15d50a3b0 512-byte logical sectors, which requires 33 bits to represent, only a SATA/USB bridge that supports SCSI READ CAPACITY (16) can handle it properly. When the size is truncated to 32-bit, it turns from:
101011101010100001010001110110000 (5860533168)
to
01011101010100001010001110110000 (1565565872)
The Linux kernel, or probably all OSes, will basically never issue ATA IDENTIFY DEVICE command "directly" (i.e. encapsulated in a SCSI ATA PASS-THROUGH command) to USB drives, but SCSI READ CAPACITY commands (which you issued manually with sg_readcap
), to get the capacity of them.
Only when the drives are actually SATA drive connected with a SATA/USB bridge, the command will be handled by the SCSI-ATA Translation Layer implemented in the bridge, which will then issue ATA IDENTIFY DEVICE command to the SATA drive to get the information it needs to form the response data for the READ CAPACITY command.
But utilities like hdparm
and smartctl
are (almost) exclusively for ATA drives, so they pretty much do everything with ATA PASS-THROUGH. (Also because they are userspace utilities, it is expected you, the user, will only use them on the appropriate type of devices.) That's why you end up getting different capacity in different places.
Best Answer
On linux,
/sys/block/<deviceName>/device/timeout
(such as/sys/block/sda/device/timeout
) is the timeout setting in seconds, which currently defaults to 30.In the same directory, there is a
eh_timeout
value which is used for the SCSI commandsTEST UNIT READY
andREQUEST SENSE
, so isn't what you're looking for.As root,
echo 1 > /sys/block/<deviceName>/device/timeout
will change the timeout to 1 second. (Or, echo 3 for your 3 second example.)As a non-root user, with
sudo
privileges,sudo bash -c "echo 1 > /sys/block/<deviceName>/device/timeout"
will do the same.