I have a Toshiba 4TB external USB hard disk that I'm trying to use with FreeBSD. I can read from and write to the disk just after the system boots (or just after I plug it in). However, if I leave the disk unused for ~5 minutes, any subsequent reads or writes hang the system (to the extent that the process doing I/O cannot be killed, but I can still run additional processes that do not touch the affected disk; rebooting the system is impossible from FreeBSD, I have to hard-reset the system).
It seems to me that the problem is the USB disk spinning down or going into power-saving mode, and FreeBSD cannot wake it again. (Linux handles the disk fine and does not exhibit this problem, so it seems unlikely to be a broken disk/hardware problem.)
This problem occurs when I connect the USB disk via USB-2 or USB-3.
Here's how I've tried to solve this problem:
What can I do to stop this disk from going to sleep? Is there a less hacky solution than writing to the disk every few minutes?
Error log
When I try to write to the disk once it has (likely) powered-down, I get the following errors in /var/log/messages:
...and then the system just hangs.
Here's some information about the USB disk:
It seems to me that the problem is the USB disk spinning down or going into power-saving mode, and FreeBSD cannot wake it again. (Linux handles the disk fine and does not exhibit this problem, so it seems unlikely to be a broken disk/hardware problem.)
This problem occurs when I connect the USB disk via USB-2 or USB-3.
Here's how I've tried to solve this problem:
- I set up a cron(8) job to
touch -c /dev/da0
every few minutes, but that seems to have no effect -- the disk still hangs after a while. - I've run
camcontrol apm /dev/da0
, which should disable APM. The command produces no errors, but seems to have no effect -- the disk still hangs after a while. - I've run
camcontrol standby /dev/da0 -t 0
andcamcontrol idle /dev/da0 -t 0
. As before, the commands produce no errors, but seem to have no effect -- the disk still hangs after a while. - I've run
smartd
from sysutils/smartmontools includingCode:DEFAULT -e standby,off
- I set up a cron(8) job to run
date > /path/to/da0-mount/date.txt
every few minutes. This seems to keep the disk awake for extended periods of time!
What can I do to stop this disk from going to sleep? Is there a less hacky solution than writing to the disk every few minutes?
Error log
When I try to write to the disk once it has (likely) powered-down, I get the following errors in /var/log/messages:
Code:
Aug 5 16:02:25 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 88 00 00 00 08 00 00
Aug 5 16:02:25 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:25 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
Aug 5 16:02:31 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 88 00 00 00 08 00 00
Aug 5 16:02:31 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:31 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 2 more tries remain
Aug 5 16:02:36 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 88 00 00 00 08 00 00
Aug 5 16:02:36 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:36 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 1 more tries remain
Aug 5 16:02:42 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 88 00 00 00 08 00 00
Aug 5 16:02:42 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:42 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 0 more tries remain
Aug 5 16:02:47 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 88 00 00 00 08 00 00
Aug 5 16:02:47 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:47 server kernel: (da0:umass-sim0:0:0:0): Error 5, Retries exhausted
Aug 5 16:02:53 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 90 00 00 00 08 00 00
Aug 5 16:02:53 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:53 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
Aug 5 16:02:59 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 90 00 00 00 08 00 00
Aug 5 16:02:59 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:02:59 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 2 more tries remain
Aug 5 16:03:04 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 90 00 00 00 08 00 00
Aug 5 16:03:04 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:04 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 1 more tries remain
Aug 5 16:03:10 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 90 00 00 00 08 00 00
Aug 5 16:03:10 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:10 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 0 more tries remain
Aug 5 16:03:16 server kernel: (da0:umass-sim0:0:0:0): WRITE(16). CDB: 8a 00 00 00 00 01 1c 00 20 90 00 00 00 08 00 00
Aug 5 16:03:16 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:16 server kernel: (da0:umass-sim0:0:0:0): Error 5, Retries exhausted
Aug 5 16:03:21 server kernel: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 e8 00 20 78 00 00 08 00
Aug 5 16:03:21 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:21 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 3 more tries remain
Aug 5 16:03:27 server kernel: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 e8 00 20 78 00 00 08 00
Aug 5 16:03:27 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:27 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 2 more tries remain
Aug 5 16:03:33 server kernel: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 e8 00 20 78 00 00 08 00
Aug 5 16:03:33 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:33 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 1 more tries remain
Aug 5 16:03:38 server kernel: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 e8 00 20 78 00 00 08 00
Aug 5 16:03:38 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:38 server kernel: (da0:umass-sim0:0:0:0): Retrying command, 0 more tries remain
Aug 5 16:03:44 server kernel: (da0:umass-sim0:0:0:0): WRITE(10). CDB: 2a 00 e8 00 20 78 00 00 08 00
Aug 5 16:03:44 server kernel: (da0:umass-sim0:0:0:0): CAM status: CCB request completed with an error
Aug 5 16:03:44 server kernel: (da0:umass-sim0:0:0:0): Error 5, Retries exhausted
...and then the system just hangs.
Here's some information about the USB disk:
Code:
# camcontrol powermode /dev/da0
camcontrol: Can't get ATA command status
Code:
# less /var/log/messages
[... snip ...]
Aug 5 18:42:19 server kernel: da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
Aug 5 18:42:19 server kernel: da0: <TOSHIBA External USB 3.0 5438> Fixed Direct Access SPC-4 SCSI device
Aug 5 18:42:19 server kernel: da0: Serial Number [REDACTED]
Aug 5 18:42:19 server kernel: da0: 400.000MB/s transfers
Aug 5 18:42:19 server kernel: da0: 3815447MB (7814037164 512 byte sectors)
Aug 5 18:42:19 server kernel: da0: quirks=0x2<NO_6_BYTE>
[... snip ...]
Code:
# usbconfig -d 1.2 dump_curr_config_desc
ugen1.2: <TOSHIBA External USB 3.0> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)
Configuration index 0
bLength = 0x0009
bDescriptorType = 0x0002
wTotalLength = 0x002c
bNumInterfaces = 0x0001
bConfigurationValue = 0x0001
iConfiguration = 0x0000 <no string>
bmAttributes = 0x0080
bMaxPower = 0x0070
Interface 0
bLength = 0x0009
bDescriptorType = 0x0004
bInterfaceNumber = 0x0000
bAlternateSetting = 0x0000
bNumEndpoints = 0x0002
bInterfaceClass = 0x0008 <Mass storage>
bInterfaceSubClass = 0x0006
bInterfaceProtocol = 0x0050
iInterface = 0x0000 <no string>
Endpoint 0
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0081 <IN>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0400
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Additional Descriptor
bLength = 0x06
bDescriptorType = 0x30
bDescriptorSubType = 0x0e
RAW dump:
0x00 | 0x06, 0x30, 0x0e, 0x00, 0x00, 0x00
Endpoint 1
bLength = 0x0007
bDescriptorType = 0x0005
bEndpointAddress = 0x0002 <OUT>
bmAttributes = 0x0002 <BULK>
wMaxPacketSize = 0x0400
bInterval = 0x0000
bRefresh = 0x0000
bSynchAddress = 0x0000
Additional Descriptor
bLength = 0x06
bDescriptorType = 0x30
bDescriptorSubType = 0x0e
RAW dump:
0x00 | 0x06, 0x30, 0x0e, 0x00, 0x00, 0x00