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