Monday, August 02, 2004

Getting SATA Hard Disk Working with Kernel 2.4.x

This weekend finally RH9 is up and running on my new box. Interesting part is to get the SATA drive working with RH9. This is also applicable to any distribution, which is based on a 2.4.x kernel (less than 2.4.27 [which is not yet out]). Following is the procedure you can follow to get these distributions running with SATA.

- Set the SATA drive to compatible mode in BIOS so that older OSs recognize them as conventional IDE drives.

- Install the Linux

- Grab the latest release candidate of 2.4.27 kernel (rc4 at this point of time). Version 2.4.27 has the SATA drivers.

- Compile the new kernel, things to look for are
+ Enable the your serial ATA controller in ATA settings (mine was Intel ICH5 i.e Intel PIIX support option)
+ Enable serial ATA option in SCSI low-level drivers

- Install the Kernel (modify your grub configuration adding the new kernel option)

- Now the important thing before rebooting and enabling SATA in BIOS is that the drive name for your hard disk is going to change when you enable the SATA option in BIOS. So you have to specify the correct device name for ROOT partition in kernel boot parameters present in grub configuration file & modify your /etc/fstab to reflect the new drive name.

- Ok. How do I find new drive name? The BIOS maps the SATA channels as extra IDE channels, so when BISO setting is in SATA your hard disk appears in IDE channel 3 (connected to 1st SATA channel). This is assuming that you have only primary and secondary IDE channels. By this SATA disk on third IDE channel becomes hde (hda[master], hdb[slave] for primary, hdc[master], hdd[slave] for Secondary). Note that if you have connected your SATA disk to the second SATA channel leaving the first one empty this will go to IDE channel 4 and drive name becomes hdg. So you can calculate this before and change your grub configuration and /etc/fstab accordingly. When installing Linux in compatible mode the disk on SATA moves to one of the disks in Primary or Secondary channels that is the reason we need to do all this.

If you are unable to calculate this properly, use trail and error method by modifying the kernel command line options at grub startup screen. Once you get it right update the configuration files and also update the grub device map which is present in /boot/grub/device.map by running grub --device-map=device.map

Then every thing will work fine but if you want to boot your old kernel any time you need to take care of /etc/fstab.

2 Comments:

At 8/02/2004 6:08 PM, Blogger Kousik said...

Can you post an example disk geometry and a corresponding /etc/fstab so that we get a clear idea exactly what to do? Also you talked about trial and error; did you mean editing /etc/fstab, reboot, if it doesn't boot, then get the rescue CD, edit /etc/fstab, reboot? That's too timeconsuming ...

I'm downloading Mandrake 10, so will use kernel 2.6 from first day ... and save all your effort :-)

 
At 8/03/2004 4:54 PM, Blogger Subhash Chandra said...

Looks like some clarity is required here. First, if you are dealing with a 2.6.x kernel then there is no reason you to understand all this.

The basic problem is that when you are installing Linux (in compatible mode) your hard drive may be named as hdb and when you switched to SATA mode it may be named as some thing else say hde this will surely cause a problem.

There are two places where you need to adjust the drive name (actually three). First place is at kernel parameters where you will specify the partition of the ROOT directory (in grub configuration). Now there are two ways to specifying a ROOT partition. One is by device name like /dev/hdb or by the drive label (RH9 actually uses this). If the device name is used for ROOT directory, you need change it. If it is not correctly specified kernel hangs at booting saying that I can't find proper things. If a drive label is used to specify the ROOT directory then grub’s device map comes into picture (you need not change in kernel parameters). Grub has his own way of naming drives (read grub manual). It maps its drive names to Linux drive names using a map file named devices.mpa (a text file in /boot/grub). If that is the case, you need to change this map manually to reflect the new Linux drive name (this is the third place I mentioned).

The next place you need to change is /etc/fstab to mount various partitions you have. If you have the drive labels used in fstab then there is no problem else you need to change the names. Note that if you have installed the Linux in a single partition then there wouldn't be much problem.

Trail and error method I talked about doesn't require you to use rescue disk. When the grub start up screen appears choose the Linux kernel you want to boot and press 'a' to edit the kernel parameters, so you can keep on trying various drive names till the kernel boots completely (of course only ROOT partition will be mounted at that time). Once it boots you can edit /etc/fstab and grub configuration.

 

Post a Comment

<< Home