# Drive identification gone wrong[Explained]

## madchaz

I just got myself a new desktop, so my old AMD64 3700+ as a new vocation as a server. 

I have 4 drives in the system. All SATA and connected as follow. 

SATA Bus 0: 250G

SATA Bus 1: 300G

SATA Bus 2 and 3: 2T

I have triple checked the cables  and bios and can confirm this is how they are connected. 

If I connect only the 250 and 300, they show up respectively as sda and sdb. 

If I add the 2X2T drives, they take over sda and sdb, pushing those connected to bus 1 and to to take sdc and sdd. 

In the end, it doesn't really make that large a difference, as I still boot off the 250G and just had to change fstab and bootloader conf, but I'm wondering why it bumps the disks like that. 

Any ideas?

edit: to correct numbering

----------

## NeddySeagoon

madchaz,

Several reasons.

SATA chipsets are started in PCI bus order, except that chip sets belonging to kernel built in drivers are always found before those belonging to modular drivers.

Please pastebin your lspci.

----------

## krinn

as you see, build your fstab like that, label your disk, and no more need to worry about them

```
/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 

```

```
mount

...

/dev/sdb1 on /mnt/sata250 type ext3 (rw,noexec,nosuid,nodev)

/dev/sdd1 on /mnt/seagate750 type ext4 (rw,noexec,nosuid,nodev)

/dev/sde1 on /mnt/seagate1g type ext4 (rw,noexec,nosuid,nodev)

/dev/sda1 on /mnt/western200 type ext3 (rw,noexec,nosuid,nodev)

```

----------

## NeddySeagoon

krinn,

That fails in grub.conf unless you use an initrd to mount the real root.

----------

## krinn

i know neddy, and as i dislike the initrd stuff, i never use label on grub, but i haven't spoke about grub  :Wink: 

for grub, but nothing prevent you from doing a 2 entries in grub to cover two cases (or more), that's what i did, i'm too lazy to edit grub while booting

----------

## madchaz

@NeddySeagoon

lspci is actually pretty short. Posting in code block below. The board as 4 sata plugs and the bios puts them in the right place. I did, however, have to enable large drives for plugs 3 and 4, so it would actually detect the 2T drives. 

```
 # lspci

00:00.0 Memory controller: nVidia Corporation CK804 Memory Controller (rev a3)

00:01.0 ISA bridge: nVidia Corporation CK804 ISA Bridge (rev a3)

00:01.1 SMBus: nVidia Corporation CK804 SMBus (rev a2)

00:02.0 USB Controller: nVidia Corporation CK804 USB Controller (rev a2)

00:02.1 USB Controller: nVidia Corporation CK804 USB Controller (rev a3)

00:04.0 Multimedia audio controller: nVidia Corporation CK804 AC'97 Audio Controller (rev a2)

00:06.0 IDE interface: nVidia Corporation CK804 IDE (rev f2)

00:07.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)

00:08.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)

00:09.0 PCI bridge: nVidia Corporation CK804 PCI Bridge (rev a2)

00:0a.0 Bridge: nVidia Corporation CK804 Ethernet Controller (rev a3)

00:0b.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

00:0c.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

00:0d.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

00:0e.0 PCI bridge: nVidia Corporation CK804 PCIE Bridge (rev a3)

00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration

00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map

00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller

00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control

01:00.0 VGA compatible controller: nVidia Corporation G96 [GeForce 9500 GT] (rev a1)

```

@krinn

I already worked around it. Writing sdc instead of sda in fstab and lilo.conf isn't exactly rocket science.  :Wink: 

Yes, I still use lilo. Still love it too. Much less quirky then grub. I'm just currious as to why it insists on saying bus 3 and 4 are sda and sdb respectively.

----------

## NeddySeagoon

madchaz,

```
00:06.0 IDE interface: nVidia Corporation CK804 IDE (rev f2)

00:07.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3)

00:08.0 IDE interface: nVidia Corporation CK804 Serial ATA Controller (rev f3) 
```

Thats the order your drive controllers will be detected in.  So PATA will be first, then the SATA drives on 07.0, lastly, those on 08.0

This means that if you add a PATA drive, all the SATA drives get bumped.

UUID is the way of the future. Labels work on filesystems that support labels.  Its not a problem in /etc/fstab, just in the bootloader as you need an initrd to make UUIDs or lables work.

----------

## madchaz

No pata drive except for the dvd-rom. 

All the other drives are SATA. And as I already said, they are on the last 2 controlers, so I would expect 00:08.0.

As for labels, not a good idea anyway, as the drives aren't going to get partitionned. They get assigned directly to lvm.

----------

## NeddySeagoon

madchaz,

What?  no raid5 ?

Labels are attached to filesystems - not drives

----------

## madchaz

 *NeddySeagoon wrote:*   

> madchaz,
> 
> What?  no raid5 ?
> 
> Labels are attached to filesystems - not drives

 

Raid 5 with just 2 drives is called mirroring  :Wink: 

and I know labels go with filesystems. That's why I said that wasn't useful for me.

----------

## cach0rr0

 *madchaz wrote:*   

> 
> 
> Raid 5 with just 2 drives is called mirroring 
> 
> 

 

mirroring with 2 drives is not RAID-5

It is RAID-1

RAID-5 requires at least 3 drives.

----------

## NeddySeagoon

Team,

LVM with two drives is raid0. Probably linear raid0.

I had missed that the OP was only using two drives.

----------

## madchaz

 *cach0rr0 wrote:*   

>  *madchaz wrote:*   
> 
> Raid 5 with just 2 drives is called mirroring 
> 
>  
> ...

 

That is why I said raid 5 with 2 drives is mirroring (also called raid 1)

Also, technically, you can setup a raid 5 array with just 2 drives. The net result is mirroring that doesn't work very well, but it lets you add drives and grow the array. 

And yea, lvm with 2 drives is raid 0. And yes, it's linear, because I don't care about performance as much as I care about convenience. This is going to be my new file server. It works over gigabite, so the sata drives are actually able to completely floor my network. 

Still can't figure out why it screws up drive lettering, however. Is there a way to make sure what buss (07 or 0 :Cool:  the drives are connected?

----------

## krinn

ls -l /sys/block

you'll see the hosts id in it (same one as lspci)

```
total 0

lrwxrwxrwx 1 root root 0  4 avril 15:11 sda -> ../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sda

lrwxrwxrwx 1 root root 0  4 avril 15:11 sdb -> ../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:1/0:0:1:0/block/sdb

lrwxrwxrwx 1 root root 0  4 avril 15:11 sr0 -> ../devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sr0

lspci | grep 00:1f.2

00:1f.2 SATA controller: Intel Corporation 82801JI (ICH10 Family) SATA AHCI Controller

lspci | grep 01:00.0

01:00.0 RAID bus controller: Adaptec AAC-RAID (rev 09)

```

----------

## NeddySeagoon

madchaz,

raidtools, now long dead, would allow you to set up any raid level you cared to on a single spindle as you just donate block devices to the raid. In this case partitions.

It wasn't very fast or useful - except for playing with.

I've never tried it with mdadm.

----------

## 1clue

As I understand it, your only real issue here is that your fstab is confused depending on how many drives are mounted, right?

Why not mount by UUID?  Just stretch your terminal a little wider.

....

UUID=cddc8706-9603-4e6a-8b13-7643b59948cf none            swap    sw              0       0

....

----------

## madchaz

 *krinn wrote:*   

> ls -l /sys/block
> 
> [/code]

 

And we have a winner. 

```

lrwxrwxrwx 1 root root 0 Apr  4 22:02 sda -> ../devices/pci0000:00/0000:00:07.0/host2/target2:0:0/2:0:0:0/block/sda

lrwxrwxrwx 1 root root 0 Apr  4 22:02 sdb -> ../devices/pci0000:00/0000:00:07.0/host3/target3:0:0/3:0:0:0/block/sdb

lrwxrwxrwx 1 root root 0 Apr  4 22:02 sdc -> ../devices/pci0000:00/0000:00:08.0/host4/target4:0:0/4:0:0:0/block/sdc

lrwxrwxrwx 1 root root 0 Apr  4 22:02 sdd -> ../devices/pci0000:00/0000:00:08.0/host5/target5:0:0/5:0:0:0/block/sdd

lrwxrwxrwx 1 root root 0 Apr  4 22:02 sr0 -> ../devices/pci0000:00/0000:00:06.0/host1/target1:0:1/1:0:1:0/block/sr0

```

Weird that controlers 2 and 3 would end up on 07 and 0-1 on 08. But now it makes sence at least.

----------

## madchaz

 *NeddySeagoon wrote:*   

> madchaz,
> 
> raidtools, now long dead, would allow you to set up any raid level you cared to on a single spindle as you just donate block devices to the raid. In this case partitions.
> 
> It wasn't very fast or useful - except for playing with.
> ...

 

mdadm still lets you do that. I agree, only useful for learning how to use it.

----------

## madchaz

 *1clue wrote:*   

> As I understand it, your only real issue here is that your fstab is confused depending on how many drives are mounted, right?
> 
> Why not mount by UUID?  Just stretch your terminal a little wider.
> 
> ....
> ...

 

Actually my issue is much worst then that. My issue is I didn't get why it got it reversed (putting drives 0 and 1 as sdc/sdd and drives 2 and 3 as sda/sdb). System as been up and running since before I posted this. Just trying to understand why it acts like it does.

----------

## 1clue

Yes, I had exactly that problem, and mounting by UUID is how I got around it.

I have a SATA drive that I stick into a bay for backups.  If I boot with that drive plugged in, it becomes /dev/sda.  If not, of course, my entire RAID array moves.

This doesn't solve the fact of /dev/sda being one drive or the other, but it allows you to define your partitions and always know it will look at the one you intended it to look at.

----------

## madchaz

edit: posted twice apparently. See below

----------

## madchaz

 *1clue wrote:*   

> Yes, I had exactly that problem, and mounting by UUID is how I got around it.
> 
> I have a SATA drive that I stick into a bay for backups.  If I boot with that drive plugged in, it becomes /dev/sda.  If not, of course, my entire RAID array moves.
> 
> This doesn't solve the fact of /dev/sda being one drive or the other, but it allows you to define your partitions and always know it will look at the one you intended it to look at.

 Using UUID wouldn't solve my problem. My curiosity wouldn't have been satisfied.

Besides, the disks aren't going to move, so the only "problem" is what I expected to be sda is sdc. 

However, we found out why a few posts ago. It also helped explain some odd behavior I had seen with that machine in the past, where windows didn't always put the disks as I would have expected it to when I installed.

----------

