Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
Applies to SUSE Linux Enterprise Server 11 SP4 11 SP4

6 Using UUIDs to Mount Devices

This section describes the optional use of UUIDs instead of device names to identify file system devices in the boot loader file and the /etc/fstab file.

6.1 Naming Devices with udev

In the Linux 2.6 and later kernel, udev provides a userspace solution for the dynamic /dev directory, with persistent device naming. As part of the hotplug system, udev is executed if a device is added to or removed from the system.

A list of rules is used to match against specific device attributes. The udev rules infrastructure (defined in the /etc/udev/rules.d directory) provides stable names for all disk devices, regardless of their order of recognition or the connection used for the device. The udev tools examine every appropriate block device that the kernel creates to apply naming rules based on certain buses, drive types, or file systems. For information about how to define your own rules for udev, see Writing udev Rules.

Along with the dynamic kernel-provided device node name, udev maintains classes of persistent symbolic links pointing to the device in the /dev/disk directory, which is further categorized by the by-id, by-label, by-path, and by-uuid subdirectories.

Note
Note

Other programs besides udev, such as LVM or md, might also generate UUIDs, but they are not listed in /dev/disk.

6.2 Understanding UUIDs

A UUID (Universally Unique Identifier) is a 128-bit number for a file system that is unique on both the local system and across other systems. It is a randomly generated with system hardware information and time stamps as part of its seed. UUIDs are commonly used to uniquely tag devices.

6.2.1 Using UUIDs to Assemble or Activate File System Devices

The UUID is always unique to the partition and does not depend on the order in which it appears or where it is mounted. With certain SAN devices attached to the server, the system partitions are renamed and moved to be the last device. For example, if root (/) is assigned to /dev/sda1 during the install, it might be assigned to /dev/sdg1 after the SAN is connected. One way to avoid this problem is to use the UUID in the boot loader and /etc/fstab files for the boot device.

The device ID assigned by the manufacturer for a drive never changes, no matter where the device is mounted, so it can always be found at boot. The UUID is a property of the file system and can change if you reformat the drive. In a boot loader file, you typically specify the location of the device (such as /dev/sda1) to mount it at system boot. The boot loader can also mount devices by their UUIDs and administrator-specified volume labels. However, if you use a label and file location, you cannot change the label name when the partition is mounted.

You can use the UUID as criterion for assembling and activating software RAID devices. When a RAID is created, the md driver generates a UUID for the device, and stores the value in the md superblock.

6.2.2 Finding the UUID for a File System Device

You can find the UUID for any block device in the /dev/disk/by-uuid directory. For example, a UUID looks like this:

e014e482-1c2d-4d09-84ec-61b3aefde77a

6.3 Using UUIDs in the Boot Loader and /etc/fstab File (x86)

After the install, you can optionally use the following procedure to configure the UUID for the system device in the boot loader and /etc/fstab files for your x86 system.

Before you begin, make a copy of /boot/grub/menu.1st file and the /etc/fstab file.

  1. Install the SUSE Linux Enterprise Server for x86 with no SAN devices connected.

  2. After the install, boot the system.

  3. Open a terminal console as the root user or equivalent.

  4. Navigate to the /dev/disk/by-uuid directory to find the UUID for the device where you installed /boot, /root, and swap.

    1. At the terminal console prompt, enter

      cd /dev/disk/by-uuid
    2. List all partitions by entering

      ll
    3. Find the UUID, such as

      e014e482-1c2d-4d09-84ec-61b3aefde77a —> /dev/sda1
  5. Edit /boot/grub/menu.1st file, using the Boot Loader option in YaST or using a text editor.

    For example, change

    kernel /boot/vmlinuz root=/dev/sda1

    to

    kernel /boot/vmlinuz root=/dev/disk/by-uuid/e014e482-1c2d-4d09-84ec-61b3aefde77a
    Important
    Important

    If you make a mistake, you can boot the server without the SAN connected, and fix the error by using the backup copy of the /boot/grub/menu.1st file as a guide.

    If you use the Boot Loader option in YaST, there is a defect where it adds some duplicate lines to the boot loader file when you change a value. Use an editor to remove the following duplicate lines:

    color white/blue black/light-gray
    default 0
    timeout 8
    gfxmenu (sd0,1)/boot/message

    When you use YaST to change the way that the root (/) device is mounted (such as by UUID or by label), the boot loader configuration needs to be saved again to make the change effective for the boot loader.

  6. As the root user or equivalent, do one of the following to place the UUID in the /etc/fstab file:

    • Launch YaST as the root user, select System › Partitioner, select the device of interest, then modify Fstab Options.

    • Edit the /etc/fstab file to modify the system device from the location to the UUID.

      For example, if the root (/) volume has a device path of /dev/sda1 and its UUID is e014e482-1c2d-4d09-84ec-61b3aefde77a, change line entry from

      /dev/sda1   /            reiserfs   acl,user_xattr        1 1

      to

      UUID=e014e482-1c2d-4d09-84ec-61b3aefde77a   /   reiserfs   acl,user_xattr        1 1
      Important
      Important

      Do not leave stray characters or spaces in the file.

6.4 Using UUIDs in the Boot Loader and /etc/fstab File (IA64)

After the install, use the following procedure to configure the UUID for the system device in the boot loader and /etc/fstab files for your IA64 system. IA64 uses the EFI BIOS. Its file system configuration file is /boot/efi/SuSE/elilo.conf instead of /etc/fstab.

Before you begin, make a copy of the /boot/efi/SuSE/elilo.conf file.

  1. Install the SUSE Linux Enterprise Server for IA64 with no SAN devices connected.

  2. After the install, boot the system.

  3. Open a terminal console as the root user or equivalent.

  4. Navigate to the /dev/disk/by-uuid directory to find the UUID for the device where you installed /boot, /root, and swap.

    1. At the terminal console prompt, enter

      cd /dev/disk/by-uuid
    2. List all partitions by entering

      ll
    3. Find the UUID, such as

      e014e482-1c2d-4d09-84ec-61b3aefde77a —> /dev/sda1
  5. Edit the boot loader file, using the Boot Loader option in YaST.

    For example, change

    root=/dev/sda1

    to

    root=/dev/disk/by-uuid/e014e482-1c2d-4d09-84ec-61b3aefde77a
  6. Edit the /boot/efi/SuSE/elilo.conf file to modify the system device from the location to the UUID.

    For example, change

    /dev/sda1   /   reiserfs   acl,user_xattr        1 1

    to

    UUID=e014e482-1c2d-4d09-84ec-61b3aefde77a   /   reiserfs   acl,user_xattr        1 1
    Important
    Important

    Do not leave stray characters or spaces in the file.

6.5 Additional Information

For more information about using udev(8) for managing devices, see Dynamic Kernel Device Management with udev in the SUSE Linux Enterprise Server 11 Administration Guide.

For more information about udev(8) commands, see its man page. Enter the following at a terminal console prompt:

man 8 udev
Print this page