Linux Disk Commands

From Atari Wiki
Revision as of 11:43, 22 March 2006 by Daeghnao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Device Concept

Linux generally makes heavy use of its filesystem, and access to hardware devices is no exception. For floppy disks, the raw content of the disk (i.e. without interpreting the disk as folders and files) is accessed through a device file. Traditionally, the first floppy drive is called /dev/fd0 and the second is /dev/fd1. Reading data from these devices translates into accesses to the raw data on the floppy disk. The data is read in logical sector order, so the image will conform to the '.ST' format used by some emulators. The commands that manipulate the disk directly (e.g. setting the disk size) are from the fdutils package, and those that manipulate files within the image are from the mtools package.

Reading the Image

The following command will create a disk image "image.st" for the disk in the first floppy drive:

cp /dev/fd0 image.st

The drivers for the disk drive usually sense the disk format correctly, detecting extra tracks and sectors. If this doesn't happen, you can set the format manually. This example sets 10 sectors, 83 tracks, double-sided:

setfdprm /dev/fd0 dd ds sect=10 cyl=82

Note that sectors count from 1, but cylinders count from 0.

Fast Format

Some disks formatted with Fastcopy III or Fastcopy Pro on the Atari ST are known to be unreadable on some PCs, even when accessing the disk controller directly. The skewing of the disk is beyond the capabilities of the hardware. If you encounter this problem, you will have to copy the disk contents using an Atari ST or other hardware that does not suffer the same problem.

Writing the Image

To write the image to a disk, first format the disk, then copy the image back to the appropriate floppy device.

The disk can be formatted with superformat. You specify the disk and the size in the same way as for setfdprm:

superformat /dev/fd0 dd ds sect=10 cyl=80

To write the image:

cp image.st /dev/fd0

Using the Disk Directly

Linux has a suite of programs, mtools, that are designed to work with floppy disks and disk images. The commands mirror the old MS-DOS commands for working with disks. For example:

mdir a:

Will give a DOS-style directory listing for the disk in the first floppy drive.

mkdir files
mcopy -s a:/ files

This command will copy the entire content of the disk, recursively, to the directory 'files'.

Using a Disk Image

Newer versions of mtools allow access to disk images as well as real floppy disks. Add the option '-i image.st' for whatever image you want to use, and use the drive letter ':' instead of a real drive letter. For example:

mdir -i image.st ::/
mkdir files
mcopy -i image.st -s ::/ files