badtrk(ADM)
badtrk --
scan fixed disk for flaws and create a bad track/block table
Syntax
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 ] ]
Description
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.
-e-
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:
q-
quick scan (default speed)
t-
thorough scan
d-
destructive scan
n-
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.
-v-
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:
-
Display the bad track table.
-
Scan the disk for flaws.
If you have entered changes to be made to the
bad track table, you are given the opportunity to
write these changes to the bad track table on disk before
badtrk starts scanning.
badtrk prompts you for the kind of scan you wish
to perform: quick or thorough, destructive or
non-destructive.
All data in the scanned region will be lost if you choose
a destructive scan.
You can interrupt a scan at any time by pressing ``q''.
You then have the option to continue the scan or return to
the main menu.
badtrk displays a read or write error from the disk
driver whenever a defect on the disk is found. For example:
WARNING: driver: Error on fixed disk dev=0/47 block=31434 cmd=0x10
status=0x5180, sector = 62899, cylinder/head = 483/4
-
Add entries to the bad track table.
Do not do this if the disk drive geometry has been
remapped or if the disk does not have a flaw map (see
``Warning'').
Enter one defective track per line.
Entries can be added by cylinder and head number, or by
sector number; the option that should be used depends
upon the format of the disk's flaw map.
-
Delete individual or all entries from the bad track table.
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:
-
Scan an entire UNIX system partition,
a filesystem (division), or a range of blocks.
You can interrupt a scan at any time by pressing <Del>.
You then have the option to reallocate the defects found so far.
If automatic remapping is not enabled on the disk,
the disk driver turns off all error correction and caching
while it scans the disk; it does not try to reconstruct data
using ECC (even if this is available).
badtrk displays a read or write hard
error from the disk driver whenever a defect on the disk is found
from which the data cannot be recovered. For example:
NOTICE: Sdsk: Unrecoverable error reading SCSI disk 2 dev 1/64
(ha=0 id=1 lun=0) block=219102
Medium error: Unrecovered read error
Do not use the block numbers that the device driver reports with
badtrk. Use the block numbers that badtrk
reports after the scan finishes.
If automatic remapping is enabled, soft errors are corrected
silently by adding them to the drive's G-List and copying their
reconstructed data to an alias block.
The reporting of soft errors can be enabled as described on the
scsidisk(HW)
manual page. This does not cause badtrk to interpret
these errors as bad blocks.
Any bad blocks containing corrupted data (hard errors)
are added to badtrk's own bad block table.
(This table consists of the existing bad block table read from the disk
partition and any blocks that have been added manually.)
If badtrk's own bad block table becomes full during the
scan, you are given the option to reallocate the bad blocks found
so far before continuing to scan the disk.
-
Display badtrk's own bad block table
(the disk's G-List cannot be displayed).
-
Add blocks to badtrk's own bad block table;
you can reallocate these at a later stage. Enter the list of
block numbers one per line; enter ``q'' to end the list.
-
Delete entries from badtrk's own bad block table.
-
Clear badtrk's own bad block table.
-
Reallocate disk blocks from badtrk's own table.
If possible, these blocks are added to the disk's G-List;
the disk partition's bad block table is updated with a table
of bad blocks that cannot be allocated to the G-List.
-
Enable or disable Automatic Read Remapping (ARR) and/or
Automatic Write Remapping (AWR) for the entire disk. This is
accessed by selecting the menu option ``Modify target parameters''.
This option is only shown if the disk controller supports these
features.
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.
Warning
You should heed the following warnings:
-
Use badtrk in single-user mode only.
-
Take care that you do not run a destructive scan on the wrong
disk by mistake.
-
If you change the size of the bad track or bad block table in a
partition (for example, by using the -e option), this creates
a new division table and renders any existing filesystems in the partition
unusable.
Note that the mkdev hd command invokes badtrk with the
-e option during the installation of a hard disk.
If the hard disk already contains filesystems, do not select
to change the size of the bad track or bad block table.
-
The recommended number of alias tracks/blocks is
based on the number of known bad tracks/blocks plus an
allowance for those that may go bad in the future.
You should allocate at least this number;
note that if you want to change the number
later, you will have to reinstall the operating system
if the partition contains the root filesystem.
-
Some disk controllers support alternate modes
known as ``translation,'' ``mapping,'' or ``63-sector'' modes,
that change the apparent geometry of the drive.
This is often used to make a drive with more than 1024
cylinders appear to have fewer cylinders.
If your drive has been formatted using one of these
options, do not add entries to the bad track table manually.
This warning does not apply to SCSI disks since these
use logical block addresses.
Limitations
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