# Can't boot because the harddrive naming keeps changing

## Kasumi_Ninja

Ok, this is really driving me insane. Sometimes when I boot, the root partition name gets changed. Once it's  changed it gets stuck in a loop of changing device names making it impossible to boot. For example before I reboot the root partition was on /dev/sdc2 when I reboot the naming has changed to /dev/sdb2 making it impossible to boot. I adjust fstab and reboot. But the system again fails to boot because this time root is on /dev/sdc2 (ord sdg2, sde2  etc. etc.). I tried using uuid for my harddrive but this didn't working either   :Confused: 

----------

## smerf

 *Aniruddha wrote:*   

> I tried using uuid for my harddrive but this didn't working either  

 

Why? UUID is also changing? What have you done?

----------

## Kasumi_Ninja

 *smerf wrote:*   

>  *Aniruddha wrote:*   I tried using uuid for my harddrive but this didn't working either   
> 
> Why? UUID is also changing? What have you done?

 

Nothing special, you can read it here:

https://forums.gentoo.org/viewtopic-t-701116-highlight-.html

The only thing I can think of its that I shouldn't use 'vol_id -u' to detect my drives. I am not the only one with this problem though:

 *danomac wrote:*   

>  *gsoe wrote:*   The UUID part seems solved, but I'm quite puzzled by your changing devicenames. I've tried rebooting mandriva (and Gentoo) a couple of times now with and without a plugged usb-stick. It doesn't affect devicenames.  
> 
> I'm not, I've seen the changing device names on my own PC. I've actually had multiple UUIDs even show up for a partition.
> 
> I wound up having to alias one controller so this wouldn't happen. It's really frustrating when your /home partition doesn't mount properly.  
> ...

 

----------

## smerf

What is your hardware setup?

----------

## mackerel

You may be able to set the boot disk order in your bios, according to the mb. I have a removable drive and when it is in, I just have it set to last order so that it does not change my boot. If you run into this immediately and need to bypass and you use grub, just edit it at load.

----------

## Kasumi_Ninja

My bios is ok (I have disabled the option to boot from usb) In regard to my hw setup. I have three sata drives from Samsung. I partially solved this problem by using /dev/disk/by-id/ for my fstab entries. Unfortunately I have problems enabling this feature in grub therefor I have manually guess each boot on which drive my root partition resides (the past three boots it went from sdb2 to sdf2 to sdg2   :Confused: )

----------

## Habbit

From the post in the GRUB-devel list: you tried to boot with this config

```
title=Gentoo Linux (2.6.24-gentoo-r8)

root (hd0,1)

kernel /boot/kernel-genkernel-x86-2.6.24-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=LABEL=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD103UJS13PJ1MQ318013-part2 udev

initrd /boot/initramfs-genkernel-x86-2.6.24-gentoo-r8
```

I think you are misunderstanding the "LABEL" part: some filesystems can have labels assigned to them like this:

ext2/3/4: tune2fs -L my_label

reiserfs: reiserfstune --label my_label

(etc)

Once you have set a label for the volume, you can refer to them with /dev/disk/by-label/my_label in Linux, and with LABEL=my_label in the kernel command line. You can do the same with UUIDs if your initrd scripts support them - just replace by-label or LABEL with by-uuid or UUID in the right places. You can get the UUID of a filesystem with "vol_id -u DEVICE". The advantage of this approach is that labels have to be specifically set, but UUIDs are automatically available for most filesystems.

As I said in the GRUB devel list, if this problem also happens in GRUB itself (i.e. you don't know whether the root partition is in hd0, hd1 or hd2), you can use the "find" (GRUB Legacy) or "search" (GRUB2) commands.

----------

## Kasumi_Ninja

 *Habbit wrote:*   

> From the post in the GRUB-devel list: you tried to boot with this config
> 
> ```
> title=Gentoo Linux (2.6.24-gentoo-r8)
> 
> ...

 

I tried settings UUID's but strangely enough they kept changing as well. /dev/disk/by-id however works fine. Is there a grub option for /dev/disk/by-id? e.g.

```
real_root=ID=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD103UJS13PJ1MQ318013-part2 udev
```

----------

## Habbit

 *Aniruddha wrote:*   

> I tried settings UUID's but strangely enough they kept changing as well.

 

That is extremely strange, since UUIDs are based on the characteristics of the filesystem, not of the disk they reside on. Are you _positively sure_ that the output of "vol_id -u DEVICE" with the same DEVICE (I mean, the same filesystem, even if the /dev/sdXY device path is different) changes between reboots?

 *Aniruddha wrote:*   

> /dev/disk/by-id however works fine. Is there a grub option for /dev/disk/by-id? e.g.
> 
> ```
> real_root=ID=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD103UJS13PJ1MQ318013-part2 udev
> ```
> ...

 

I don't know any such option. By the way, even if it existed, you would write one of:

real_root=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD103UJS13PJ1MQ318013-part2

or:

real_root=ID=scsi-SATA_SAMSUNG_HD103UJS13PJ1MQ318013-part2

----------

## Cyker

This sort of thing is the EXACT reason why I still use the old BLOCK drivers for my IDE drives (so they get fixed at a nice predictable /dev/hdx), and why I greatly fear them being removed.

I really really hate that everything is /dev/sdx now - It is a stupid stupid way to map things and having to rely on udev kludges like UUID and by-label, both of which have caused me problems in the past due to things like the length of the reference names or because they were not even existing at that part of the boot process.

If the kernel e.g. mapped IDE stuff to hdx, SCSI stuff to sdx, sata stuff to stx and usb stuff to usbx instead of *everything* now to sdx, things would be a lot less problematic...

----------

## Kasumi_Ninja

@Habbit

I find it also strange that UUID isn't working, although it happens more (see https://forums.gentoo.org/viewtopic-p-5164344.html?sid=65ac008880ace589289c3035a8b0862d#5164344 ). Afaik I have implemented UUID correctly, I've even written  a little how-to:

 *Aniruddha wrote:*   

> UUID can come in handy for those of us who want a fixed entry in fstab for their hard drives and/or removable media. And best off all, it's very easy! Here's how to do it:
> 
> 1) Make sure you are using an initrd image to boot Gentoo (UUID requires this). if you haven't a initrd image you can create one easily with genkernel:
> 
> ```
> ...

 

https://forums.gentoo.org/viewtopic-t-701116-highlight-.html

@Cyker

I noticed more people have troubles with udev renaming, the problem starrts when you add or remove a hard-drive from your current configuration.

I filed a bugreport here:

https://bugs.gentoo.org/show_bug.cgi?id=233423

----------

## danomac

 *Cyker wrote:*   

> This sort of thing is the EXACT reason why I still use the old BLOCK drivers for my IDE drives (so they get fixed at a nice predictable /dev/hdx), and why I greatly fear them being removed.

 

I do not have any IDE devices in my PC. They are all SATA devices. This still doesn't explain the renaming. I do not have anything plugged into the one IDE port on my motherboard either.

My motherboard is actually in the process of an RMA due to defective DDR3 slots, but I don't think this has anything to do with udev. Once I get my PC assembled with new parts I will be reinstalling for good measure. I will do some troubleshooting and post in this thread and on the bug above.

----------

## yabbadabbadont

Even though UUIDs should not change (unless you reformat a partition), the /dev/sd? devices can and will.  The libata kernel driver does not guarantee that the order that the device nodes will be created will be consistent from one boot to the next.  As long as you use UUID (or LABEL) in your /etc/fstab, the only place you may have issues with changing /dev/sd? nodes, is with removable devices.  The standard answer to that is, "If you are correctly using HAL, you don't need to know the devices..."  (which I don't agree with, by the way  :Wink: )

----------

## Kasumi_Ninja

I was checking /etc/conf.d.rc. Maybe this can help with the udev woes?

```
# UDEV OPTION:

# Set to "yes" if you want to save /dev to a tarball on shutdown

# and restore it on startup.  This is useful if you have a lot of

# custom device nodes that udev does not handle/know about.

RC_DEVICE_TARBALL="no"
```

@yabbadabbadont

I am really clueless why by-id does work and UUID doesn't. I suspect something is broken with UUID.

----------

## yabbadabbadont

 *Aniruddha wrote:*   

> @yabbadabbadont
> 
> I am really clueless why by-id does work and UUID doesn't. I suspect something is broken with UUID.

 

Not that it helps you any, but it works fine for me...   :Wink: 

----------

## Habbit

I guess this reply comes a bit too late, but are you sure the UUIDs are malfunctioning? You said your /dev/sdX drives were rotating on each reboot, so of course the output of "vol_id -u /dev/sda1" _will_ change across reboots. What you want to check is whether the output of "vol_id -u /dev/disk/by-id/scsi-1ATA_ST9200420ASG_5TUXGYD8-part1" (with your own device IDs, of course) changes across reboots.

----------

## Kasumi_Ninja

 *Habbit wrote:*   

> I guess this reply comes a bit too late, but are you sure the UUIDs are malfunctioning? You said your /dev/sdX drives were rotating on each reboot, so of course the output of "vol_id -u /dev/sda1" _will_ change across reboots. What you want to check is whether the output of "vol_id -u /dev/disk/by-id/scsi-1ATA_ST9200420ASG_5TUXGYD8-part1" (with your own device IDs, of course) changes across reboots.

 

Lol, ok I get your point.  Instead of issuing a 

```
vol_id -u /dev/sdc2
```

I should use

```
vol_id -u /dev/disk/by-id/scsi-1ATA_ST9200420ASG_5TUXGYD8-part1
```

I also noticed that /dev/disk/by-id/ didn't change even when my partition names did (I am on sdh2 now   :Confused: )

----------

