# (RESOLVED) System Drive moves between IDE and LibATA driver

## eohrnberger

I have something of a puzzler here that I can't figure out and was wondering if someone could point me to a possible solution or explanation.

I have an older gentoo installation (2.6.21.6) that is acting as a file server with an additional Promise 20269 EIDE controllers plugged in with hard drives attached.  This chassis is running an ASUS A7V600.

I'm building out a new gentoo system (kernel 2.6.26-r4) on a separate chassis (The new system is built out on a MSI KT-880) and swap system hard disks when I've got everything working just the way that I want.  One of the things that I wanted to do was use the LibATA driver rather than the old IDE driver, as I've been told, or I've read, that the LibATA driver is much more robust and better performing.

In both chassis, the system hard disk is plugged into the primary IDE controller as the master hard disk.  In the old system this was /dev/hda, and in the new system it's /dev/sda.

So I have the new system hard disk built out.  On the ASUS chassis, I swap the old hard disk out, and the new one in and boot it, but the system disk doesn't show up as /dev/sda, it's like /dev/sdf!  Of course, this screws up the file system mounting.  Yes, I could edit the fstab, but I feel pretty strongly that the system disk should be the first disk in the system (/dev/sda or /dev/hda).  I don't want it wandering all over the place as I add and remove data disks on the Promise controllers.

What's going on?  Something with LibATA?  Or a kernel grub parameter I'm not aware of?Last edited by eohrnberger on Fri Dec 19, 2008 8:21 pm; edited 1 time in total

----------

## cyrillic

 *eohrnberger wrote:*   

> One of the things that I wanted to do was use the LibATA driver rather than the old IDE driver, as I've been told, or I've read, that the LibATA driver is much more robust and better performing. 

 

Yes, and in order to avoid conflicts, you should compile the kernel with only one or the other, not both drivers.

Look in /usr/src/linux/.config

You probably have both CONFIG_IDE=y (the old drivers) and CONFIG_ATA=y (the new drivers).

----------

## eohrnberger

I checked my .config, and CONFIG_IDE is not set, and CONFIG_ATA=y is set.

Yea, I made sure that I was booting on the LibATA drivers, and I am, as all the IDE hard drives are identified by /dev/sd*.  

The real thing is why in one chassis primary master is being assigned /dev/sda, and on the other chassis it's being assigned /dev/sdf.  That's the mystery to me.  I want the system hard drive, primary IDE controller master, to be /dev/sda on both chassis.

Any ideas?  I've Googleed up a bunch of stuff, but nothing seems relevant.

----------

## cyrillic

One way you can control the harddrive detection order when you have multiple controllers is to compile-in only the controller that the boot drive is plugged into, and compile all the rest as modules.

ps.  Remember that CONFIG_USB_STORAGE counts as one of your harddrive controllers, especially if you have a card reader plugged in.

----------

## eohrnberger

Now there's an idea.  Thanks.

I'll give that a try and see where it gets me.  Let you know.

----------

## Sysa

 *eohrnberger wrote:*   

> Now there's an idea.  Thanks.
> 
> I'll give that a try and see where it gets me.  Let you know.

 

One more idea - look at udev (e.g. /etc/udev/rules.d/ and docs, of course) - I think it'll be a surprise for you  :Wink: 

----------

## Cyker

If you use libata, you CAN'T rely on the /dev/sdx mappings; libata assigns devices in order of detection so it's *very* easy to end up with your hard disk order completely buggered, esp. if, like me, you compile most storage drivers into the kernel. (Plugging in a USB hard disk would be enough to stop it booting!)

With the old block driver, it only worked with IDE devices, and since you can't generally hotplug IDE devices it was a pretty consistently primary master/slave=hda/hdb, secondary m/s=hdc/hdd.

This is partly why I still use both drivers, with the block drivers only supporting IDE, and the libata drivers only supporting SATA.

If you must use libata with IDE stuff, the best thing to do is assign a label to ALL your drives (e.g. "tune2fs -L <volname>" for ext-format drives) and mount them in /etc/fstab as /dev/disk/by-label/<volname>

This will prevent any possibility of the wrong drive being mounted in the wrong place (Well, unless you hook up one that is named wrong or plug in another disk with that name or something  :Razz: )

The only problems that you might have with this setup is:

- Your fstab will be really ugly and annoying to work with in an 80x25 console

- If udev doesn't work for some reason (Like that time a buggy one got into the stable tree), the system won't boot.

----------

## eohrnberger

I tried the blacklisting of modules as recomended in the Gentoo udev documentation, but that didn't work out.  Got the same results.

 *Quote:*   

> If you must use libata with IDE stuff, the best thing to do is assign a label to ALL your drives (e.g. "tune2fs -L <volname>" for ext-format drives) and mount them in /etc/fstab as /dev/disk/by-label/<volname> 

 

I opted for the using the udev's /dev/disk/by-id symlinks to mount /, swap and boot.  Seems to work OK.  

I can live with the really long fstab lines to get around this.  However, in grub.conf, wouldn't you have to change the root designation?

```

title=Gentoo Linux (2.6.26-gentoo-r4)

        root (hd0,0)

        kernel /kernel-genkernel-x86-2.6.26-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda3

        initrd /initramfs-genkernel-x86-2.6.26-gentoo-r4

```

 would have to change to 

```
title=Gentoo Linux (2.6.26-gentoo-r4)

        root (hd0,0)

        kernel /kernel-genkernel-x86-2.6.26-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sdl3

        initrd /initramfs-genkernel-x86-2.6.26-gentoo-r4

```

Wouldn't it? (Note the drive name)

Seems a bit disconcerting to me that what used to be a very fixed and reliable device name allocation under the IDE drivers, hda, hdb, etc.  is now a seemingly random device name assignment under LibATA.  Or is this just me?

----------

## eohrnberger

OK.  I got it figured out now, and it's working just fine.  The solution is a mix of hints collected from the udev and genkernel documentation.

I ended up putting the LibATA drivers for the IDE controllers that are typically on motherboards directly into the kernel and build it without initrdmodules.  This forces the system hard drive, which is connected to the primary master IDE interface as the first hard disk, /dev/sda.  Then in the module autoload file I call out for the needed Promise controller driver modules, so then the other data drives come on line.

Sure glad that I kept at it.

----------

