Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By

The mtools Package

The mtools package, originally by Emmet P. Gray and now maintained by Alain Knaff and David Niemi, is a public-domain set of programs you can use in just about any operation on MS-DOS floppies. The mtools package can help you when working with the DOS or Windows operating system while running Linux, and facilitate the transfer of information and manipulation of removable media for those operating systems.

These commands are useful because you don't need to reboot to DOS or Windows, run an emulator, or mount the floppy in order to read, write, or make changes to the floppy's contents. Table 28.3 lists the tools included in the package.

Table 28.3. mtools Package Contents

Program Name Function
mattrib Changes file attributes
mbadblocks Floppy testing program
mcd Changes directory command
mcheck Checks a floppy
mcopy Copies files to and from floppy disk
mdel Deletes files on disk
mdeltree Recursively deletes files and directories
mdir Lists contents of a floppy
mformat Formats a floppy
minfo Categorizes, prints floppy characteristics
mkmanifest Restores Linux filenames from floppy
mlabel Labels a floppy
mmd Creates subdirectory
mmount Mounts a floppy
mmove mv command for floppy files and directories
mpartition Makes a DOS filesystem as a partition
mrd Deletes directories
mren Renames a file
mtoolstest Tests mtools package installation
mtype Types (lists) a file
mzip ZIP/JAZ drive utility

The most often used will be the mformat, mdir, mcopy, and mdel commands. The mformat command formats nearly any type of floppy device. One of this software package's nice features is that you don't have to remember the specific names of floppy devices, such as /dev/fd0, and can use the (possibly) familiar A or B drive designators. This is possible because of mtool's use of the configuration file, /etc/mtools.conf.

Entries for different disk devices are listed in the file. You can edit the file (as root) to configure mtools for your system without having to rebuild the software. (If you need the source, however, you can readily find a copy on your favorite Linux site, or at ftp://ftp.tux.org/pub/knaff/mtools, along with numerous add-ons and utilities.) If you examine the /etc/mtools.conf file, you'll see entries for different devices and configurations for other operating systems. For example, the floppy device entries look like this:

# Linux floppy drives
drive a: file="/dev/fd0" exclusive 1.44m mformat_only
drive b: file="/dev/fd1" exclusive 1.44m mformat only

These entries allow you to easily format a floppy in drive A without mounting the disk:


   # mformat a:

After the mformat command has finished, you can copy files to and from the disk with the mcopy command. Here is an example:


   # mcopy *.txt a:

This copies all files ending in .txt to your disk. To copy files from your disk, reverse the arguments (in DOS form) to the mcopy command:


   # mcopy a:*.txt

This copies all files ending in .txt to the current directory, or to whatever directory you specify. To see what is on the disk, use the mdir command. Here is an example:


   # mdir a

 Volume in drive A has no label
 Volume Serial Number is 4917-9EDD

Directory for A:/
launch   gif     62835 04-09-1999  13:43  launch.gif
vmware   gif     10703 04-09-1999  13:44  vmware.gif
vnc      gif     21487 04-09-1999  13:44  vnc.gif
        3 files              95 025 bytes
                          1 362 432 bytes free

You can use the mlabel command to label the disk:


   # mlabel a:
 Volume has no label
Enter the new volume label : LINUX

You can also use special shell command-line quoting to label the disk from the command line:


   # mlabel a:'DOS DISK'

This is a handy way to use spaces in a disk's label. If you want to delete files on your disk, use the mdel command:


   # mdel a:*.txt

This deletes all files ending in .txt on the disk in the A drive. You can also mount your disk. For details, see the mmount command manual page, along with the mount command manual page.

Share ThisShare This