Monday, January 4, 2010

Getting AHCI to work with an IDE installation of windows

If anybody has tried to install windows XP (with SP3 or the 64-bit version) with SATA drives, they'll quickly find out the challenge of installing with AHCI enabled in BIOS. I was one of many who gave up trying, and simply set IDE compatibility mode in the BIOS, which ensures that your new SATA drive will work with older operating systems. For the longest time I had simply assumed that I was stuck with the slower IDE drivers, and would forgo the double data transfer rate of SATAII, as well as the lower wear-and-tear on my hard drive from the use of NCQ. Or I would have to spring the cash for a brand new install of Windows Vista or Windows 7. However, I came across a somewhat painless method for enabling AHCI in BIOS, using the following tutorial. (Since this link appears down at the moment, I will reproduce the text below)

Posted by Giulio in Computers

This is a topic I often googled for to have the definitive solution, but I never found a complete one.

Sometimes you install Windows on your PC while the disk controller is in IDE (compatible) mode, and you later realize you would like to switch to the newer AHCI mode.

Doing this after the install procedure is tricky, because Windows needs the disk driver to boot, and if it doesn’t have it, well, it will blue screen forever because it’s not able to mount the system volume.

I found a lot of articles regarding this topic, but often they were specific to some SATA controller, incomplete, and didn’t explain *why* this happens and how to define a generic solution.

So, here is my best effort to explain this.

In Windows, drivers are installed as services. You can find a pretty list of them in the registry, using the well known regedit.

Fire regedit up, and browse to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services key.

Every key here represents a service, which could be a driver or a service as you see them in the Services console.

CurrentControlSet is the current system configuration. Actually, this a link to one of those ControlSetXXXX keys you can see at the same level of CurrentControlSet.

Windows does this to keep track of different system configurations, so you can have a “last good configuration”, and so on.

You can tell which control set is the current one by having a look at the HKEY_LOCAL_MACHINE\System\Select key. Here you can see four values : Current, Default, Failed, LastKnownGood. The value of each of these indicates which ControlSetXXXX is the corresponding one. Value names are pretty self explanatory, so I won’t detail them. Since you need to modify the current one, anyway, let’s stick to CurrentControlSet.

Now, before switching to AHCI (which can be done in the BIOS of your computer, and if you’re reading this you probably know how to do that), the proper driver must be manually installed.

Since the most common vendor for AHCI controllers is Intel, I will cover how to install the iaStor driver, which is the generic driver for all recent Intel SATA controllers.

First, download the drivers. A quick google search will point where to get them. The installer won’t work, because the controller now is in IDE mode, and has a different hardware ID. So, they must be manually installed.

The quickest way to have the actual driver files is to download the plain ZIP package from Intel’s website. The only file needed from the archive is iaStor.sys.

Throw this file in C:\Windows\System32\Drivers. Of course, if “Windows” is not where Windows is installed, replace with the correct folder name.

Now, a registry key for the driver must be created.

To speed things up, a .reg file can be created to quickly import new keys and values in the registry. Copy and paste the following in a text file and save it as ‘iastor.reg’, or whatever .reg name. Double click on the .reg file to import it.

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\iaStor] "Type"=dword:00000001 "Start"=dword:00000000 "Group"="SCSI miniport" "ErrorControl"=dword:00000001 "ImagePath"="system32\\drivers\\iaStor.sys" "tag"=dword:00000019 "DisplayName"="Intel AHCI Controller" [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\iaStor\Parameters] "queuePriorityEnable"=dword:00000000 "BusType"=dword:00000003

Now, Windows knows of the iaStor driver. Windows also needs to know that your AHCI controller is a critical device, and the driver must be loaded early, before painfully crash with a bluescreen.

Another key in the registry must be created, in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase. Here a key exists for each device which is critical for boot time. A new key with the hardware PCI ID of your specific AHCI controller. This PCI ID can be retrieved by having a look at the ‘iaStor.inf’ (for SATA RAID) or ‘iaAhci.inf’ (for plain AHCI) files which come with the drivers. Doing some text search (and of course knowing the name of your controller, like ICH8, ICH9, etc) will uncover some lines which match the controller name with its PCI ID. Here is an extract of iaAhci.inf.

PCI\VEN_8086&DEV_2653&CC_0106.DeviceDesc = "Intel(R) 82801FBM SATA AHCI Controller" PCI\VEN_8086&DEV_27C1&CC_0106.DeviceDesc = "Intel(R) 82801GR/GH SATA AHCI Controller" PCI\VEN_8086&DEV_27C5&CC_0106.DeviceDesc = "Intel(R) 82801GBM SATA AHCI Controller" PCI\VEN_8086&DEV_2681&CC_0106.DeviceDesc = "Intel(R) 631xESB/632xESB SATA AHCI Controller" PCI\VEN_8086&DEV_2821&CC_0106.DeviceDesc = "Intel(R) 82801HR/HH/HO SATA AHCI Controller" PCI\VEN_8086&DEV_2829&CC_0106.DeviceDesc = "Intel(R) 82801HEM/HBM SATA AHCI Controller" PCI\VEN_8086&DEV_2922&CC_0106.DeviceDesc = "Intel(R) ICH9 SATA AHCI Controller"

As for the iaStor key, the following text can be copied and pasted in a .reg text file for quick import, but be careful to substitute my PCI ID (the red string) with yours. You should change only the DEV_ value, since VEN and CC are the same for all controllers. Double click the file, just as for the previous one, to import it.

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\pci#ven_8086&dev_2829&cc_0106] "Service"="iaStor" "ClassGUID"="{4D36E96A-E325-11CE-BFC1-08002BE10318}" "Security"=hex:01,00,04,90,00,00,00,00,00,00,00,00,00,00,00,00,14,00,00,00,02,\ 00,4c,00,03,00,00,00,00,00,14,00,ff,01,1f,00,01,01,00,00,00,00,00,05,12,00,\ 00,00,00,00,18,00,ff,01,1f,00,01,02,00,00,00,00,00,05,20,00,00,00,20,02,00,\ 00,00,00,18,00,9f,01,12,00,01,02,00,00,00,00,00,05,20,00,00,00,21,02,00,00

OK. Now, you can reboot, change the controller from IDE to AHCI in the BIOS, and hopefully everything will work. At least, it worked for me

If something went wrong, just switch back to IDE mode and verify that all steps have been done correctly.

These steps should be quite similar for other vendors/drivers, so feel free to improvise

Have fun!

I tried this method, and wasn't successful at enabling AHCI, but I *was* successful in enabling RAID in my BIOS. Don't worry, you don't need to mount a RAID volume, it will use your existing volumes without you needing to do anything, but if you want to use RAID in the future. Also, the RAID option encapsulates the ACHI option, so you'll benefit from the same features such as SATAII and NCQ. You can then install Intel's Matrix Storage Manager if you'd like. I recommend using a utility such as HD Tune to confirm that you're getting the faster transfer rates and features present with your SATA drive--the free version is sufficient in reporting this information.

4 comments:

tas flowrance said...

Thank you for this good topic

Giulio said...

Hi, thanks for linking to my post :) You're right, the site has been down because of provider problems, now is back online. Feel free to send me any improvements for the procedure! Giulio

jeepakistan said...

Nice blog

Scratch the hostile fay said...

Your computer language it Greek (Geek?) to me.

But the bunny looks cool, it looks like the one who held me up at the garden for my carrots.

"Hell's Lapines"? X-D
Your verification word for today: flamis

=French for "look! I just flamed your blog!" (just kidding)

Scratch