1mtools(1)                   General Commands Manual                  mtools(1)
2
3
4

Name

6       mtools - utilities to access DOS disks in Unix.
7
8
9

Introduction

11       Mtools is a collection of tools to allow Unix systems to manipulate MS-
12       DOS files: read, write, and move around files on an MS-DOS file  system
13       (typically  a floppy disk).  Where reasonable, each program attempts to
14       emulate the MS-DOS equivalent command.  However,  unnecessary  restric‐
15       tions  and oddities of DOS are not emulated. For instance, it is possi‐
16       ble to move subdirectories from one subdirectory to another.
17
18       Mtools is sufficient to give access to MS-DOS file  systems.   For  in‐
19       stance, commands such as mdir a: work on the a: floppy without any pre‐
20       liminary   mounting   or   initialization   (assuming    the    default
21       `/etc/mtools.conf' works on your machine).  With mtools, one can change
22       floppies too without unmounting and mounting.
23

Where to get mtools

25       Mtools can be found at the following places (and their mirrors):
26
27          http://ftp.gnu.org/gnu/mtools/mtools-4.0.43.tar.gz
28
29
30
31       These patches are named mtools-version-ddmm.taz, where  version  stands
32       for  the  base  version,  dd for the day and mm for the month. Due to a
33       lack of space, I usually leave only the most recent patch.
34
35       There is an mtools mailing list at info-mtools @ gnu.org .  Please send
36       all  bug  reports  to  this  list.   You  may  subscribe to the list at
37       https://lists.gnu.org/mailman/listinfo/info-mtools. (N.B. Please remove
38       the  spaces  around  the  "@". I left them there in order to fool spam‐
39       bots.)  Announcements of new mtools versions will also be sent  to  the
40       list,  in  addition to the Linux announce newsgroups.  The mailing list
41       is archived at http://lists.gnu.org/pipermail/info-mtools/
42

Common features of all mtools commands

44   Options and filenames
45       MS-DOS filenames are composed of a drive letter followed by a colon,  a
46       subdirectory,  and a filename. Only the filename part is mandatory, the
47       drive letter and the subdirectory are  optional.  Filenames  without  a
48       drive letter refer to Unix files. Subdirectory names can use either the
49       '/' or '\' separator.  The use of the '\' separator  or  wildcards  re‐
50       quires  the  names  to  be  enclosed in quotes to protect them from the
51       shell. However, wildcards in Unix filenames should not be  enclosed  in
52       quotes, because here we want the shell to expand them.
53
54       The  regular  expression  "pattern  matching" routines follow the Unix-
55       style rules.  For example, `*' matches all  MS-DOS  files  in  lieu  of
56       `*.*'.   The  archive,  hidden, read-only and system attribute bits are
57       ignored during pattern matching.
58
59       All options use the - (minus) as their first character, not / as  you'd
60       expect in MS-DOS.
61
62       Most  mtools commands allow multiple filename parameters, which doesn't
63       follow MS-DOS conventions, but which is more user-friendly.
64
65       Most mtools commands allow options that instruct  them  how  to  handle
66       file name clashes. See section name clashes, for more details on these.
67
68       All  commands  accept the -i flag which allows to specify an image file
69       (See section drive letters).
70
71       All commands accept the -V flag which prints the version, and most  ac‐
72       cept  the  -v  flag,  which  switches on verbose mode. In verbose mode,
73       these commands print out the name of the MS-DOS files upon  which  they
74       act,  unless  stated otherwise. See section Commands, for a description
75       of the options which are specific to each command.
76
77   Drive letters
78       The meaning of the drive letters depends on the  target  architectures.
79       However,  on  most  target  architectures,  drive A is the first floppy
80       drive, drive B is the second floppy drive (if available), drive J is  a
81       Jaz  drive  (if  available), and drive Z is a Zip drive (if available).
82       On those systems where the device name is derived from the SCSI id, the
83       Jaz drive is assumed to be at SCSI target 4, and the Zip at SCSI target
84       5 (factory default settings).  On Linux, both drives are assumed to  be
85       the  second  drive on the SCSI bus (/dev/sdb). The default settings can
86       be changes using a configuration file (see section  Configuration).
87
88       The drive letter : (colon) has a special meaning. It is used to  access
89       image  files which are directly specified on the command line using the
90       -i options.
91
92       Example:
93
94           mcopy -i my-image-file.bin ::file1 ::file2 .
95
96
97
98       This copies file1 and file2 from the image file (my-image-file.bin)  to
99       the /tmp directory.
100
101       You can also supply an offset within the image file by including @@off‐
102       set into the file name.
103
104       Example:
105
106           mcopy -i my-image-file.bin@@1M ::file1 ::file2 .
107
108
109
110       This looks for the image at the offset of 1M in the file,  rather  than
111       at its beginning.
112
113   Current working directory
114       The mcd command (`mcd') is used to establish the device and the current
115       working directory (relative to the MS-DOS file system),  otherwise  the
116       default is assumed to be A:/. However, unlike MS-DOS, there is only one
117       working directory for all drives, and not one per drive.
118
119   VFAT-style long file names
120       This version of mtools supports VFAT style long filenames.  If  a  Unix
121       filename is too long to fit in a short DOS name, it is stored as a VFAT
122       long name, and a companion short name is generated. This short name  is
123       what you see when you examine the disk with a pre-7.0 version of DOS.
124        The following table shows some examples of short names:
125
126          Long name       MS-DOS name     Reason for the change
127          ---------       ----------      ---------------------
128          thisisatest     THISIS~1        filename too long
129          alain.knaff     ALAIN~1.KNA     extension too long
130          prn.txt         PRN~1.TXT       PRN is a device name
131          .abc            ABC~1           null filename
132          hot+cold        HOT_CO~1        illegal character
133
134
135
136        As  you  see,  the  following transformations happen to derive a short
137       name:
138
139       *      Illegal characters are  replaced  by  underscores.  The  illegal
140              characters are ;+=[]',\"*\\<>/?:|.
141
142       *      Extra dots, which cannot be interpreted as a main name/extension
143              separator are removed
144
145       *      A ~n number is generated,
146
147       *      The name is shortened so as to fit in the 8+3 limitation
148
149        The initial Unix-style file name  (whether  long  or  short)  is  also
150       called  the primary name, and the derived short name is also called the
151       secondary name.
152
153        Example:
154
155           mcopy /etc/motd a:Reallylongname
156
157        Mtools creates a VFAT entry for Reallylongname, and uses REALLYLO as a
158       short  name.  Reallylongname  is  the primary name, and REALLYLO is the
159       secondary name.
160
161           mcopy /etc/motd a:motd
162
163        Motd fits into  the  DOS  filename  limits.  Mtools  doesn't  need  to
164       derivate  another  name. Motd is the primary name, and there is no sec‐
165       ondary name.
166
167        In a nutshell: The primary name is the long name, if  one  exists,  or
168       the short name if there is no long name.
169
170        Although  VFAT  is  much more flexible than FAT, there are still names
171       that are not acceptable, even in VFAT. There  are  still  some  illegal
172       characters left (\"*\\<>/?:|), and device names are still reserved.
173
174          Unix name       Long name       Reason for the change
175          ---------       ----------      ---------------------
176          prn             prn-1           PRN is a device name
177          ab:c            ab_c-1          illegal character
178
179
180
181        As you see, the following transformations happen if a long name is il‐
182       legal:
183
184       *      Illegal characters are replaces by underscores,
185
186       *      A -n number is generated,
187
188   Name clashes
189       When writing a file to disk, its long name or short  name  may  collide
190       with  an  already  existing  file or directory. This may happen for all
191       commands which create new directory entries, such as mcopy, mmd,  mren,
192       mmove. When a name clash happens, mtools asks you what it should do. It
193       offers several choices:
194
195       overwrite
196              Overwrites the existing file. It is not possible to overwrite  a
197              directory with a file.
198
199       rename
200              Renames the newly created file. Mtools prompts for the new file‐
201              name
202
203       autorename
204              Renames the newly created file. Mtools chooses a name by itself,
205              without prompting
206
207       skip   Gives up on this file, and moves on to the next (if any)
208
209       To  chose one of these actions, type its first letter at the prompt. If
210       you use a lower case letter, the action  only  applies  for  this  file
211       only, if you use an upper case letter, the action applies to all files,
212       and you won't be prompted again.
213
214       You may also chose actions (for all files) on the  command  line,  when
215       invoking mtools:
216
217       -D o   Overwrites primary names by default.
218
219       -D O   Overwrites secondary names by default.
220
221       -D r   Renames primary name by default.
222
223       -D R   Renames secondary name by default.
224
225       -D a   Autorenames primary name by default.
226
227       -D A   Autorenames secondary name by default.
228
229       -D s   Skip primary name by default.
230
231       -D S   Skip secondary name by default.
232
233       -D m   Ask user what to do with primary name.
234
235       -D M   Ask user what to do with secondary name.
236
237       Note  that for command line switches lower/upper differentiates between
238       primary/secondary name whereas  for  interactive  choices,  lower/upper
239       differentiates between just-this-time/always.
240
241       The  primary name is the name as displayed in Windows 95 or Windows NT:
242       i.e. the long name if it exists, and the  short  name  otherwise.   The
243       secondary name is the "hidden" name, i.e. the short name if a long name
244       exists.
245
246       By default, the user is prompted if the primary name clashes,  and  the
247       secondary name is autorenamed.
248
249       If a name clash occurs in a Unix directory, mtools only asks whether to
250       overwrite the file, or to skip it.
251
252   Case sensitivity of the VFAT file system
253       The VFAT file system is able to remember the  case  of  the  filenames.
254       However, filenames which differ only in case are not allowed to coexist
255       in the same directory. For example if you store a file called LongFile‐
256       Name  on  a VFAT file system, mdir shows this file as LongFileName, and
257       not as Longfilename. However, if you then try to  add  LongFilename  to
258       the  same  directory,  it is refused, because case is ignored for clash
259       checks.
260
261       The VFAT file system allows you to store the case of a filename in  the
262       attribute  byte,  if all letters of the filename are the same case, and
263       if all letters of the extension are the same case too. Mtools uses this
264       information  when  displaying  the files, and also to generate the Unix
265       filename when mcopying to a Unix directory. This  may  have  unexpected
266       results  when applied to files written using an pre-7.0 version of DOS:
267       Indeed, the old style filenames map to all upper case. This is  differ‐
268       ent from the behavior of the old version of mtools which used to gener‐
269       ate lower case Unix filenames.
270
271   high capacity formats
272       Mtools supports a number of formats which allow storage of more data on
273       disk  than  usual.  Due  to different operating system abilities, these
274       formats are not supported on all operating systems.  Mtools  recognizes
275       these formats transparently where supported.
276
277       In  order  to  format  these disks, you need to use an operating system
278       specific tool. For Linux, suitable floppy tools can  be  found  in  the
279       fdutils package at the following locations~:
280
281          http://www.fdutils.linux.lu/.
282
283
284
285       See  the  manual pages included in that package for further detail: Use
286       superformat to format all formats except XDF, and use xdfcopy to format
287       XDF.
288
289     More sectors
290       The oldest method of fitting more data on a disk is to use more sectors
291       and more cylinders. Although the standard format uses 80 cylinders  and
292       18  sectors (on a 3 1/2 high density disk), it is possible to use up to
293       83 cylinders (on most drives) and up to 21 sectors. This method  allows
294       to  store  up to 1743K on a 3 1/2 HD disk. However, 21 sector disks are
295       twice as slow as the standard 18 sector disks because the  sectors  are
296       packed  so close together that we need to interleave them. This problem
297       doesn't exist for 20 sector formats.
298
299       These formats are supported by numerous DOS shareware utilities such as
300       fdformat  and vgacopy. In his infinite hubris, Bill Gate$ believed that
301       he invented this, and called it  `DMF  disks',  or  `Windows  formatted
302       disks'.  But  in  reality,  it has already existed years before! Mtools
303       supports these formats on Linux, on SunOS and on the DELL Unix PC.
304
305     Bigger sectors
306       By using bigger sectors it is possible to go beyond the capacity  which
307       can  be  obtained  by the standard 512-byte sectors. This is because of
308       the sector header. The sector header has the same size,  regardless  of
309       how  many data bytes are in the sector. Thus, we save some space by us‐
310       ing fewer, but bigger sectors. For example, 1 sector of 4K  only  takes
311       up  header space once, whereas 8 sectors of 512 bytes have also 8 head‐
312       ers, for the same amount of useful data.
313
314       This method permits storage of up to 1992K on a 3 1/2 HD disk.
315
316       Mtools supports these formats only on Linux.
317
318     2m
319       The 2m format was originally invented by Ciriaco Garcia  de  Celis.  It
320       also  uses  bigger  sectors than usual in order to fit more data on the
321       disk.  However, it uses the standard format (18 sectors  of  512  bytes
322       each)  on  the  first  cylinder, in order to make these disks easier to
323       handle by DOS. Indeed this method allows you to have a  standard  sized
324       boot  sector,  which contains a description of how the rest of the disk
325       should be read.
326
327       However, the drawback of this is that the first cylinder can hold  less
328       data  than  the  others. Unfortunately, DOS can only handle disks where
329       each track contains the same amount of data. Thus  2m  hides  the  fact
330       that  the  first  track contains less data by using a shadow FAT. (Usu‐
331       ally, DOS stores the  FAT  in  two  identical  copies,  for  additional
332       safety.   XDF  stores  only one copy, but tells DOS that it stores two.
333       Thus the space that would be taken up by the second FAT copy is saved.)
334       This  also  means that you should never use a 2m disk to store anything
335       else than a DOS file system.
336
337       Mtools supports these formats only on Linux.
338
339     XDF
340       XDF is a high capacity format used by OS/2. It  can  hold  1840  K  per
341       disk.  That's lower than the best 2m formats, but its main advantage is
342       that it is fast: 600 milliseconds per track. That's faster than the  21
343       sector  format, and almost as fast as the standard 18 sector format. In
344       order to access these disks, make sure mtools has  been  compiled  with
345       XDF support, and set the use_xdf variable for the drive in the configu‐
346       ration file. See section Compiling  mtools,  and  `miscellaneous  vari‐
347       ables',  for  details on how to do this. Fast XDF access is only avail‐
348       able for Linux kernels which are more recent than 1.1.34.
349
350       Mtools supports this format only on Linux.
351
352       Caution / Attention distributors: If mtools is compiled on a Linux ker‐
353       nel  more recent than 1.3.34, it won't run on an older kernel. However,
354       if it has been compiled on an older kernel, it still runs  on  a  newer
355       kernel,  except  that XDF access is slower. It is recommended that dis‐
356       tribution authors only include  mtools  binaries  compiled  on  kernels
357       older than 1.3.34 until 2.0 comes out. When 2.0 will be out, mtools bi‐
358       naries compiled on newer  kernels  may  (and  should)  be  distributed.
359       Mtools  binaries compiled on kernels older than 1.3.34 won't run on any
360       2.1 kernel or later.
361
362   Exit codes
363       All the Mtools commands return 0 on success, 1 on utter failure,  or  2
364       on  partial  failure.   All  the  Mtools  commands perform a few sanity
365       checks before going ahead, to make sure that the disk is indeed an  MS-
366       DOS  disk  (as opposed to, say an ext2 or MINIX disk). These checks may
367       reject partially corrupted disks, which might otherwise still be  read‐
368       able.  To  avoid  these checks, set the MTOOLS_SKIP_CHECK environmental
369       variable or the corresponding configuration file variable (see  section
370       global variables)
371
372   Bugs
373       An unfortunate side effect of not guessing the proper device (when mul‐
374       tiple disk capacities are supported) is  an  occasional  error  message
375       from the device driver.  These can be safely ignored.
376
377       The fat checking code chokes on 1.72 Mb disks mformatted with pre-2.0.7
378       mtools. Set the environmental variable MTOOLS_FAT_COMPATIBILITY (or the
379       corresponding  configuration  file variable, `global variables') to by‐
380       pass the fat checking.
381

See also

383       floppyd_installtest mattrib mbadblocks mcd mcopy mdel mdeltree mdir mdu
384       mformat  minfo  mkmanifest  mlabel mmd mmount mmove mrd mren mshortname
385       mshowfat mtoolstest mtype
386
387
388
389mtools-4.0.43                       21Mar23                          mtools(1)
Impressum