# SATA : sd* confused when switching IDE <-> AHCI [Solved]

## aCOSwt

THE SITUATION :

- My mother board (ASUS P5P43TD) is built with an ICH10 chipset.

- The BIOS enables me to configure SATA as IDE or AHCI

- I get 3 hard disks connected :

disk-1 - SATA (bootable)

disk-2 - SATA

disk-3 - IDE (bootable)

- I cared to build my kernel with :

- AHCI SATA support (CONFIG_SATA_AHCI=[y])

- ATA SFF support (CONFIG_ATA_SFF=[y])

- Intel ICH PATA/SATA support (CONFIG_ATA_PIIX=[y])

- JMICRON PATA support (CONFIG_PATA_JMICRON=[y])

For some... historical reason...   :Rolling Eyes:  (The exact truth being that I had the need for XP installed on disk-1 and did not want to fiddle its drivers   :Twisted Evil:   ) I configured SATA as IDE and set-up one Gentoo on disk-1 and another one on disk-3 having the following association :

- disk-1 = sdb (first boot device)

- disk-2 = sda

- disk-3 = sdc

I use LILO and configured it so that I get an MBR on sdb and another one on sdc, both chained together

THE PROBLEM :

Having got rid of... the historical reason, I setup my BIOS so that SATA is now configured as AHCI

- The boot manager appears on the screen,

- The system starts booting on disk-1 (according to my choice)

Then when it comes to mounting root, the boot process stops, unable to mount sdb5 (the actual root partition on disk-1) and a list of available sd* devices is displayed, from which I deduce that now :

- disk-1 = sda  :Sad: 

- disk-2 = sdb  :Confused: 

- disk-3 = sdd  :Shocked: 

THE QUESTION :

Is there some convenient way to overcome this ?

A - As part of some boot command line parameters ?

B - Re-fiddling my lilo.conf  but, in this case how as if, having boot with SATA-> IDE => under a sdb based fstab, I just change its boot and root statements to sda, /sbin/lilo will refuse updating that !

C - Finding some Live DVD 10, boot on it with SATA -> AHCI (expecting it will accept) then chroot and adapt lilo.conf (I dislike this one)

D - Other I cannot think of ?

EDIT 1 : C is no longer an option as, booting on LiveDVD 10 + SATA as AHCI leads to yet another association   :Rolling Eyes: 

- disk-1 = sdc

- disk-2 = sdb

- disk-3 = sda

What in my system is responsible for inventing those charming affect-dependent drive <> sd * associations   :Evil or Very Mad: Last edited by aCOSwt on Sat Apr 16, 2011 9:26 am; edited 4 times in total

----------

## krinn

D - grub and udev label fstab :

- for those kind of things, really grub is better, and the on-the-fly command line parser will ease your tests

- the udev label fstab need only labels, easy to do, easy results, giving away the need to know the name of the device, abstract the device name but still have a known mount point

----------

## aCOSwt

 *krinn wrote:*   

> D - grub

 

 :Sad:   :Confused:   :Evil or Very Mad:   :Mad:  Hmmm... 

"Is there anybody else we could talk to ?" (Michael Palin accent)   :Wink: 

 *krinn wrote:*   

> udev label fstab

 

"That's easy !"

Grreat Indeed ! I did not know this possibility ! I had never had the idea of writing an fstab differing from the first mnttab I made 30 years ago !   :Rolling Eyes: 

Thanks for pointing this krinn !

This should definitely solve the problem that had gone even darker since I tried booting the LiveDVD 10, this leading to yet another association list.   :Shocked: 

This making me think that the process of sd devices election was definitely looking like "some farcical aquatic ceremony"    :Wink: 

Thanks again krinn !   :Cool: 

I try this at once... keeping my lilo if I can.

----------

## krinn

switch to that when i was having trouble with a controller (by this time it was a marvell something) that was still using hd* and i was getting mad at making all of them work together while my disks were switching from sd*<>hd* names

even i don't use it for that anymore (everyone is sd*), i keep using it, just because nothing can disturb my mounts now (and with that list, it's easy to disturb them, just by adding an usb key...)

```
/dev/disk/by-label/faramirboot      /boot      ext2      noauto,noatime   1 2

/dev/disk/by-label/faramirroot      /      ext3      noatime0 1

/dev/disk/by-label/faramirswap      none      swap      sw   0 0

/dev/disk/by-label/sata250              /mnt/sata250    ext3            users           0 2

/dev/disk/by-label/seagate750           /mnt/seagate750 ext4            users           0 2

/dev/disk/by-label/seagate1G            /mnt/seagate1g  ext4            users   0 2

/dev/disk/by-label/western200           /mnt/western200 ext3            users           0 2 

```

----------

## aCOSwt

Well... approximately everything is OK now using partition labels.

The only thing I still cannot figure out is how to reference the MBR itself.

I mean that labels / uuids are identifying partitions v.g. sd-x-y

How can I symbolically identify sd-x ?

I need this to be able to chain my MBRs.

I usually achieve this in lilo.conf of my main gentoo system on sdb disk as simply as the following statement :

```
other=/dev/sdc

label=System-Rescue
```

(I did not read how to in grub documentation either)

----------

## Anon-E-moose

You should be able to set boot order of the disks in your bios.

That should make them consistent.

----------

## aCOSwt

 *Anon-E-moose wrote:*   

> You should be able to set boot order of the disks in your bios.
> 
> That should make them consistent.

 

Well, more than just setting the boot order, the BIOS even (apparently) enables to set the order of the disk devices, that is, what I requested : disk-1 / disk-2 / disk-3

I do not believe that the problem comes from the BIOS as, from the lilo's boot menu, I can see that the BIOS always selects the correct device for booting (disk-1), making my choice from the boot menu, I also can witness that the boot is starting on the correct partition.

The problem comes within the boot process. When it comes to actually mount root. Partitions sd* naming is differing in the three cases I mentioned in my first post.Last edited by aCOSwt on Thu Apr 14, 2011 3:56 pm; edited 1 time in total

----------

## Anon-E-moose

Then investigate the map-drive and/or bios entries for the lilo config file.

----------

## aCOSwt

 *Anon-E-moose wrote:*   

> Then investigate the map-drive and/or bios entries for the lilo config file.

 

 :Evil or Very Mad:  All sort of things labeled as "considerably-largely-profundly outdated of deprecation"   :Very Happy: 

Well, thanks anyway Anon-E-moose for having pointed this.

I discovered, reading further down the static-BIOS-codes option, that lilo could get into troubles when mixing IDE / SCSI drives.

This being the case in my system, I just... :

- Stopped reading,

- Pronounced one or two sware words,

- Remembered krinn's advice to swap for grub,

- Pronounced three additional (and different) sware words, and started wondering why I needed anything dedicated at all for creating a poor bunch of 512 bytes.   

- Booted on disk-3 the IDE way

- Used dd to get a copy of my lilo based disk-1 MBR,

- Used my hex editor to put it in accordance with the way disks are associated when AHCI driven

- Used dd to put the MBR back in place

- Booted succesfully on disk-1 the AHCI way

- Achieved the same for disk-3.

My system is now AHCI driven !

I do hope I will be the witness of some significant improvements...   :Twisted Evil: 

Thank you krinn and Anon-E-Moose for your help.

----------

## Anon-E-moose

I use grub, but I did notice that there were warning of depreciation, though it seemed they still worked, when I looked at lilo.

Glad it got fixed.

----------

