Don't understand german? Read or subscribe to my english-only feed.

Stable root device (AKA UUID)

Given: server with SCSI disk for the system plus a SCSI storage in the back. The SCSI disk uses another driver than the SCSI storage. Installing Debian etch via grml is no problem, the system disk is /dev/sda, the SCSI storage is bound to /dev/sdb. But: who guarantees that /dev/sda is always the systemdisk? Using the Debian-kernel with initramfs isn’t capable of booting the system via root=/dev/sda1 because /dev/sda1 corresponds to the SCSI storage. (Side-note: the grml-kernel does not have this problem, it just boots the system without any problems at all. 8-))

Generic solution: use the power of UUID:

root@grml # /lib/udev/vol_id /dev/sda1 | grep UUID
ID_FS_UUID=4a6aed11-42dd-4c82-81ce-8f469e93f210
root@grml # eval $(/lib/udev/vol_id /dev/sda1 | grep UUID)
root@grml # ls -la /dev/disk/by-uuid/$ID_FS_UUID
lrwxrwxrwx 1 root root 10 Aug 10 11:01 /dev/disk/by-uuid/4a6aed11-42dd-4c82-81ce-8f469e93f210 -> ../../sda1

Now we know the UUID and boot the system via root=UUID=… instead of a root=/dev/sda-entry:

title           Debian Etch, kernel 2.6.15-1-686 (on /dev/sda1)
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.15-1-686 root=UUID=4a6aed11-42dd-4c82-81ce-8f469e93f210 ro
initrd          /boot/initrd.img-2.6.15-1-686

Finally do not forget to adjust /etc/fstab as well for all entries:

UUID=e0164f78-9821-4eaf-bda7-1fd9b43a6f06 /     ext3  defaults,errors=remount-ro 0 1
UUID=4a6aed11-42dd-4c82-81ce-8f469e93f210 /home ext3  defaults                   0 0
UUID=0e88f32f-fb98-4279-b3bc-8edfc2046b5d none  swap  sw                         0 0

2 Responses to “Stable root device (AKA UUID)”

  1. Michael Gebetsroither Says:

    labels sind da imho etwas userfreundlicher.
    nur der vollständigkeit halber ;)

    # xfs_admin -L test /dev/hda1
    writing all SBs
    new label = “test”

    # findfs LABEL=test
    /dev/hda1

  2. mika Says:

    Wie schon miteinander besprochen, aber ebenfalls JFTR ;-) kann man Labels nicht bei allen Dateisystemen im Nachhinein, und (noch wichtiger) ohne Remount ändern. Wenn man die Wahl hat, sind die Labels aber meist wartungsfreundlicher, ACK. :-)

    mfg,
    -mika-