Sortix cross-volatile manual
This manual documents Sortix cross-volatile. You can instead view this document in the latest official manual.
mtools(1) | General Commands Manual | mtools(1) |
Introduction
Mtools is a collection of tools to allow Unix systems to manipulate MS-DOS files: read, write, and move around files on an MS-DOS file system (typically a floppy disk). Where reasonable, each program attempts to emulate the MS-DOS equivalent command. However, unnecessary restrictions and oddities of DOS are not emulated. For instance, it is possible to move subdirectories from one subdirectory to another.Where to get mtools
Mtools can be found at the following places (and their mirrors):http://ftp.gnu.org/gnu/mtools/mtools-4.0.44.tar.gz
Common features of all mtools commands
Options and filenames
MS-DOS filenames are composed of a drive letter followed by a colon, a subdirectory, and a filename. Only the filename part is mandatory, the drive letter and the subdirectory are optional. Filenames without a drive letter refer to Unix files. Subdirectory names can use either the '/' or '\' separator. The use of the '\' separator or wildcards requires the names to be enclosed in quotes to protect them from the shell. However, wildcards in Unix filenames should not be enclosed in quotes, because here we want the shell to expand them.Drive letters
The meaning of the drive letters depends on the target architectures. However, on most target architectures, drive A is the first floppy drive, drive B is the second floppy drive (if available), drive J is a Jaz drive (if available), and drive Z is a Zip drive (if available). On those systems where the device name is derived from the SCSI id, the Jaz drive is assumed to be at SCSI target 4, and the Zip at SCSI target 5 (factory default settings). On Linux, both drives are assumed to be the second drive on the SCSI bus (/dev/sdb). The default settings can be changes using a configuration file (see section Configuration).mcopy -i my-image-file.bin ::file1 ::file2 .
mcopy -i my-image-file.bin@@1M ::file1 ::file2 .
Sizes and offsets
Certain commands, such as mformat, allow you to specify a hard disk size.- *
- S sectors (of 512 bytes)
- *
- K Kilobytes
- *
- M Megabytes
- *
- G Gigabytes
- *
- T Terabytes
Current working directory
The mcd command (`mcd') is used to establish the device and the current working directory (relative to the MS-DOS file system), otherwise the default is assumed to be A:/. However, unlike MS-DOS, there is only one working directory for all drives, and not one per drive.VFAT-style long file names
This version of mtools supports VFAT style long filenames. If a Unix filename is too long to fit in a short DOS name, it is stored as a VFAT long name, and a companion short name is generated. This short name is what you see when you examine the disk with a pre-7.0 version of DOS.The following table shows some examples of short names:
Long name MS-DOS name Reason for the change
--------- ---------- ---------------------
thisisatest THISIS~1 filename too long
alain.knaff ALAIN~1.KNA extension too long
prn.txt PRN~1.TXT PRN is a device name
.abc ABC~1 null filename
hot+cold HOT_CO~1 illegal character
As you see, the following transformations happen to derive a short name:
- *
- Illegal characters are replaced by underscores. The illegal characters are ;+=[]',\"*\\<>/?:|.
- *
- Extra dots, which cannot be interpreted as a main name/extension separator are removed
- *
- A ~n number is generated,
- *
- The name is shortened so as to fit in the 8+3 limitation
The initial Unix-style file name (whether long or short) is also called the primary name, and the derived short name is also called the secondary name.
Example:
mcopy /etc/motd a:Reallylongname
mcopy /etc/motd a:motd
In a nutshell: The primary name is the long name, if one exists, or the short name if there is no long name.
Although VFAT is much more flexible than FAT, there are still names that are not acceptable, even in VFAT. There are still some illegal characters left (\"*\\<>/?:|), and device names are still reserved.
Unix name Long name Reason for the change
--------- ---------- ---------------------
prn prn-1 PRN is a device name
ab:c ab_c-1 illegal character
As you see, the following transformations happen if a long name is illegal:
- *
- Illegal characters are replaces by underscores,
- *
- A -n number is generated,
Name clashes
When writing a file to disk, its long name or short name may collide with an already existing file or directory. This may happen for all commands which create new directory entries, such as mcopy, mmd, mren, mmove. When a name clash happens, mtools asks you what it should do. It offers several choices:- overwrite
- Overwrites the existing file. It is not possible to overwrite a directory with a file.
- rename
- Renames the newly created file. Mtools prompts for the new filename
- autorename
- Renames the newly created file. Mtools chooses a name by itself, without prompting
- skip
- Gives up on this file, and moves on to the next (if any)
- -D o
- Overwrites primary names by default.
- -D O
- Overwrites secondary names by default.
- -D r
- Renames primary name by default.
- -D R
- Renames secondary name by default.
- -D a
- Autorenames primary name by default.
- -D A
- Autorenames secondary name by default.
- -D s
- Skip primary name by default.
- -D S
- Skip secondary name by default.
- -D m
- Ask user what to do with primary name.
- -D M
- Ask user what to do with secondary name.
Case sensitivity of the VFAT file system
The VFAT file system is able to remember the case of the filenames. However, filenames which differ only in case are not allowed to coexist in the same directory. For example if you store a file called LongFileName on a VFAT file system, mdir shows this file as LongFileName, and not as Longfilename. However, if you then try to add LongFilename to the same directory, it is refused, because case is ignored for clash checks.high capacity formats
Mtools supports a number of formats which allow storage of more data on disk than usual. Due to different operating system abilities, these formats are not supported on all operating systems. Mtools recognizes these formats transparently where supported.http://www.fdutils.linux.lu/.
More sectors
The oldest method of fitting more data on a disk is to use more sectors and more cylinders. Although the standard format uses 80 cylinders and 18 sectors (on a 3 1/2 high density disk), it is possible to use up to 83 cylinders (on most drives) and up to 21 sectors. This method allows to store up to 1743K on a 3 1/2 HD disk. However, 21 sector disks are twice as slow as the standard 18 sector disks because the sectors are packed so close together that we need to interleave them. This problem doesn't exist for 20 sector formats.Bigger sectors
By using bigger sectors it is possible to go beyond the capacity which can be obtained by the standard 512-byte sectors. This is because of the sector header. The sector header has the same size, regardless of how many data bytes are in the sector. Thus, we save some space by using fewer, but bigger sectors. For example, 1 sector of 4K only takes up header space once, whereas 8 sectors of 512 bytes have also 8 headers, for the same amount of useful data.2m
The 2m format was originally invented by Ciriaco Garcia de Celis. It also uses bigger sectors than usual in order to fit more data on the disk. However, it uses the standard format (18 sectors of 512 bytes each) on the first cylinder, in order to make these disks easier to handle by DOS. Indeed this method allows you to have a standard sized boot sector, which contains a description of how the rest of the disk should be read.XDF
XDF is a high capacity format used by OS/2. It can hold 1840 K per disk. That's lower than the best 2m formats, but its main advantage is that it is fast: 600 milliseconds per track. That's faster than the 21 sector format, and almost as fast as the standard 18 sector format. In order to access these disks, make sure mtools has been compiled with XDF support, and set the use_xdf variable for the drive in the configuration file. See section Compiling mtools, and `miscellaneous variables', for details on how to do this. Fast XDF access is only available for Linux kernels which are more recent than 1.1.34.Exit codes
All the Mtools commands return 0 on success, 1 on utter failure, or 2 on partial failure. All the Mtools commands perform a few sanity checks before going ahead, to make sure that the disk is indeed an MS-DOS disk (as opposed to, say an ext2 or MINIX disk). These checks may reject partially corrupted disks, which might otherwise still be readable. To avoid these checks, set the MTOOLS_SKIP_CHECK environmental variable or the corresponding configuration file variable (see section global variables)Bugs
An unfortunate side effect of not guessing the proper device (when multiple disk capacities are supported) is an occasional error message from the device driver. These can be safely ignored.See also
floppyd_installtest mattrib mbadblocks mcd mcopy mdel mdeltree mdir mdu mformat minfo mkmanifest mlabel mmd mmount mmove mrd mren mshortname mshowfat mtoolstest mtype02Jun24 | mtools-4.0.44 |