blob: b9a127ac1d27634a2da9595b1bf0f3c845659dde [file] [log] [blame]
Alistair Delvabeaee832021-02-24 11:27:23 -08001'\" t
2.TH mtools 1 "28Nov20" mtools-4.0.26
3.SH Name
4mtools - utilities to access DOS disks in Unix.
5'\" t
6.de TQ
7.br
8.ns
9.TP \\$1
10..
11
12.tr \(is'
13.tr \(if`
14.tr \(pd"
15
16.PP
17.SH Introduction
18Mtools is a collection of tools to allow Unix systems to manipulate
19MS-DOS files: read, write, and move around files on an MS-DOS
20file system (typically a floppy disk). Where reasonable, each program
21attempts to emulate the MS-DOS equivalent command. However,
22unnecessary restrictions and oddities of DOS are not emulated. For
23instance, it is possible to move subdirectories from one subdirectory
24to another.
25.PP
26Mtools is sufficient to give access to MS-DOS file systems. For
27instance, commands such as \fR\&\f(CWmdir a:\fR work on the \fR\&\f(CWa:\fR floppy
28without any preliminary mounting or initialization (assuming the default
29\&\fR\&\f(CW\(if/etc/mtools.conf\(is\fR works on your machine). With mtools, one can
30change floppies too without unmounting and mounting.
31.PP
32.SH Where\ to\ get\ mtools
33.PP
34Mtools can be found at the following places (and their mirrors):
35
36.nf
37.ft 3
38.in +0.3i
39http://ftp.gnu.org/gnu/mtools/mtools-4.0.26.tar.gz
40.fi
41.in -0.3i
42.ft R
43.PP
44
45\&\fR
46.PP
47These patches are named
48\&\fR\&\f(CWmtools-\fR\fIversion\fR\fR\&\f(CW-\fR\fIddmm\fR\fR\&\f(CW.taz\fR, where version
49stands for the base version, \fIdd\fR for the day and \fImm\fR for the
50month. Due to a lack of space, I usually leave only the most recent
51patch.
52.PP
53There is an mtools mailing list at info-mtools @ gnu.org . Please
54send all bug reports to this list. You may subscribe to the list at
55https://lists.gnu.org/mailman/listinfo/info-mtools. (N.B. Please
56remove the spaces around the "@". I left them there in order to fool
57spambots.) Announcements of new mtools versions will also be sent to
58the list, in addition to the Linux announce newsgroups. The mailing
59list is archived at http://lists.gnu.org/pipermail/info-mtools/
60.PP
61.SH Common\ features\ of\ all\ mtools\ commands
62.PP
63.SS Options\ and\ filenames
64MS-DOS filenames are composed of a drive letter followed by a colon, a
65subdirectory, and a filename. Only the filename part is mandatory, the
66drive letter and the subdirectory are optional. Filenames without a
67drive letter refer to Unix files. Subdirectory names can use either the
68\&'\fR\&\f(CW/\fR' or '\fR\&\f(CW\e\fR' separator. The use of the '\fR\&\f(CW\e\fR' separator
69or wildcards requires the names to be enclosed in quotes to protect them
70from the shell. However, wildcards in Unix filenames should not be
71enclosed in quotes, because here we \fBwant\fR the shell to expand
72them.
73.PP
74The regular expression "pattern matching" routines follow the Unix-style
75rules. For example, `\fR\&\f(CW*\fR' matches all MS-DOS files in lieu of
76`\fR\&\f(CW*.*\fR'. The archive, hidden, read-only and system attribute bits
77are ignored during pattern matching.
78.PP
79All options use the \fR\&\f(CW-\fR (minus) as their first character, not
80\&\fR\&\f(CW/\fR as you'd expect in MS-DOS.
81.PP
82Most mtools commands allow multiple filename parameters, which
83doesn't follow MS-DOS conventions, but which is more user-friendly.
84.PP
85Most mtools commands allow options that instruct them how to handle file
86name clashes. See section name clashes, for more details on these. All
87commands accept the \fR\&\f(CW-V\fR flags which prints the version, and most
88accept the \fR\&\f(CW-v\fR flag, which switches on verbose mode. In verbose
89mode, these commands print out the name of the MS-DOS files upon which
90they act, unless stated otherwise. See section Commands, for a description of
91the options which are specific to each command.
92.PP
93.SS Drive\ letters
94.PP
95The meaning of the drive letters depends on the target architectures.
96However, on most target architectures, drive A is the first floppy
97drive, drive B is the second floppy drive (if available), drive J is a
98Jaz drive (if available), and drive Z is a Zip drive (if available). On
99those systems where the device name is derived from the SCSI id, the Jaz
100drive is assumed to be at SCSI target 4, and the Zip at SCSI target 5
101(factory default settings). On Linux, both drives are assumed to be the
102second drive on the SCSI bus (/dev/sdb). The default settings can be
103changes using a configuration file (see section Configuration).
104.PP
105The drive letter : (colon) has a special meaning. It is used to access
106image files which are directly specified on the command line using the
107\&\fR\&\f(CW-i\fR options.
108.PP
109Example:
110
111.nf
112.ft 3
113.in +0.3i
114 mcopy -i my-image-file.bin ::file1 ::file2 .
115.fi
116.in -0.3i
117.ft R
118.PP
119
120\&\fR
121.PP
122This copies \fR\&\f(CWfile1\fR and \fR\&\f(CWfile2\fR from the image file
123(\fR\&\f(CWmy-image-file.bin\fR) to the \fR\&\f(CW/tmp\fR directory.
124.PP
125You can also supply an offset within the image file by including
126\&\fR\&\f(CW@@\fR\fIoffset\fR into the file name.
127.PP
128Example:
129
130.nf
131.ft 3
132.in +0.3i
133 mcopy -i my-image-file.bin@@1M ::file1 ::file2 .
134.fi
135.in -0.3i
136.ft R
137.PP
138
139\&\fR
140.PP
141This looks for the image at the offset of 1M in the file, rather than
142at its beginning.
143.PP
144.SS Current\ working\ directory
145.PP
146The \fR\&\f(CWmcd\fR command (\(ifmcd\(is) is used to establish the device and
147the current working directory (relative to the MS-DOS file system),
148otherwise the default is assumed to be \fR\&\f(CWA:/\fR. However, unlike
149MS-DOS, there is only one working directory for all drives, and not one
150per drive.
151.PP
152.SS VFAT-style\ long\ file\ names
153.PP
154This version of mtools supports VFAT style long filenames. If a Unix
155filename is too long to fit in a short DOS name, it is stored as a
156VFAT long name, and a companion short name is generated. This short
157name is what you see when you examine the disk with a pre-7.0 version
158of DOS.
159 The following table shows some examples of short names:
160.PP
161
162.nf
163.ft 3
164.in +0.3i
165Long name MS-DOS name Reason for the change
166--------- ---------- ---------------------
167thisisatest THISIS~1 filename too long
168alain.knaff ALAIN~1.KNA extension too long
169prn.txt PRN~1.TXT PRN is a device name
170\&\&.abc ABC~1 null filename
171hot+cold HOT_CO~1 illegal character
172.fi
173.in -0.3i
174.ft R
175.PP
176
177\&\fR
178.PP
179 As you see, the following transformations happen to derive a short
180name:
181.TP
182* \ \
183Illegal characters are replaced by underscores. The illegal characters
184are \fR\&\f(CW;+=[]',\e"*\e\e<>/?:|\fR.
185.TP
186* \ \
187Extra dots, which cannot be interpreted as a main name/extension
188separator are removed
189.TP
190* \ \
191A \fR\&\f(CW~\fR\fIn\fR number is generated,
192.TP
193* \ \
194The name is shortened so as to fit in the 8+3 limitation
195.PP
196 The initial Unix-style file name (whether long or short) is also called
197the \fIprimary\fR name, and the derived short name is also called the
198\&\fIsecondary\fR name.
199.PP
200 Example:
201
202.nf
203.ft 3
204.in +0.3i
205 mcopy /etc/motd a:Reallylongname
206.fi
207.in -0.3i
208.ft R
209.PP
210
211\&\fR Mtools creates a VFAT entry for Reallylongname, and uses REALLYLO as
212a short name. Reallylongname is the primary name, and REALLYLO is the
213secondary name.
214
215.nf
216.ft 3
217.in +0.3i
218 mcopy /etc/motd a:motd
219.fi
220.in -0.3i
221.ft R
222.PP
223
224\&\fR Motd fits into the DOS filename limits. Mtools doesn't need to
225derivate another name. Motd is the primary name, and there is no
226secondary name.
227.PP
228 In a nutshell: The primary name is the long name, if one exists, or
229the short name if there is no long name.
230.PP
231 Although VFAT is much more flexible than FAT, there are still names
232that are not acceptable, even in VFAT. There are still some illegal
233characters left (\fR\&\f(CW\e"*\e\e<>/?:|\fR), and device names are still
234reserved.
235.PP
236
237.nf
238.ft 3
239.in +0.3i
240Unix name Long name Reason for the change
241--------- ---------- ---------------------
242prn prn-1 PRN is a device name
243ab:c ab_c-1 illegal character
244.fi
245.in -0.3i
246.ft R
247.PP
248
249\&\fR
250.PP
251 As you see, the following transformations happen if a long name is
252illegal:
253.TP
254* \ \
255Illegal characters are replaces by underscores,
256.TP
257* \ \
258A \fR\&\f(CW-\fR\fIn\fR number is generated,
259.PP
260.SS Name\ clashes
261.PP
262When writing a file to disk, its long name or short name may collide
263with an already existing file or directory. This may happen for all
264commands which create new directory entries, such as \fR\&\f(CWmcopy\fR,
265\&\fR\&\f(CWmmd\fR, \fR\&\f(CWmren\fR, \fR\&\f(CWmmove\fR. When a name clash happens, mtools
266asks you what it should do. It offers several choices:
267.TP
268\&\fR\&\f(CWoverwrite\fR\
269Overwrites the existing file. It is not possible to overwrite a
270directory with a file.
271.TP
272\&\fR\&\f(CWrename\fR\
273Renames the newly created file. Mtools prompts for the new filename
274.TP
275\&\fR\&\f(CWautorename\fR\
276Renames the newly created file. Mtools chooses a name by itself, without
277prompting
278.TP
279\&\fR\&\f(CWskip\fR\
280Gives up on this file, and moves on to the next (if any)
281.PP
282To chose one of these actions, type its first letter at the prompt. If
283you use a lower case letter, the action only applies for this file only,
284if you use an upper case letter, the action applies to all files, and
285you won't be prompted again.
286.PP
287You may also chose actions (for all files) on the command line, when
288invoking mtools:
289.TP
290\&\fR\&\f(CW-D\ o\fR\
291Overwrites primary names by default.
292.TP
293\&\fR\&\f(CW-D\ O\fR\
294Overwrites secondary names by default.
295.TP
296\&\fR\&\f(CW-D\ r\fR\
297Renames primary name by default.
298.TP
299\&\fR\&\f(CW-D\ R\fR\
300Renames secondary name by default.
301.TP
302\&\fR\&\f(CW-D\ a\fR\
303Autorenames primary name by default.
304.TP
305\&\fR\&\f(CW-D\ A\fR\
306Autorenames secondary name by default.
307.TP
308\&\fR\&\f(CW-D\ s\fR\
309Skip primary name by default.
310.TP
311\&\fR\&\f(CW-D\ S\fR\
312Skip secondary name by default.
313.TP
314\&\fR\&\f(CW-D\ m\fR\
315Ask user what to do with primary name.
316.TP
317\&\fR\&\f(CW-D\ M\fR\
318Ask user what to do with secondary name.
319.PP
320Note that for command line switches lower/upper differentiates between
321primary/secondary name whereas for interactive choices, lower/upper
322differentiates between just-this-time/always.
323.PP
324The primary name is the name as displayed in Windows 95 or Windows NT:
325i.e. the long name if it exists, and the short name otherwise. The
326secondary name is the "hidden" name, i.e. the short name if a long name
327exists.
328.PP
329By default, the user is prompted if the primary name clashes, and the
330secondary name is autorenamed.
331.PP
332If a name clash occurs in a Unix directory, mtools only asks whether
333to overwrite the file, or to skip it.
334.PP
335.SS Case\ sensitivity\ of\ the\ VFAT\ file\ system
336.PP
337The VFAT file system is able to remember the case of the
338filenames. However, filenames which differ only in case are not allowed
339to coexist in the same directory. For example if you store a file called
340LongFileName on a VFAT file system, mdir shows this file as LongFileName,
341and not as Longfilename. However, if you then try to add LongFilename to
342the same directory, it is refused, because case is ignored for clash
343checks.
344.PP
345The VFAT file system allows you to store the case of a filename in the
346attribute byte, if all letters of the filename are the same case, and if
347all letters of the extension are the same case too. Mtools uses this
348information when displaying the files, and also to generate the Unix
349filename when mcopying to a Unix directory. This may have unexpected
350results when applied to files written using an pre-7.0 version of DOS:
351Indeed, the old style filenames map to all upper case. This is different
352from the behavior of the old version of mtools which used to generate
353lower case Unix filenames.
354.PP
355.SS high\ capacity\ formats
356.PP
357Mtools supports a number of formats which allow storage of more data on
358disk than usual. Due to different operating system abilities, these
359formats are not supported on all operating systems. Mtools recognizes
360these formats transparently where supported.
361.PP
362In order to format these disks, you need to use an operating system
363specific tool. For Linux, suitable floppy tools can be found in the
364\&\fR\&\f(CWfdutils\fR package at the following locations~:
365
366.nf
367.ft 3
368.in +0.3i
369\&\fR\&\f(CWhttp://www.fdutils.linux.lu/.
370.fi
371.in -0.3i
372.ft R
373.PP
374
375\&\fR
376.PP
377See the manual pages included in that package for further detail: Use
378\&\fR\&\f(CWsuperformat\fR to format all formats except XDF, and use
379\&\fR\&\f(CWxdfcopy\fR to format XDF.
380.PP
381.SS \ \ More\ sectors
382.PP
383The oldest method of fitting more data on a disk is to use more sectors
384and more cylinders. Although the standard format uses 80 cylinders and
38518 sectors (on a 3 1/2 high density disk), it is possible to use up to
38683 cylinders (on most drives) and up to 21 sectors. This method allows
387to store up to 1743K on a 3 1/2 HD disk. However, 21 sector disks are
388twice as slow as the standard 18 sector disks because the sectors are
389packed so close together that we need to interleave them. This problem
390doesn't exist for 20 sector formats.
391.PP
392These formats are supported by numerous DOS shareware utilities such as
393\&\fR\&\f(CWfdformat\fR and \fR\&\f(CWvgacopy\fR. In his infinite hubris, Bill Gate$
394believed that he invented this, and called it \fR\&\f(CW\(ifDMF disks\(is\fR, or
395\&\fR\&\f(CW\(ifWindows formatted disks\(is\fR. But in reality, it has already existed
396years before! Mtools supports these formats on Linux, on SunOS and on
397the DELL Unix PC.
398.PP
399.SS \ \ Bigger\ sectors
400By using bigger sectors it is possible to go beyond the capacity which
401can be obtained by the standard 512-byte sectors. This is because of the
402sector header. The sector header has the same size, regardless of how
403many data bytes are in the sector. Thus, we save some space by using
404\&\fIfewer\fR, but bigger sectors. For example, 1 sector of 4K only takes
405up header space once, whereas 8 sectors of 512 bytes have also 8
406headers, for the same amount of useful data.
407.PP
408This method permits storage of up to 1992K on a 3 1/2 HD disk.
409.PP
410Mtools supports these formats only on Linux.
411.PP
412.SS \ \ 2m
413.PP
414The 2m format was originally invented by Ciriaco Garcia de Celis. It
415also uses bigger sectors than usual in order to fit more data on the
416disk. However, it uses the standard format (18 sectors of 512 bytes
417each) on the first cylinder, in order to make these disks easier to
418handle by DOS. Indeed this method allows you to have a standard sized
419boot sector, which contains a description of how the rest of the disk
420should be read.
421.PP
422However, the drawback of this is that the first cylinder can hold less
423data than the others. Unfortunately, DOS can only handle disks where
424each track contains the same amount of data. Thus 2m hides the fact that
425the first track contains less data by using a \fIshadow
426FAT\fR. (Usually, DOS stores the FAT in two identical copies, for
427additional safety. XDF stores only one copy, but tells DOS that it
428stores two. Thus the space that would be taken up by the second FAT copy
429is saved.) This also means that you should \fBnever use a 2m disk
430to store anything else than a DOS file system\fR.
431.PP
432Mtools supports these formats only on Linux.
433.PP
434.SS \ \ XDF
435.PP
436XDF is a high capacity format used by OS/2. It can hold 1840 K per
437disk. That's lower than the best 2m formats, but its main advantage is
438that it is fast: 600 milliseconds per track. That's faster than the 21
439sector format, and almost as fast as the standard 18 sector format. In
440order to access these disks, make sure mtools has been compiled with XDF
441support, and set the \fR\&\f(CWuse_xdf\fR variable for the drive in the
442configuration file. See section Compiling mtools, and \(ifmiscellaneous variables\(is,
443for details on how to do this. Fast XDF access is only available for
444Linux kernels which are more recent than 1.1.34.
445.PP
446Mtools supports this format only on Linux.
447.PP
448\&\fBCaution / Attention distributors\fR: If mtools is compiled on a
449Linux kernel more recent than 1.3.34, it won't run on an older
450kernel. However, if it has been compiled on an older kernel, it still
451runs on a newer kernel, except that XDF access is slower. It is
452recommended that distribution authors only include mtools binaries
453compiled on kernels older than 1.3.34 until 2.0 comes out. When 2.0 will
454be out, mtools binaries compiled on newer kernels may (and should) be
455distributed. Mtools binaries compiled on kernels older than 1.3.34 won't
456run on any 2.1 kernel or later.
457.PP
458.SS Exit\ codes
459All the Mtools commands return 0 on success, 1 on utter failure, or 2
460on partial failure. All the Mtools commands perform a few sanity
461checks before going ahead, to make sure that the disk is indeed an
462MS-DOS disk (as opposed to, say an ext2 or MINIX disk). These checks
463may reject partially corrupted disks, which might otherwise still be
464readable. To avoid these checks, set the MTOOLS_SKIP_CHECK
465environmental variable or the corresponding configuration file variable
466(see section global variables)
467.SS Bugs
468An unfortunate side effect of not guessing the proper device (when
469multiple disk capacities are supported) is an occasional error message
470from the device driver. These can be safely ignored.
471.PP
472The fat checking code chokes on 1.72 Mb disks mformatted with pre-2.0.7
473mtools. Set the environmental variable MTOOLS_FAT_COMPATIBILITY (or the
474corresponding configuration file variable, \(ifglobal variables\(is) to
475bypass the fat checking.
476.PP
477.SH See also
478floppyd_installtest
479mattrib
480mbadblocks
481mcd
482mclasserase
483mcopy
484mdel
485mdeltree
486mdir
487mdu
488mformat
489minfo
490mkmanifest
491mlabel
492mmd
493mmount
494mmove
495mrd
496mren
497mshortname
498mshowfat
499mtoolstest
500mtype