MNT and UNMOUNT: Two little Utilities for Windows NT for safely removing drives and/or media from your system and other puposes

Please read this documentation completely or "unwanted" actions may appear on your computer. MNT and UNMOUNT are utilities for the power user and DO WHAT YOU TELL THEM. There are no "ARE YOU SURE?" questions.

Usage Instructions

The legal stuff is put at the end of the documentation. You don't do something illegal by testing the utilities. So read the usage instructions and try out these utilities.

I have written these Utilities to allow safe removal of removable media, such as magneto-optical disk, bernoulli disks, a Syquest disk or similar devices. When you have NTFS on a removable disk, you are not allowed to simply remove the media, when there are still open files. In case of FAT, Windows NT allows the removal of the media, but it is not recommended to do so, if there are still open files. HPFS is even more sensitive to media removal, so Windows NT does not allow formatting removable disks with HPFS, neither does OS/2.

Because UNMOUNT.EXE uses MNT.EXE as a DLL, it is required to have MNT.EXE in the same directory as UNMOUNT.EXE. Otherwise UNMOUNT.EXE does not work.

One common method of removing disks with NTFS filesystem is to run CHKDSK /F on the drive and afterwards removal is allowed by pressing the eject button, but this is quite time consuming.

UNMOUNT is a utility, which helps is this case. You simply type UNMOUNT <drive>: to eject the media. This works on all removable media (even on CD-ROMs). UNMOUNT tries to lock the drive for exclusive use. If this is successful, UNMOUNT will dismount the drive and then eject the media. If there are still open files on the disk or another process (e.g. FORMAT) has locked the drive exclusively, locking fails and the program will exit.

You can specifiy UNMOUNT -l <drive>: This will retry locking the drive continously, until you press CTRL-C or CTRL-BREAK. In the meantime you can close programs, which are currently accessing the drive, e.g. the File Manager or go to the Command Prompt and switch to another driver, e.g. by typing C: on the command line.

You can also try UNMOUNT -a -l <drive>: This will delete the drive letter definition after locking the drive. This is useful, when you want to ensure, that no process can access the drive after it has been removed and prevents error dialogs like "There is no disk in the drive (A)bort, (R)etry, (I)gnore". You need MNT to redefine the drive letter again (described later).

You can also delete the drive letter before you attempt to lock the drive. This is useful, if there are processes, that want to open files on your removable drive, while you are going to lock and eject your media. To do so type UNMOUNT -b -a -l <drive:> or simply UNMOUNT -bal <drive:>. After you typed that, the drive letter definition is removed immediately, but processes, that already had open files can still use these files and close them correctly.

To see other options, type UNMOUNT -?

You can also use UNMOUNT for removing external fixed disks, e.g. an external SCSI-harddisk and afterwards connecting it to another computer without shutting down either of these computers. When you remove an external SCSI-device, the SCSI-bus will be not properly terminated for a while. Windows NT, unlike other operating systems, will recover from this situation, after you terminated the SCSI-bus again.

For non removable drives UNMOUNT will default to remove the drive letter definition. If you don't want to remove the drive letter definition, use UNMOUNT -d <drive>: This option is unlikely to make sense, because after dismounting a drive, if the drive letter is still defined, accessing the drive will remount it, and the drive should not be removed.

Some (but not all) SCSI-harddisks support "ejecting" the media, which, of course, does not result in physically ejecting some magnetic slices, but rather in shutting off the drive's motor. This is quite useful, because as long the motor is turned off (you will hear that in most cases), you can safely remove your harddisk from the computer. If you don't want the motor to be turned off, use UNMOUNT -e <drive>:

There are some considerations, when you have a drive with multiple partitions on it. First, of course, to remove a drive with multiple partitions, you have to unmount all partitions. The second considertion is to use the -e option, e.g. UNMOUNT -bel <drive>: except on the last partition on your drive. This is important, since your motor will shut off and will be immediately restarted, if another partition on your drive will be used by a process.

UNMOUNT is a utility, that does what you tell it. E.g. If you have Windows NT on drive C: and you type UNMOUNT -bel C:, then drive C: will be immediately gone. Period. You will have to use MNT to redefine C:. If MNT was also on C: you will have to Shutdown by pressing Ctrl-Alt-Del and then select shutdown. So be careful and use UNMOUNT -el C: instead.

MNT is a utility to define drive letters to their real Windows NT device names. With Windows NT the drive letters are links (aliases) to Windows NT device names. Typical Windows NT device names are \Device\Harddisk0\Partition1, \Device\CdRom0 or \Device\Floppy0.

Typing MNT without any parameters will show you the current assignments. Please note, that all numbers are zero based. I.e. the first Harddisk is Harddisk0 and the first CD-ROM is CdRom0. Partitions also start with Partition0, but Partition0 is the partition table itself, so the first "real" partition is Partition1. Thus the first partition on your first harddisk is \Device\Harddisk0\Partition1.

To manually define a partition, e.g. because you have undefined it using UNMOUNT, simply type MNT <drive>: <devicename>, e.g. MNT H: \Device\Harddisk2\Partition1. The device names are not case sensitive. MNT allows you to define whatever you want. E.g. you can type MNT X: \I\am\an\idiot and this will not result in an error. But typing DIR X: will result in an "The system cannot find the drive specified" error.

If you define a drive letter, that is already defined, this will neither result in an error nor overwrite the current definition. Instead the old definition will be put on a stack and the new definition will come into effect. When you undefine the current definition, the current definition will be discarded and the last definition will be recent again. MNT without parameters shows you all definitions for a drive in a seperate line. The topmost line for a drive is the recent definition.

To undefine a drive use MNT -u <drive>: Unlike UNMOUNT, only the definition is removed. The drive is not ready for removal. So use UNMOUNT, if you want to remove a drive or media. Like UNMOUNT, MNT will do what you say. So MNT -U C: removes the current definition of C: without asking anything.

Another option is -z. MNT -z <drive>: works like MNT -u <drive>: except that -z causes all definitions for a drive letter to be removed. Example: Type MNT Z: \Device\Cdrom0, then MNT Z: \Device\Harddisk0\Partition1. Z: is now your first partition on your first harddisk. After typing MNT -u Z: Z: will be your CD-ROM drive. If you would use MNT -z Z: instead, Z: would be undefined.

There are other definitions, you can use with MNT. E.g., if C: is defined as \Device\Harddisk0\Partition1, you can define MNT X: \Device\Harddisk0\Partition1\DOS, then X:\ is the same as C:\DOS. You could also define MNT X: \DosDevices\C:\DOS. However, there is a slight difference. If you define via the DosDevice method, then the definition of X: changes, if you redefine C:, whereas this is not the case, when you define X: with the \Device\Harddisk... method.

The Windows NT external command SUBST.EXE does nothing else as defining drive letters via the DosDevices method. Typing SUBST X: C:\DOS is the same as typing MNT X: \DosDevices\C:\DOS.

When you are in a LAN environment, you can also use MNT to define network drive letters. This is done by typing MNT <drive>: \Device\Mup\Server\Sharename\subdirectory. E.g. MNT X: \Device\Mup\MyServer\MyShare is virtually identical to NET USE X: \\MyServer\MyShare. MNT allows two things NET USE does not allow: The first is the definition of subdirectories of a share. E.g. MNT X: \Device\Mup\MyServer\MyShare\subdir1 is a valid and working definition, whereas NET USE X: \\MyServer\MyShare\subdir1 only works with Novell Servers, but does not work with Microsoft or NFS Servers. The \Device\Mup\... definition can be used with any networking client you have installed (Microsoft, Novell, Bayon Vines, NFS, etc.)


Legal stuff

This program comes without any warranty either implied or expressed. In no case shall the author be liable for any damage or unwanted behavior of any computer hardware and/or software.

This program is put into the public domain. Everybody can do whatever he/she likes with the source code or the any other file of this program. If you do modify the program, then you must include some kind of document, which indicates, that this is not the original version, but a modified version. You should also say, what kind of modification you did.

Although the author is working for Microsoft, this is not Microsoft Software. The program has been written in the author's free time and is unrelated to his work at Microsoft.


The author

You can reach me in case of questions, comments, additions/modifications to the program:

snail mail:	Christoph H. Hochstaetter
		Schlierseestrasse 59
		D-81539 Munich
		Germany

Phone:		+49-89-6912343 (Germany is located in Central Europe and our Time Zone
		is GMT+1. So please don't call at 3:00 a.m. Central European Time)
Fax:		+49-89-3176-3710

e-mail:		christoh@microsoft.com
		If you are using Compuserve, Microsoft Network, AOL, GENIE or similar,
		please contact customer service, how to send mail to the Internet.

If you find this program useful, you may send money (no upper limit!!!), but this is not a must. Simply send cash, check, etc. to my snail mail address or to my bank account #0614020800 at the Dresdner Bank AG, bank routing number (only from Germany and the Kleinwalsertal, Austria) is 700 800 00. From outside Germany use the S.W.I.F.T code DRESDEFF700.

Instead of money, you may also send postcards, diskettes with software you wrote and other gimmicks.

If you want to make a donation, please note. There is no registration, printed documentation, phone support, free automatic upgrade to next version, etc. If you have questions send it to me and I'll try to answer to anyone as time permits.


Rebuilding MNT.EXE and UNMOUNT.EXE

For those of you, who want to hack on MNT.EXE and UNMOUNT.EXE: This release has been built with Visual C++ Version 2.0. However, I have used CRTDLL.DLL as C Run-Time-Library. This means, the executables are small, since the C Run-Time-Code is present on any Windows NT machine in %SystemRoot%\System32\CRTDLL.DLL and you don't have to install MSVCRT20.DLL. To link using CRTDLL.DLL you not only need Visual C++ 2.0, but also the Windows NT SDK. If you don't have the SDK, you must either statically link or the user must have MSVCRT20.DLL installed.

The executables are optimized for size. I wanted to keep it as small as possible. I think speed is not important in this case.
re is a slight difference. If you define via the DosDevice method, then the definition of X: changes, if you used with any networking client you have installed (Microsoft, Novell, Bayon Vines, NFS, etc.)


Legal stuff
