[Previous] [Contents] [Index] [Next]

dcheck

Check a disk for bad blocks (QNX 4, QNX Neutrino)

Syntax:

dcheck [options] drive

Options:

-B max_blks
The maximum number of blocks to read at a time; max_blks can be up to 32 (the default).
-b blk_cnt
The maximum number of blocks to check.
-f first_blk
The first block to check.
-L loops
Loop as in the -l option, but with a specified number of loops.
-l
("el") Loop until input (switching serial/random).
-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
Verify write after read.
-v
Be verbose; display every bad block on the disk.
-w
Write after read (nondestructive) 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 can't 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 aren't damaged.

If the number of blocks to verify isn't specified, dcheck obtains this information from the filesystem and checks 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 reads it, and when it's finished checking the disk, dcheck updates the bitmap and recreates 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 recognizing these blocks and adding them 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 makes dcheck 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're prompted to stop the loop. If you don't stop it within 15 seconds, dcheck is started again, etc. The -L option is identical to -l with an upper limit to the number of loops.

The -w option makes dcheck 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, it takes more time, depending 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 nondestructive. Note, however, that this is a more thorough test that takes longer.

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:

dcheck /dev/hd0t77

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 are 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 fails with a "Device or resource busy" message. While dcheck is working in read/write mode, no other utilities or programs is 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.

See also:

chkfsys, dinit, fdformat, io-blk.so

Backing Up and Recovering Data in the Neutrino User's Guide


[Previous] [Contents] [Index] [Next]