[Previous] [Contents] [Next]

dcheck

Check a disk for bad blocks (QNX)

Syntax:

dcheck [options] drive

Options:

-b blk_cnt
The maximum number of blocks to check.
-B max_blks
The maximum number of blocks to read at a time; can be up to 32 (the default).
-e
If possible, disable drive error correction during check for bad blocks.
-f first_blk
The first block to check.
-l
("el") Loop until input (switching serial/random).
-L loops
Loop as in the -l option, but with a specified number of loops.
-m
In the bitmap, mark bad blocks as unavailable.
-p
Prompt before starting.
-q
Be quiet; don't display progress information.
-r
Use a random head movement algorithm.
-v
Be verbose; display every bad block on the disk.
-V
Verify write after read. (Filesystem caching effects can render this option to be of little value.)
-w
Write after read (non-destructive) check.
drive
The name of the disk (e.g. /dev/fd0, /dev/hd0t77) or the root of the filesystem.

Description:

The dcheck utility verifies that a disk has been correctly formatted by attempting to read every block on the drive. The block numbers of any blocks that cannot be read are displayed (in hex) to standard output. A summary of the total number of bad blocks is also displayed. You can use dcheck to check any formatted disk, including disks that contain files. The files won't be damaged.

If the number of blocks to verify is not specified, dcheck will obtain this information from the filesystem and will check all the blocks on the specified drive.

If a disk has been initialized for QNX, you should use the -m option to remove any bad blocks from the disk allocation bitmap (/.bitmap). This is especially true for hard disks. When you specify the -m option, dcheck attempts to read the file /.bad_blks from the disk. This file contains a list of all known bad blocks, in sorted order. If /.bad_blks is found, dcheck will read it, and when it is finished checking the disk, dcheck will update the bitmap and recreate the /.bad_blks file. Note that the dcheck utility only adds to, but never removes, bad block information in this file.

Some blocks may be marginal, so if you run dcheck multiple times (see the -l and -L options), you can increase the chance of these blocks being recognized and added to the /.bad_blks file.


Note:

The /.bad_blks file is also recognized by the chkfsys utility.


To help you find any marginal blocks, dcheck has a number of options to provide additional checking of a disk. For example, the -r option checks the blocks in a random order-each check consists of a random number of blocks between 1 and 32 (or less, depending on the value specified in the -B option). The dcheck utility keeps track of the checked blocks and checks each one only once. This option allows you to find blocks that are bad due to a slight lag time in head movement.

The -l option will continuously check the disk until you stop it. For this option, -r is implicitly used and is toggled for each invocation. That is, for the first loop, random checking is set on; for the second loop, it is off, etc. At the end of each complete check, you are prompted to stop the loop. If you don't stop it within 15 seconds, dcheck will be started again, etc. The -L option is identical to -l with an upper limit to the number of loops.

The -w option will rewrite each block on the device after reading it. This is a nondestructive check that tests the write portion of the hardware. Note that, although this is a more thorough test, you must pay for it with additional time that is dependent on the hardware.

The -V option is similar to the -w option, in that dcheck rewrites each block after reading it but in this case dcheck also rereads each block after the rewrite check and compares this second read with the first. Like the -w option, this test is also nondestructive. Note, however, that this is a more thorough test that takes longer.

If you wish to check a disk on another node, you must indicate the disk explicitly via a //node prefix.

The -e option requests that error correction (where supported) not be used. This lets dcheck detect marginal blocks as if they were bad blocks. Hence, specifying the -e option in combination with the -m option -- which marks bad blocks as unavailable-removes marginal blocks from the disk allocation bitmap. Note that error correction is re-enabled after dcheck terminates.

Examples:

Check all blocks on the hard disk and mark bad blocks in the bitmap:

    dcheck -m /

Check the first 640 blocks on the floppy disk:

    dcheck -b 640 /dev/fd0

Check all blocks on the hard disk of node 3:

    dcheck //3/dev/hd0t77

Files:

The dcheck utility will utilize the standard input for reading user responses to prompts. The user will be prompted only if the -p (pause before starting) option or -l (loop until input) options are used.

Messages will be written to standard error when internal errors occur which might prevent a complete check, or when dcheck discovers bad blocks on the disk. Information not related to errors is written to the standard output.

All drive parameters specified on the command line must specify block special files.

If the -m (mark bad blocks) option is specified, the block special file being checked must be a currently mounted QNX partition. The .badblocks and .bitmap files on that filesystem will be updated if dcheck discovers any bad blocks.

Exit status:

0
No bad blocks were found.
>0
An error occurred or bad blocks were found.

Caveats:

The dcheck utility normally opens the disk in read-only mode. However, if you specify the -m, -w, or -V options, the disk is opened in read/write mode. For read/write access, there must be no open files on the disk, or dcheck will fail with a "Device or resource busy" message. While dcheck is working in read/write mode, no other utilities or programs will be allowed to access the disk.

When using the -m option, if dcheck is terminated by a SIGBREAK or other signal, any pending bad blocks may not be recorded. In any event, the results are nondestructive.

Filesystem caching may render some options, such as -V to be of little value. In the case of -V, the read after write may simply read the data back out of the cache instead of from the disk media. Another cache effect to watch out for is that bad blocks are 'sticky' in the cache. Even though the failure might be intermittent, it will not be possible for force Fsys to re-read the block as long as it remains in cache. It will always return the block as bad.

See also:

chkfys, dinit, fdformat, Fsys


[Previous] [Contents] [Next]