Write Raw Sectors to a Disk Usage: dskwrite [-abcdEfFhHLSTvxz-] [-Z!] [-n name] [-N sectors] [-s size] [-t tracks] [-V volid] [ disk: ] [ <sectorlist> ] dskwrite copies stdin to the low-level raw sectors on the disk you specify. In conjunction with dskread, dskwrite is most useful as a quick diskette duplication utility: you can read a whole diskette image into a file with dskread, then write it back out with dskwrite to a new diskette. But it's also useful for dumping a long stream of data across a series of diskettes, formatting and filling each with as much as possible before requesting the next one. The disk is given as a single alphabetic drive letter plus a colon. If no disk is specified, the first logical drive is assumed. (In most machines, this is the a: drive.) Operation: dskwrite normally starts at cylinder 0, head 0, sector 0 and walks through the whole disk, writing all the sectors on a track under one head and then all tracks in a cylinder before repositioning the heads to the next cylinder. You can also cause dskwrite to write to just specific sectors by giving it a sector list. dskwrite always writes whole sectors and, if requested, formats whole tracks. If the last sector is only partially- used, dskwrite fills it out with binary zeros. To avoid conflicts with other applications, dskwrite always locks a drive before actually writing to it. Basic Options: -a Autoformat. If the disk appears to be unformatted, automatically do a low-level format of the entire disk. -f Low-level format the entire disk as data is copied to it from stdin. -F Low-level format the entire diskette and create an empty FAT filesystem. Do not read anything from stdin. -S Share the drive for read/write access by other processes. -v Verify. Read back and verify each write. -h Help. (This screen.) -- End of options. Options for using the disk as a serial media: -b Boot record. Write a simple non-system disk boot record and parameter block corresponding to the particular media into sector 0. If writing the entire disk, continue with the next sector. -c Continuation. If there's more data on stdin after an entire disk has been written, prompt for a new disk to be inserted and continue. If -d is specified also, the filename extension on each disk will be the disk number, i.e., 001, 002, 003, etc. -d Dummy filesystem. Write a boot record and a FAT filesystem into the initial sectors allocating whatever is written to a single file. -n <name> The filename to be given to any data written onto the disk if the -d (dummy filesystem) option is used. Default is 'bindata'. Formatting: Default is to let Windows NT try to determine how the media has been formatted and not to reformat the disk. If the disk isn't already formatted and the -a (autoformat) option is selected or if formatting is explicitly requested with the -f or -F options, dskwrite will do a low-level format of the media. Dskwrite takes its specification of the format (e.g., low- or high-density) from the following sources, in decreasing priority: 1. Explicit specifications on the command line. 2. The Windows NT kernel's guess at the media format, assuming the disk is already formatted and not being re-formatted. 3. The format parameters in the boot sector copied from stdin, assuming neither the -b nor the -d options is given. 4. The previous format of the media, assuming it's already formatted in a standard configuration but being reformatted. 5. The highest-density format supported by the drive. Unless you specify -b or -d, dskwrite will expect to copy a compatible disk image from stdin including a suitable boot sector, etc. That happens automatically when dskread'ing a whole disk is paired with dskwrite'ing a whole disk but not otherwise. Explicit Format Specification Options: -E Extended density (2.88M) format. -H High density format. -L Low density format. -N <sectors> Sectors per track. -s <size> Sector size. Normally only 512 is supported but, depending on your hardware, you may also be able to create 128, 256 or 1024-byte sectors. -t <tracks> Number of tracks. Other Advanced Options: -T Low-level format the media track-at-a-time as the disk is written. Only as much of the disk as is being written to will be formatted. -V <volid> The volume identifier to be written into the dummy filesystem header if -F or -d is used. (Ignored otherwise.) -x Force use of a non-standard format or writing of non-standard format parameters to the boot sector. -z Zero-length files written with -d option should still be added to the directory. (Otherwise, they're ignored.) -Z! Force write to a hard disk. Warning! Very risky unless you know exactly what you're doing. Sector lists: Optionally, you can specify a list of sectors you want written. Sectors are given in (cylinder, head, sector) coordinates with parentheses around and commas or white space to separate the numeric values you write. Cylinders, heads and sectors are counted from zero and can be specified in decimal, hex or octal. A single sector specified alone means just that sector. Listing several separated by commas or spaces means each one individually. A pair of sectors joined by a hyphen means a range: all the consecutive sectors beginning with the first and running through to the second. Specifying a negative number as an ordinate means use the highest possible value for that disk. If any of the ordinates of a sector are omitted, they're assumed to be zero except when it closes a range, in which case it means use the highest possible value. Examples: 1. To duplicate a whole diskette image, autoformatting the output media if it's not already formatted: dskread a: > dskimage.a dskwrite -av a: < dskimage.a 2. To use dskwrite to format a disk with an empty FAT file system, use either: dskwrite -F a: or: dskwrite -df a: < nul 3. To rewrite just the boot sector to make it a non-system disk: dskwrite -b a: < nul 4. To use a diskette as a serial archive media: The -d option allows you to request just enough dummy file system "envelope" around the otherwise arbitrary data you intend to write to ensure the disk can still be used with other Windows NT utilities. Here's an example writing the result of a tar'ing (archiving) a whole directory to a series of diskettes, again autoformatting: tar -cs mydir | dskwrite -avcd -n mydir a: It's restored with dskread -dc -n mydir a: | tar -xs The diskettes used do not all have to be the same density; any mix of high and low is okay. But remember that if a disk isn't already formatted, there's no way for dskwrite to tell whether it should be high or low density; any disks it has to format will all be formatted the same way. 5. Reading or writing tar-format floppies: Many UNIX machines support the use of a floppy as a tar archive media, just as if it were a tape. Every sector contains data; there's no filesystem and no boot record at all. This allows the greatest possible amount of data to be written to the disk and it does allow interchange with a UNIX machine, but tar-format floppies are not readable by any ordinary utilities. Here's an example, tar'ing mydir to a single tar-format floppy: tar -cs mydir | dskwrite -vx a: It's restored with dskread a: | tar -xs If the amount of data you're archiving is more than will fit on one diskette, use the -c option with dskread and dskwrite. But since there's no labeling recorded on the diskettes and the data just runs continuously from one diskette to the next, you will need to pay attention to the order in which they're written or read. Non-standard Diskette Formats: If you write anything but a standard boot record into the boot sector, you will not be able to read it with anything but dskread and even then only if you tell it explicitly what format was used. Without a standard parameter block in the boot sector, the Windows NT diskette device driver just can't tell on its own how the diskette was written. Similarly, it's possible you may be able to write a non- standard format (e.g., a sector size other than 512 bytes, etc.) depending on your hardware. But doing that may make the diskette impossible to read on other machines. For that reason, dskwrite normally won't let you write a boot record that doesn't match the actual format of the diskette nor will it let you write anything other than one of the standard format. To override these checks, you must use the -x option. Writing to a Hard Disk: Deliberately, dskwrite normally only lets you write to diskettes. Writing to a hard disk is very risky since the chance of catastrophic loss of information is so high. Also, only ESDI and SCSI disk controllers routinely map out bad blocks, so reading the disk image from one drive and writing it to another is unlikely to work if there are bad blocks on either one. To force dskwrite to write to a hard disk, you must specify the -Z! option, meant to be hard to accidentally type. In effect, the -Z! option means you understand the risk you're taking. |