News

eSATA: Installation and Hotplugging on Windows

« Back to news

I've been meaning to implement a backup solution for a while now and after finding a cheap enclosure and backplate for my eSATAless motherboard, I took the plunge and ordered the parts. I was certainly not expecting it to take more than half an hour to get it up and running but after first experiencing issues getting the drive detected and then discovering that there was no “Safely Remove Hardware” icon in the systray it was obvious that this would take some Googling. It turns out that the manufacturers offered little advice and although a lot of people were talking about it on various forums, there didn’t seem to be any consistent advice so I thought I’d roll up my sleeves and put something together.

This article is divided into the following sections:

  1. In the beginning
  2. Messing with hardware
  3. Back to software
  4. AHCI
  5. The best half solution for the rest of us
  6. Other hotplug methods
  7. Comments
  8. Troubleshooting
  9. Contact

1. In the beginning

After slotting the backplate into a free PCI slot, connecting all the various cables and powering on my brand spanking new enclosure I proceeded to boot up the machine only to be greeted with a black screen and flashing cursor. I hadn't even managed to enter the BIOS yet and already there were issues. As a software guy by trade I am generally quite reluctant to take the lid off the pretty box but in this case there was no other choice.

2. Messing with hardware

I first confirmed that the onboard SATA connector was working correctly by connecting it to my primary hard drive and then tested all the components on another machine. In both cases the hardware proved to be working correctly. I then performed a BIOS update which did absolutely nothing and eventually ended up temporarily solving the problem using a spare SATA 1.5gbit controller card. Having not really quenched my thirst for a real answer I set about Googling and stumbled upon this blog entry.

It turns out that its all down to the poor signal produced by the motherboards eSATA controller which is not enough to combat the large amount of electrical noise caused by multiple cables and connections. The solution is thus to change the jumpers on the hard drive so it runs at 1.5gbit lowering the transfer rate but at least providing a usable setup (it stills faster than the alternative). You can find out how to do this on Western digital hard drives by looking here.

This however was not the end of my troubles; having got the disk detected and working I now had to deal with the opposite task of safely removing it.

3. Back to software

On Linux/Unix/ix when you're finished with a CD or USB stick you just run the unmount command which ensures (probably amongst other things) that all open file handles are closed and cached data is flushed to the disk. On Windows this same operation is normally performed via the safely remove hardware icon in the systray but unless you have your SATA controller configured in AHCI mode and have an eSATA connector on your motherboard i.e. you don't need to use a SATA to eSATA backplate (this may not apply to all motherboards particularly nForce chipsets) you won't get this behaviour. Unfortunately enabling AHCI is not simply a case of changing an option in the BIOS and then rebooting, ooohhh no, if you're running Windows XP you would then see the inaccessible boot device BSOD. So how do you get it working, well there are 3 options.

  1. Reinstall Windows with AHCI enabled. You must have the drivers for your SATA controller on a floppy disk.
  2. Repair Windows. This will work although you will need the drivers as explained in 1 and you may find the system runs slightly more sluggishly than usual afterwards.
  3. Do a bit of file copying and registry editing.

4. AHCI

I initially chose option 3, hoping that somehow my eSATA backplate solution would work, and followed this little tutorial for enabling AHCI on Intel SATA controllers (Note: According to the readme.txt that comes with the Intel storage drivers, you must also ensure you install your motherboards chipset drivers either before or straight after getting AHCI working). See the troubleshooting section if you run into difficulties.

Although the machine did boot back into Windows, unsurprisingly I was still not able to use hotplug.

5. The best half solution for the rest of us

According to official Microsoft documentation here (referenced from here) there is only one other method available to safely remove a device:

"If the Safely Remove Hardware icon is not in the notification area, you must use Device Manager to uninstall the disk before you unplug it".

Uninstalling from device manager will occasionally force a reboot making it less than ideal but unfortunately it is the only alternative. You can make this process slightly less painful by using a utility called HotSwap.

If you still want more I've listed some other methods below that I investigated before coming to the above conclusion but be warned, they ain't pretty.

6. Other hotplug methods

Disclaimer: Apart from option 1, I don't believe any of these other methods are 100% reliably so don't blame me if you experience data loss.

  1. You buy a third party SATA controller. Quite an expensive option (if you actually want a good quality controller) just to get an external disk working especially as its something your motherboard should be able to do out of the box!

  2. Disable OS and disk caches. This sounds good in theory (apart from the performance drop) but personally I can't actually do it! You can see this by going to device manager, expanding out disk drives then looking at the policies tab under the disks properties.

  3. You try using something like Sysinternals sync utility with the -e -r switch (-r to flush cached data and -e to eject the removable disk) provided with the pstools package. The -e switch in particular probably sounds quite promising until you try it and discover that it does nothing (I am sure it works correctly if Windows thinks the device is removable). Although the flushing does work at least at the OS level, you still can't guarantee that something isn't going to start writing to the disk just after you finish flushing but before you disconnect the external disk and I am not certain whether or not it actually flushes the cache built into the external hard disk because it won't think it's removable.

  4. You attempt to unmount the disk using either the disk management tool (can be found by right clicking on my computer -> manage -> disk management on the left under storage) or the command mountvol. This either involves removing the drive letter (in the case of disk manager) or deleting the existing volume mount point using mountvol.

    At the end of the day both of these tools almost certainly use the same underlying Windows APIs to achieve the goal of removing the drive letter and after looking inside MountVol and having a look on MSDN you will find the DeleteVolumeMountPoint function. Although you would presume that this flushes data to the disk and safely removes it, the remarks section gives no solid evidence of this and having a quick browse around MSDN turns up nothing.

    After Googling the function name I eventually came up firstly with this forum post basically saying mountvol was not a reliable way to flush cached data (meaning that disk management is also probably not reliable) and then also found this newgroup thread. The usenet post may only be referring to a read cache but it still puts doubt in my mind about using the function.

  5. You use eSATA for the first large backup/data transfer then reboot/shutdown the machine and thereafter use USB 2.0 or firewire depending on your hard disk enclosure and motherboard connectors. It works but I personally can't bring myself to do it, not when I know my hardware supports something much better and didn't you start reading this in the first place because you wanted to use eSATA?

  6. You just power off/unplug the disk. The simplest and worst solution although admittedly in the short term you probably won't experience anything out of the ordinary. In the long term you'll eventually run out of luck and start losing data. This is due to caching provided by the OS and/or (depending on how your device is configured) hard disk to speed things up which means that when data is saved it won't necessarily be instantly written to the disk. Any data in this in between state will thus be lost when power is cut or the device unplugged.

7. Comments

While not being completely hassle free, installation is still relatively easy compared to removal and at this moment in time AHCI seems to be the only reliable method of getting hotplug functionality providing you have either an nForce based chipset or similiar or a real eSATA connector. Without shelling out more money, your only other options are to either manually remove the disk from device manager or use a nicer graphical interface like HotSwap and hope that Windows doesn't require you to restart.

Its a real shame that you can't just force the OS/SATA controller to allow hotplug capability even when it believes the disk is internal. After reading through the datasheet for my I/O controller it seems like a software patch could be made to do this as the hardware seems to support the required functionality, infact using an eSATA backplate is even specifically mentioned.

"The cable-up solution involves an internal SATA cable that connects to the SATA motherboard connector and spans to a back panel PCI bracket with an e-SATA connector. A separate e-SATA cable is required to connect an e-SATA device.".

Clearly Intel realise people are going to do this and yet provide no software support to properly utilise it. I suppose it’s possible that a patch will appear at some point in the future but I won't hold my breath.

8. Troubleshooting

Q: when attempting to install the Intel Matrix Storage Manager MSI I get the message "This computer does not meet the minimum requirements for installing the software".
A: Pass the "-a" switch to the MSI e.g. iata76_enu.exe -a. This MSI will install once Windows is able to boot with AHCI support enabled in the BIOS provided that you have supported hardware.

Qa: I can see the safely remove hardware icon in the systray and select the "Safely remove Disk drive" entry but the device never gets ejected.
Qb: The BIOS seems sluggish/there is a long delay in starting to boot the operating system and/or XP takes a long time to boot or never boots at all.
Qc: The external disk doesn't show up in the intel storage manager:
Qd: No drive letter appears and the disk doesn't show up under disk management.
Qe: The "new hardware found" bubble appears in the systray for the external disk but after a few minutes it doesn't seem to go away and the detection process gets stuck.
A: Your motherboards SATA controller is most likely not able to support 3.0gbit transfer to your eSATA drive/the controller cannot detect the hard disks transfer speed automatically. You will need to follow (for Western Digital disks) these instructions to force your hard disk to run at 1.5gbit. For other manufacturers see there website for details.

Q: I've broken it and get a BSOD on start-up.
A: Change your SATA controller back to IDE in the BIOS.

9. Contact

If you have any questions, comments etc please feel free to email me. All my details can be found here.

Hosted by www.Geocities.ws

1