MHDD Documentation


Copyright and Disclaimer

This manual cannot be sold or published anywhere. As I am trying to make it useful, it is much better to give a link to this page instead of copying something from here.

You may distribute MHDD without any limitations while you preserve copyrights. You can disassemble (reverse-engineer) MHDD for educational purposes. You cannot sell MHDD program or any its part.

© 2005 Dmitry Postrigan

DISCLAIMER: Use this software as is. MHDD is powerful, but very dangerous program and nobody is responsible for any damage or data loss made by MHDD.


Contents



About the MHDD project

MHDD is the small and powerful freeware tool to work with hard drives at the lowest possible level. First version was released in 2000 by me, Dmitry Postrigan. It was able to make surface scan of an IDE drive in CHS mode. My main objective was to develop well-known and trusted HDD diagnostic tool.

Now MHDD is much more than just diagnostic. You can do anything with MHDD: diagnose your drive, access raw sectors, manage S.M.A.R.T. (SMART) and other drive parameters such as acoustic management, security, Host Protected Area. You can even send your own commands to a drive using very simple linear scripting engine.


Getting MHDD

When you need fresh copy of MHDD, please always use http://mhdd.com website. You can get MHDD as CD image, as self-extracting floppy image or as archive.

Documentation is web-based to make it always up-to-date.


What is inside of MHDD package

mhdd.exe  Main executable
mhdd.hlp  This file is used by MHDD to display help
batch/sample.mba  Sample batch script to run tests without an operator
scripts/test  Sample script for sending commands
cfg/mhdd.cfg  Here MHDD stores its configuration
After the first run log/mhdd.log file will be created automatically. This is the main log file, everything is logged there.

If you download and extract a boot floppy or CD image you will have DR-DOS system files too.


How it works

Let's imagine how MSDOS works when it needs to read a sector from a drive — it simply asks the BIOS to do that. Then BIOS looks into its tables to find where that drive is attached, checks ranges and then starts sending commands to the drive. After everything is done it returns result to MSDOS.

Just look at this. This is a typical diagram how generic DOS program talks to the drive.



   PROGRAM  <--->  MSDOS  <--->  BIOS  <--->  IDE/SATA controller  <---> Hard disk


And now how MHDD works:



   MHDD  <--->  IDE/SATA controller  <---> Hard disk


The main difference: MHDD does not use BIOS functions and interrupts. So, you even do not need to detect your drive in BIOS. You can even turn on your drive after MSDOS boots. MHDD works directly with IDE or Serial ATA controller so it does not care about partitions, file systems, BIOS (motherboard) limitations, etc.

WARNING: Do not run MHDD from the hard drive which is on the same physical IDE channel (cable) which you are going to use to diagnose drives! MSDOS (SMARTDRV.EXE, for example) may decide to access any drive at the same moment when MHDD is using it, you will have some data loss on both devices on that channel! There is no way to block or trace MSDOS' or BIOS' read/write attempts. That is why, by default, MHDD does not work with Primary IDE as it usually used to boot MSDOS, to run MHDD, etc. To unblock Primary IDE please run MHDD once, then exit, and then modify MHDD.CFG or use /ENABLEPRIMARY switch.

For SCSI drives MHDD uses DOS ASPI driver. If you are not planning to use MHDD on SCSI drives then you do not need any drivers.


Platform requirements and supported hardware

Platform:

IDE/SATA Controllers:
Hard disk drives

IDE drive should operate in master mode, and no slave devices should be attached. Please configure all drives you are planning to work with as master devices.

Other devices


Obtaining installation package

You have to decide which kind of installation you prefer: CD image, floppy image or just executable files. Please visit http://mhdd.com.

You can burn CD image with any CD burning software. Your CD will be bootable.

Floppy image can be written under Windows 2000/XP.

You may also decide to obtain just executables. You will have to extract MHDD files somewhere.


First run. Some important information

Some people believe that MHDD is very difficult. This is because they suppose MHDD should be very simple and easy, «one-button» software, and when they run it for the first time they become disappointed. MHDD is not easy if you have no deep knowledge how disk drives work. If you want to get such knowledge you can use ATA/ATAPI standard: http://t13.org.

It is very important to understand that you have to spend several hours (minimum) before you will start understanding results made by MHDD. I strongly recommend trying a couple of good drives with MHDD before you start working with bad drives.

On the first run MHDD creates a new ./cfg/mhdd.cfg file. Primary IDE channel is disabled by default. If you really want to enable it, please read this (look for warning message).

You will see drive selection menu. Please select any device you want. You can always call this menu by pressing SHIFT+F3.

Now you can press F1 and use whatever commands you want. Please be extremely careful when running MHDD first times.

Best commands to try first are EID, SCAN, STOP, CX and TOF. Some of them have shortcuts, for example F4 for SCAN.

Please also take a look at the registers. Any IDE/SATA drive should report DRIVE READY and DRIVE SEEK COMPLETE, so you will see DRDY and DRSC flags colored in blue. BUSY appears when drive has something to execute (read or write command, for example). Some flags such as WRITE FAULT and TRACK 0 NOT FOUND are obsolete, they never should appear. INDEX flag is obsolete too, but sometimes it can blink. DATA REQUEST (DREQ) flag is on when drive wants to receive or to send some data from/to the PC.

When you see ERROR flag (ERR) you can look at the error register where you can see what kind of error happened. See ATA/ATAPI standard for more information about registers and commands.




Using MHDD commands




Scanning a drive

Scanning of any device is possible only if it can be detected by ID/EID commands (or F2 key). To scan a drive type SCAN and press ENTER or use F4 key. You will see menu where you can adjust some settings. By default, start LBA is zero and end LBA is maximum possible value (last sector of the drive). All data-destructive functions (Remap, Erase Delays) are switched off by default.

Press F4 again to start the scan. MHDD scans drives by blocks. For IDE/SATA drives one block is 255 sectors (130560 bytes).

How MHDD scan works:

    1. MHDD sends VERIFY SECTORS command with LBA number and 
       number of sectors to verify as parameters
    2. DRIVE raises BUSY flag
    3. MHDD starts timer
    4. After drive executes VERIFY command, it drops BUSY flag
    5. MHDD counts the time and puts corresponding block 
       on the screen. If error occures MHDD prints corresponding
       letter which describes the error.

MHDD repeats steps 1—5 till the end sector. If you need the log of scan please check out log/mhdd.log file — everything is there.

If your drive has errors, first thing to do is to make full back up. Then you have to run ERASE command which erases every sector on your drive, and drive recalculates ECC fields of each sector. This helps to get rid of «software bad blocks». If that do not help, you have to run SCAN with REMAP option switched on.

If you see all blocks as errors, do not try to erase or remap sectors on your drive. You deal with service-area error which cannot be fixed by standard MHDD commands. If you need your data — the best option is to use a data recovery company.


Getting SMART attributes

You can type SMART ATT command or press F8 to get SMART attributes. What do they mean?

The most important thing is the raw value of «Reallocated Sectors Count» attribute, which says how many remaps are on the drive. Normally, you should always have zero there. If it is more than 50 — you have a problem. That means you have bad power supply, vibration, overheating or just broken hard disk drive.

Take a look at the temperature. The best values are between 20 and 40 degrees centigrade, but some drives do not report their temperature.

UDMA CRC error rate attribute means how many errors have happened during transferring data through IDE/SATA cable. You should normally have zero there. If it is not zero, you have to change your cable immediately. Also overclocking may result in increased error rate.

Other attributes usually are not so important. Please see ATA/ATAPI standard for more information about SMART attributes.


Device identify commands

Try commands ID and EID to see some information about your drive.

Please see ATA/ATAPI standard for more information about HDD features and modes.


Erasing sectors or whole drive

You can use ERASE command to do this. If your drive is recognized by BIOS, MHDD will try to use BIOS functions to erase the drive. If you don't want MHDD to use BIOS to erase drives then use /DISABLEBIOS command line switch.


Cutting the drive (size change)

Use HPA command to limit size of a drive. You will be asked about new MaxLBA number, just enter how many sectors you want to use. To uncut the drive, use NHPA command. Please repower the drive before using NHPA command. According to ATA/ATAPI standard, you can use HPA functions only once per drive's power cycle.


Security commands

Use PWD command to lock a drive with defined user password. According to ATA/ATAPI standard, you have to repower the drive to make password setting active.

There are two commands to unlock drives: UNLOCK and DISPWD. UNLOCK just unlocks a drive till the next power cycle. To disable password you have to UNLOCK drive first, then use DISPWD command to disable the password. You have to know the password to use unlock or disable password commands. UNLOCK and DISPWD will ask you which kind of password you will enter: master or user. For example, PWD command sets USER password.

Master password is set by manufacturer and can be used to unlock a drive.


Reading sectors to a file

You can read several sectors or whole drive to a file or to set of files. Just run TOF command, there is nothing difficult. MHDD skips bad sectors, if any. If you are planning to get more than 1 GB, it is better to use ATOF command (it just creates several files instead of one).


Writing sectors from file to the drive

Use FF command to write sectors to the drive. It will ask you the number of the first LBA sector to write and how many sectors to write.


Acoustic Management

Almost all modern drives support Acoustic Management. You can decrease noise produced by heads by increasing seek time. Use AAM command to adjust the noise.


Device Configuration

You can view and change current drive configuration by using CONFIG command. It will allow you to view or set the maximum UDMA mode, Security support, SMART support, LBA48 mode support, AAM and HPA support etc. You can also cut or uncut the drive by using this command. Some manufacturers are using Device Configuration to reduáe the size of a disk.


Batches

You can write a simple batch file (see an example in BATCH directory) where you can describe «what to do». Press F5 to run a batch.


Other MHDD commands

Press F1 to find more MHDD commands to play with. Also it is a very good idea to use command MAN to get more detailed help on each command. Good luck!






Command line switches

    /NOPINGPONG     Disable some sounds
    /DISABLEBIOS    Disable ERASE through BIOS
    /DISABLESCSI    Disable SCSI engine
    /ENABLEPRIMARY  Enable Pimary IDE/SATA channel
    /RO             Run MHDD on write-protected storage 
                    (disable logging and temp files creation)


Frequently Asked Questions

FAQ is available here: http://forum.hddguru.com/viewtopic.php?t=5


Editor: Maya Postrigan





© 2005 Hddguru.com — your source of information about Hard Drives