Check a disk for bad blocks (QNX 4, QNX Neutrino)
dcheck [options] drive
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 you don't specify the number of blocks to verify, dcheck obtains this information from the filesystem and checks all the blocks on the specified drive.
If a disk has been initialized for a QNX 4 filesystem, 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 -F, -l, and -L options), you can increase the chance of recognizing these blocks and adding them to the /.bad_blks file.
|The chkfsys utility also recognizes the /.bad_blks file.|
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 -F doesn't prompt you at the end of each check.
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.
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:
If you specify the -m (mark bad blocks) option, the block-special file being checked must be a currently mounted QNX partition. The .bad_blks and .bitmap files on that filesystem are updated if dcheck discovers any bad blocks.
The dcheck utility normally opens the disk in read-only mode. However, if you specify the -m, -w, or -V option, the disk is opened in read/write mode. For read/write access, there must be no open files on the disk, or else 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.
chkfsys, dinit, fdformat, io-blk.so
Backing Up and Recovering Data in the Neutrino User's Guide