# Kernel disc enumeration

## Letharion

Sometimes, after performing an install and rebooting, the newly installed kernel enumerate discs differently from the livecd one. Why is that? Can I foresee the change? Normally it's not much of a problem, but recently I performed a remote install and because sdb became sda. My carefully written and double checked grub and fstab became invalid.

I had to walk a collegue through fixing it over the phone.

----------

## Nacon

You can replace your /dev/sda1 with the UUID of the disk to avoid the usage of /dev/sda or /dev/sdb.

Just get the UUID by running the "blkid" command:

 *Quote:*   

> 
> 
> /dev/sda1: UUID="115bd492-d1z9-4c4d-b5a4-748de242d1a3" TYPE="ext4"
> 
> 

 

Your menu.lst should look similar to this:

 */boot/grub/menu.lst wrote:*   

> 
> 
> title Gentoo
> 
> kernel /boot/kernel root=UUID=115bd492-d1z9-4c4d-b5a4-748de242d1a3 rootfstype=ext4 ro quiet
> ...

 

The same for /etc/fstab, just insert your UUID instead of /dev/sda1.

The downside of this is, that you have a long string, which is not very friendly in terms of readability.

----------

## Letharion

Thanks, that's useful to know  :Smile: 

Is this the "recommended" way of solving this issue?

It doesn't shed any light on why thet problem exists in the first place.

----------

## d2_racing

Never used that actually.

----------

## NeddySeagoon

Nacon,

That doesn't work for me but my root is /dev/md3 which is a raid5 volume.

----------

## Sadako

Isn't the UUID a filesystem attribute rather than a disk identifier?

I mean, run mkfs on the same partition and you'll have a different UUID.

I use the /dev/disk/by-id/* symlinks within fstab, which offer more or less the same functionality as UUIDs, only you can't use them to specify the root block device to the kernel.

It's enough to save against "/dev/sda" and "/dev/sdb" switching, for example.

 *NeddySeagoon wrote:*   

> Nacon,
> 
> That doesn't work for me but my root is /dev/md3 which is a raid5 volume.

 In theory it should work, only you'd still need to tell the kernel how to assemble the raid array first (and as it's a filesystem attribute it can't be used to identify the array alements...).

----------

## NeddySeagoon

Hopeless,

The array is autoassembled and that still happens before the kernel tries to mount root.

```
kernel (hd0,0)/2.6.33-gentoo root=/dev/md5 vga=0x317 video=vesafb:mtrr:3,ywrap
```

works 

```
kernel (hd0,0)/2.6.33-gentoo root=UUID=ff5730d5-c28d-4276-b300-5b0b0fc60300 vga=0x317 video=vesafb:mtrr:3,ywrap
```

gets me a VFS panic.

----------

## Sadako

 *NeddySeagoon wrote:*   

> Hopeless,
> 
> The array is autoassembled and that still happens before the kernel tries to mount root.
> 
> ```
> ...

 If you're interested in testing, you could try appending (for example) "md=d0,/dev/sdb1,/dev/sda1 raid=noautodetect" to your kernel command line, I found the raid autodetact a little flaky before so disabled it in kernel.

Another thing you could try, append rootdelay=10 to your command line, maybe the raid array just isn't assembled when the kernel scans for UUIDs?

Of course, the above would be even less convenient to actually use than what you already have...

I'm just curious, maybe the kernel doesn't automatically scan assembled raid arrays for UUIDs.

----------

## NeddySeagoon

Hopeless,

I'll add in things on at a time, so I can test at normal boot time.

I've made some notes in grub.conf.

Can I use UUID to manually assemble the raid5?

If I have to use device names before I can use UUID, that defeats the purpose.

----------

## Sadako

 *NeddySeagoon wrote:*   

> Can I use UUID to manually assemble the raid5?

 I don't think so, like I said above I believe the UUID is a filesystem attribute, therefore you'd only find one on the assembled array, not on the individual elements.

Of course, I could be wrong.

----------

## NeddySeagoon

Hopeless,

It looks like you are right about UUIDs being filesystem attributes.

Also, rootdelay=10 with UUID and root on raid5 doesn't help. It only takes 10 seconds longer to work out that it can't mount root.

The error message listed all the partitions with their drivers, except for the raid sets which had their drivers listed as (??).

I'll try the manual assembly next.

----------

## krinn

read somewhere you must set the UUID in mdadm.conf too, and use blkid /dev/md? to get UUID of the assembled array to put in mdadm.conf.

----------

## NeddySeagoon

krinn,

Thats  PITA.  It means I have to have an initrd as I have root on raid and mdadm.conf is on the root fs.

I kept root outside of LVM to avoid having to deal with an initrd.

I'll play with UUIDs on my netbook

----------

