# SATA Drive changes device path

## oneself

Hi All,

I've been using Gentoo for a few years now on one of my machines, and

for some odd reason, it decided to change my SATA drive from /dev/sda

to /dev/sdb.  This now means that the machine will not boot.  I can

say that it was really scary to figure out what happened, since at first

glance I thought that this was a hardware failure.  So, at least it's not that,

but the drive keeps changing it's path.

My machine has one SATA drive which was always located at /dev/sda.

This is the drive the my system is on, and that I boot from.  In addtion,

I have a regular drive at /dev/hda.  I have not changed or added or

repartitioned the drives in any way.  In fact, if I reboot enough times

it will eventually switch back to the right location.  I keep my system

up to date, and I believe that it's pretty close to latest.

How do I make sure Gentoo always assigns the same device path

to the same piece of hardware?

Thanks

----------

## jburns

One way of handling the problem is to use partition lables or UUID to identify the partitions.  See https://forums.gentoo.org/viewtopic-p-4588037.html#4588037

----------

## oneself

Hi and thanks for the quick reply,

I have tried implementing this, but I've ran into a few problems.  First

the /dev/disk/by-uuid seems to be missing some partitions.  Here is mine:

```
lrwxrwxrwx 1 root root 10 Feb 16 11:27 4df39b80-4914-4bdb-9ed1-4af77c3d3220 -> ../../sdb6

lrwxrwxrwx 1 root root 10 Feb 16 11:27 5fb1e105-032d-4237-a818-c69bb6b5e5c9 -> ../../sdb3

lrwxrwxrwx 1 root root 10 Feb 16 11:27 6a45644e-9e17-4e7a-a840-06011d5eb994 -> ../../sdb7

lrwxrwxrwx 1 root root 10 Feb 16 11:27 a2c37e80-b574-45f4-bdfe-cae06227c4b5 -> ../../sdb8

lrwxrwxrwx 1 root root 10 Feb 16 11:27 b5979bec-0895-432a-8f0a-0419cab06db7 -> ../../sdb1

lrwxrwxrwx 1 root root 10 Feb 16 11:27 cb091e38-b984-49c9-8605-e179c50b5059 -> ../../sdb2

lrwxrwxrwx 1 root root 10 Feb 16 11:27 ec026eb6-567d-4960-8d3f-cfaae1140346 -> ../../hda1

```

sdb5 (my swap partition) seems to be missing.

Regardless, isn't there a way for Gentoo to allocate device paths in a sticky predictable way?

I've been using Linux in general and Gentoo in particular for some time now, and this seems

very strange to me.

----------

## jburns

You could try giving the swap partition a label and using the label in fstab. See http://www.eukhost.com/forums/showthread.php?t=975 also look at the man pages for mkswap and fstab.

----------

## oneself

Hi,

Yeah, setting the label is an excellent idea.  I set the labels on all

of my partitions using the e2label utility:

```
e2label /dev/sdb1 boot

e2label /dev/sdb2 root

e2label /dev/sdb3 home

...

```

For swap (as you suggested) I set the label as follows:

```
mkswap -L swap /dev/sdb5
```

I then edited my fstab to use above labels:

```
LABEL=boot      /boot      ext3      defaults,noatime   1 2

LABEL=root      /      ext3      noatime         0 1

LABEL=tmp      /tmp      ext3      noatime         0 2

LABEL=home      /home      ext3      noatime         0 2

...

```

And in grub.conf I specify root as a label as well:

```
title=Gentoo-2.6.23-r8 [Default]

root (hd0,0)

kernel /kernel-genkernel-x86-2.6.23-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=LABEL=root

initrd /initramfs-genkernel-x86-2.6.23-gentoo-r8

```

So, now have a system that is pretty much device path agnostic.  I

still don't know why the path changed on me, but now, I don't really

care anymore.

Thanks for your help

----------

## lyallp

This is also caused by a change in Boot order in your BIOS.

The order in which they appear in the BIOS boot list is the order in which they are assigned device id's (generally)

----------

