How to fix the hard drive to /dev/sdax ?

Hello,

I’ve got a weird bug sinds I’ve updated to 11.4. On boot, the main hard drive isn’t recognized as /dev/sda but it changes from time to time (probably according to other removable medias plugged in or not). It has been sdb, sde… but not sda anymore.

The trouble is that it boots and then it tries to find /dev/sda2 (the root partition). As it doesn’t find it asks me sether he should take “SAMSUNG…whathever…-part2”. Answering Yes solves the problem. But then, if I change in Grub the /dev/sde2, it still keeps changing of name. How could I have my hard drive back to /dev/sda2 ?

Thanks in advance for your help.

My /etc/fstab:

/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part1 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part2 /                    ext4       acl,user_xattr        1 1
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part3 /home                ext4       defaults              1 2

You should use the by-id (or by-label, etc.) names. They are there just for this case.
Thus not only in your fstab, but also in your GRUB menu.lst. openSUSE does this by fefault, thus I do not know why it is different in your system.

On 2011-03-14 22:36, jeancayron wrote:
>
> Hello,
>
> I’ve got a weird bug sinds I’ve updated to 11.4. On boot, the main hard
> drive isn’t recognized as /dev/sda but it changes from time to time
> (probably according to other removable medias plugged in or not). It has
> been sdb, sde… but not sda anymore.

Aha.

You can not influence those changes, except by controlling what you plug
in. What we do is not use those names that change.

Do you, per chance, have both SATA and PATA disks? The mixture causes problems.

> The trouble is that it boots and then it tries to find /dev/sda2 (the
> root partition). As it doesn’t find it asks me sether he should take
> “SAMSUNG…whathever…-part2”. Answering Yes solves the problem. But
> then, if I change in Grub the /dev/sde2, it still keeps changing of
> name. How could I have my hard drive back to /dev/sda2 ?

Grubs actually knows nothing about sd* names, it uses bios numbers inside,
and a file to map them.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

I would also check my BIOS Advanced to verify that your boot device is defaults to the correct HD.
As Hvv writes make sure your /boot/grub/menu.lst matches /etc/fstab and both are correct.


ls -al /dev/disk/by-id

It does change from time to time. But it should not bother you if you do not use device names (in /etc/fstab, /boot/grub/menu.lst and anywhere).
Here’s the last interesting discussion we had on that topic: OpenSuse 11.4 Hard drive order?

Notice that you might have some influence of the names by loading the modules in a different order an rebuilding the ramdisk, as suggested at the end of this thread. I couldn’t test it though.

Very nice command there tararpharazon

ls -al /dev/disk/by-id

Thank You,

While we are at it, let us go back to the basics: SDB:Basics of partitions, filesystems, mount points - openSUSE.

I wish they would explain why openSUSE defaults to the /dev/disk/by-id method while most others mount by UUID (not to be confused with /dev/disk/by-uuid). Those links are generated by udev at boot time, while UUIDs are written in partition superblocks and cached in /dev/.blkid.cache (under openSUSE). Also a comparison of /etc/blkid.conf between openSUSE and Ubuntu is kind of interesting … and might help explain a couple things.

openSUSE has:

# never try to sequentially scan all devices in /dev
EVALUATE=udev

while Ubuntu has:

# Perform simple UUID and LABEL lookups using udev information first, 
# fall back to scanning if not found
EVALUATE=udev,scan

Ubuntu also has:

# Send a change uevent if we discover that a symlink is wrong
SEND_UEVENT=yes

Whether you mount by-id or by-uuid will behave differently depending on what you are doing. uuids won’t mount if they are duplicated (like if you copy a partition with dd and mount both the copy and the original) but will stay consistent if you add/remove partitions. by-id will be a mess if partitions change but don’t pose a problem when you duplicate disks. by-id and by-uuid are both symlinks and can go missing or wrong indeed - if you play back and forth with partitions.

On 2011-03-15 12:06, please try again wrote:
> I wish they would explain why openSUSE defaults to the /dev/disk/by-id
> method while most others mount by UUID (not to be confused with
> /dev/disk/by-uuid).

I fail to see how you can mount without using the symlinks. I don’t see the
difference you mention.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

I think he means the* -U (and -L*) options of the mount command (see* man mount*) and their equivalent in* /etc/fstab* using* UUID=* (or* LABEL=) as described in man fstab*.

On 2011-03-15 16:36, hcvv wrote:
>
> I think he means the- -U -(and- -L-) options of the -mount- command
> (see- man mount-) and their equivalent in- /etc/fstab- using- UUID=-
> (or- LABEL=-) as described in- man fstab-.

Ah, I see. But it ends using the same thing, I believe.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

I think it makes you independant of udev functionality, though I never had any problem here.

@jeancayron Could you post outputs from


cat /boot/grub/menu.lst 
###  before and after fstabs
cat /etc/fstab

when the partitions have moved/changed?
Refresh brief of how it changed this time?

@hcvv
EVALUATE= over my head

But my 11.4 /etc/fstab specifies which partitions to mount by LABEL=home and /dev/disk/by-id/. Wouldn’t the -L and -U only apply to the CLI mount command?

Hye,

Thanks for all the answers. It seems to inspire all of you :wink:

The problem occured after I made an update. I first did a zypper up but I think my 11.3 was to much different from the original one (all my KDE was in 4.6) that it didn’t succeed: after reboot, only the grub menu had the 11.4 branding, the rest had the 11.3 one and more or less the half of the packages were 11.3 and the other 11.4… openSUSE 11.35 indeed lol! But the boot was OK
So, as I didn’t want to waste my time, I did an update with the network-install CD and the problem appeared after that. I didn’t change anything to the automatic configuration of grub. But, at that time, I had some external hard drive plugged in, and I think the problem comes partially from there.
But the problem described above happens even without them plugged in.

This is my menu.lst from grub now:

# Modified by YaST2. Last modification on dim mås 13 18:14:41 CET 2011
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader

default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.4 - 2.6.37.1-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/sdb2 resume=/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part1 splash=silent quiet nomodeset showopts vga=0x317
    initrd /boot/initrd-2.6.37.1-1.2-desktop

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.4 - 2.6.37.1-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/sdb2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 x11failsafe nomodeset vga=0x317
    initrd /boot/initrd-2.6.37.1-1.2-desktop

And /etc/fstab

/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part1 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part2 /                    ext4       acl,user_xattr        1 1
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part3 /home                ext4       defaults              1 2

I’ll repost one after reboot but I’ll first try to indicate the /dev/disk/by-id/ in menu.lst to see if it solves the thing.

Update:
I just chang the menu.lst to that and now everything is fine.

This is now the grub menu:

# Modified by YaST2. Last modification on mår mås 15 21:08:02 CET 2011
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in /etc/sysconfig/bootloader

default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title Desktop -- openSUSE 11.4 - 2.6.37.1-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part2 resume=/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part1 splash=silent quiet nomodeset showopts vga=0x317
    initrd /boot/initrd-2.6.37.1-1.2-desktop

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- openSUSE 11.4 - 2.6.37.1-1.2
    root (hd0,1)
    kernel /boot/vmlinuz-2.6.37.1-1.2-desktop root=/dev/disk/by-id/ata-SAMSUNG_SP2004C_S07GJ1UYB03169-part2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 x11failsafe nomodeset vga=0x317
    initrd /boot/initrd-2.6.37.1-1.2-desktop

Thanks for the help.

PS: How can I change the title to “resolved”, I can’t edit my first message… weird.

No need to change the title. Those interested after 6 months will read to the end and will be satisfied (but they will have a task in seeing the difference between the to listings, a little bit of red couldd have helped here :wink:

On 2011-03-15 18:06, hcvv wrote:
>
> I think it makes you independant of -udev- functionality, though I never
> had any problem here.

Mmm… that would be interesting, if true. I’m using LABEL= in fstab, and
/dev/disk/by-id (or uuid) in /etc/crypttab.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Just for you:


/dev/disk/by-id/ata-ST31000528AS_9VP5X58H-part9    /    ext4    acl,user_xattr 1 1 
LABEL=home    /home    ext3    acl,user_xattr 1 2 
/dev/disk/by-id/ata-ST31000528AS_9VP5X58H-part8    swap    swap    defaults 0 0 
/dev/disk/by-id/ata-ST31000528AS_9VP5X58H-part6    /srv    ext3    acl,user_xattr 1 2 
/dev/disk/by-id/ata-ST31000528AS_9VP5X58H-part7 /var    ext3    acl,user_xattr 1 2 

More on this:

# cat /etc/fstab

UUID=e15f9b1d-d2e4-404f-aac6-79e46b016eb9 /                    ext3       acl,user_xattr        1 1
UUID=ed078dce-1524-4421-933f-68577673f1cd /local               ext3       acl,user_xattr        1 2
UUID=37a0de1f-8fbb-4883-95b5-f76c7853d01b /usr                 ext4       acl,user_xattr        1 2
UUID=620d92ae-0325-479d-8c41-fa0f7bde5912 /var                 ext4       acl,user_xattr        1 2
UUID=50089717-8b5e-482a-8686-7d47d88b7402 swap                 swap       defaults              0 0
UUID=667b3d11-8d33-44a1-92a9-4ce2b0d1ce79 swap                 swap       defaults              0 0
UUID=a3c827b2-7dd4-45e2-b7e9-979594837096 /home                ext3       defaults              1 2
UUID=e373d504-6654-4859-8b31-0297d98ba743 /srv                 ext4       defaults              1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0

# for uuid in $(awk '/UUID/{ sub(/UUID=/,"",$1); print $1}' /etc/fstab) ; do
echo -n  "$uuid -> "
findfs UUID=$uuid
dumpe2fs -h $(findfs UUID=$uuid) 2>/dev/null | grep UUID
done


e15f9b1d-d2e4-404f-aac6-79e46b016eb9 -> /dev/sda11
Filesystem UUID:          e15f9b1d-d2e4-404f-aac6-79e46b016eb9
ed078dce-1524-4421-933f-68577673f1cd -> /dev/sda9
Filesystem UUID:          ed078dce-1524-4421-933f-68577673f1cd
37a0de1f-8fbb-4883-95b5-f76c7853d01b -> /dev/sda12
Filesystem UUID:          37a0de1f-8fbb-4883-95b5-f76c7853d01b
620d92ae-0325-479d-8c41-fa0f7bde5912 -> /dev/sda13
Filesystem UUID:          620d92ae-0325-479d-8c41-fa0f7bde5912
50089717-8b5e-482a-8686-7d47d88b7402 -> /dev/sda15
667b3d11-8d33-44a1-92a9-4ce2b0d1ce79 -> /dev/sdb9
a3c827b2-7dd4-45e2-b7e9-979594837096 -> /dev/sda10
Filesystem UUID:          a3c827b2-7dd4-45e2-b7e9-979594837096
e373d504-6654-4859-8b31-0297d98ba743 -> /dev/sda14
Filesystem UUID:          e373d504-6654-4859-8b31-0297d98ba743

On 2011-03-16 00:06, please try again wrote:
>
> tararpharazon;2305597 Wrote:
>> Just for you:
>>>

> More on this:

I prefer labels, it avoids confusions:

> LABEL=a_main / ext3 noauto,acl,user_xattr 1 1
> LABEL=a_boot_2 /boot ext2 acl,user_xattr 1 2
> LABEL=a_swap swap swap pri=-1 0 0
> LABEL=b_swap swap swap pri=-1 0 0
>
> LABEL=c_home /home xfs defaults 1 2
> LABEL=b_main_usr /usr reiserfs acl,user_xattr 1 2
> LABEL=c_usr_src /usr/src reiserfs acl,user_xattr 1 3
> LABEL=c_usr_local /usr/local reiserfs acl,user_xattr 1 3
> LABEL=b_main_opt /opt reiserfs acl,user_xattr 1 2
> LABEL=c_home_mail /home1 reiserfs acl,user_xattr 1 2

I see at a glance what each partition is for from their name, which is very
useful when doing a rescue and I don’t have access to my notes on file.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)