SCSI disk spare sectors

Is there a way to determine the number of available spare sectors on a disk ? as it may be useful for notifying a user to take a backup of the disk before it runs into a medium error.

try "df -k" and "du -sk"

I don't think you can do this with du.

Du (Unix - Wikipedia, the free encyclopedia)

To look at the underlying sectors, you need a lower level utility such as fdisk

fdisk - Wikipedia, the free encyclopedia

I didn't take this literally, I inferred it meant useable disk space.

I am sorry. I think I confused everyone. This is what I actually meant to say..

Usually a hard disk keeps spare sectors that are not visible to the user. Whenever the disk encounters a bad block the disk internally replaces these bad blocks from the spare sectors. This operation is completely translucent to the user. There seems to be a specific number of spare sectors on any hard disk that is used for recovering from bad blocks. But once the disk runs out of spare sectors in the process of replacing bad blocks, all future bad blocks will become medium errors (unrecoverable). If the number of available spare sectors can be found then the user can be informed much earlier that its time to backup this disk as it would soon become faulty.

You should be backing up the disk anyway irrespective of this as this is only one of the many ways your data may become unrecoverable. Power spikes, bearing failures, buggy/malicious software, erroneous deletions etc can all trash your data.

What you are asking for is very low-level and device/manufacturer specific.

See the SourceForge project called SMART:

smartmontools Home Page (last updated $Date: 2007/10/26 21:49:03 $)

See also:

Monitoring Hard Disks with SMART