badtrk -- scan fixed disk for flaws and create a bad track/block table


For non-SCSI disks:

/etc/badtrk [ -e [ -v ] [ -m max ] ] [ -f device ] [ -R n ] [ -s [q|t][d|n] ]

For SCSI disks:

/etc/badtrk [ -a ] [ -e [ -v ] [ -m max ] ] [ -f device ] [ -O ]
[ -b [ -n ] block ... ] | [ -s [q|t][d|n] [ start end ] [ -r ] ]


badtrk is primarily used during system installation. It scans a hard disk partition for flaws, creates a new bad track table for non-SCSI drives, creates a new bad block table for SCSI drives, prints the current table, and adds and deletes entries in the table.

Bad tracks/blocks listed in the table are ``aliased'' to good tracks/blocks; when a process tries to read or write a track/block listed in the bad track/block table, it is replaced by one of the alias tracks/blocks.

The bad track/block table and alias tracks/blocks are stored in the disk partition, after the division table and before division 0.

Note that the blocks referred to for SCSI disks are SCSI logical blocks, not filesystem logical blocks. SCSI logical blocks typically range from 48 to 4096 bytes in size, depending on the manufacturer. The SCSI logical block size is usually set to 512 bytes when the disk is formatted. Logical block addresses (LBAs) are specified from the start of the physical disk.

badtrk accepts the following options:

-a (SCSI only)
Enable Automatic Read/Write Remapping (ARR/AWR) for the entire disk if the target SCSI disk controller supports these features. (See scsidisk(HW) for further details.) If supported, the Save Page bit is set to ensure that automatic remapping is not lost when power is removed from the drive; whether this is successful depends on the disk controller hardware, and may be overridden by operating systems on other disk partitions.

If enabled, bad blocks that arise are reallocated automatically to the drive's grown defect list (G-List); by default, notification is not sent to the system administrator. Bad block tables in partitions are unaffected by this activity.

-b [ -n ] block ... (SCSI only)
Specify block numbers to be added to the disk's G-List. If the list is full or unavailable, the blocks are added to the partition's bad block table. If the -n option is specified, badtrk does not attempt to recover data from the blocks. Drives that support an error correction code (ECC) can usually recover data from blocks that show soft errors.

Used during installation to change the size of the bad track/block table.

It is recommended that you do not invoke this option from the command line. See ``Warning'' for more information.

-f device
Open the partition raw device and read the bad track/block table associated with that partition. device can refer to a UNIX® System partition, or a division (filesystem) within such a partition. For example, /dev/rhd0a is the active partition on the first drive, and /dev/rroot is the root filesystem. See hd(HW) for details of the naming of disk partitions.

The default device is /dev/rhd0a.

-m max
Set the maximum number of bad tracks/blocks in the bad track/block table to max.

Used only in non-interactive mode with -e.

-O (SCSI only)
Map out defects using the bad block table managed by the operating system in the disk partition. Disregard whether the disk controller supports the SCSI REASSIGN BLOCKS command or not.

-R n (non-SCSI only)
Specify the number of attempts, n, to read a bad track when attempting to recover data. n can be any integer value from 1 to 10; if a value is specified outside this range, n reverts to its default value of 5.

-s [q|t][d|n]

-s [q|t][d|n] [ start end ] [ -r ] (SCSI only)
Invoke badtrk non-interactively, causing it to scan the disk for bad tracks/blocks.

The option arguments q, t, d, and n specify the speed and type of scan:

quick scan (default speed)

thorough scan

destructive scan

non-destructive scan (default effect)

For example, -s qn specifies a quick non-destructive scan.

For non-SCSI disks, any bad tracks are added to the bad track table when badtrk exits.

For SCSI disks, the reallocate (-r) option must be specified if bad blocks are to be reallocated while the disk is being scanned. If necessary, the scan can be limited to a range of blocks by specifying the start and end block numbers.

The -r option reallocates bad blocks using spare disk blocks (managed by the disk controller's firmware); the bad block number is added to the disk's G-List. If the G-List is full or the hardware does not support the SCSI REASSIGN BLOCKS command, badtrk adds the blocks to the bad block table in the disk partition (managed by the operating system).

The -r option can only be used with, and must appear after, the -s option.

Display progress messages indicating how much of the disk has been scanned.

Used only in non-interactive mode with -e.
badtrk runs non-interactively if any of the options -b, -m, or -s is specified.

Using badtrk interactively with non-SCSI disks

From badtrk's main menu, you can:
When you quit badtrk, you are given the option to add any bad tracks that have been found to the bad track table.

Using badtrk interactively with SCSI disks

From badtrk's main menu, you can: When you quit badtrk, you are given the option to reallocate the bad blocks in badtrk's internal table. If possible, these are added to the disk's G-List; otherwise, they are used to update the disk partition's bad block table.

When badtrk reallocates blocks, it gives you the option of first trying to recover data from the blocks. This is usually unlikely to succeed.


You should heed the following warnings:


badtrk is intended for use with ST506, ESDI, and SCSI disk controllers. It will not function with IDA controllers; these manage their own internal defect list.

You will obtain better performance from SCSI disks if the disk controller is allowed to reassign bad blocks using the disk's G-List; that is, do not specify the -O option.

If a bad spot develops in the boot blocks or system tables at the very beginning of a partition on a non-SCSI disk, reinstallation is required. You must then use badtrk to add entries to the bad track table. On SCSI disks, ECC can usually recover the data to the G-List.

See also

badblk(ADM), hd(HW), scsidisk(HW)

Standards conformance

badtrk is not part of any currently supported standard; it is an extension of AT&T System V provided by The Santa Cruz Operation, Inc.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003