man smartctl
states (SNIPPED for brevity):
The first category, called "online" testing. The second category of testing is called "offline" testing. Normally, the disk will suspend offline testing while disk accesses are taking place, and then automatically resume it when the disk would otherwise be idle. The third category of testing (and the only category for which the word ´testing´ is really an appropriate choice) is "self" testing.
Enables or disables SMART automatic offline test, which scans the drive every four hours for disk defects. This command can be given during normal system operation.
Who runs the test – drive firmware? What sort of tests are these – does the firmware read/write to disk – what exactly goes on? Is it safe to invoke testing whilst in the OS (linux) or can one schedule a test for later – how does this take place – when you reboot the OS at the BIOS prompt ('offline test')? Where are the results displayed – SMART logs?
Best Answer
The drive firmware runs the tests.
The details of the tests can be read in eg www.t13.org/Documents/UploadedDocuments/technical/e01137r0.pdf, which summarises the elements of the short and long tests thus:
an electrical segment wherein the drive tests its own electronics. The particular tests in this segment are vendor specific, but as examples: this segment might include such tests as a buffer RAM test, a read/write circuitry test, and/or a test of the read/write head elements.
a seek/servo segment wherein the drive tests it capability to find and servo on data tracks. The particular methodology used in this test is also vendor specific.
a read/verify scan segment wherein the drive performs read scanning of some portion of the disk surface. The amount and location of the surface scanned are dependent on the completion time constraint and are vendor specific.
The criteria for the extended self-test are the same as the short self-test with two exceptions: segment (3) of the extended self-test shall be a read/verify scan of all of the user data area, and there is no maximum time limit for the drive to perform the test.
It is safe to perform non-destructive testing while the OS is running, though some performance impact is likely. As the
smartctl
man page says for both-t short
and-t long
,If you invoke captive mode with
-C
,smartctl
assumes the drive can be busied-out to unavailability. This should not be done on a drive the OS is using.As the man page also suggests, the offline testing (which simply means periodic background testing) is not reliable, and never officially became part of the ATA specifications. I run mine from cron, instead; that way I know when they should happen, and I can stop it if I need to.
smartctl
output. Here's one with a test running:Note two previous completed tests (at 486 and 20567 hours power-on, respectively) and the current running one (10% complete).