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