All Products
Search
Document Center

:Identify disk partitions by UUID in GRUB

Last Updated:Apr 21, 2026

Replace device-name-based partition identifiers with UUIDs in the GRUB configuration file to prevent GRUB boot failures after disk operations such as image imports.

Background

Device names such as /dev/vda1 can change after operations like image imports. If the device name in the GRUB configuration no longer points to the correct partition, the kernel fails to load the file system and the instance cannot start.

Procedure

Configure GRUB to identify the root partition by UUID to ensure reliable boot.

Warning

Modifying the GRUB configuration is a high-risk operation. Incorrect modifications can prevent your instance from starting. Before you proceed, create a snapshot for your instance to ensure data security.

Check the GRUB version

GRUB has two major versions: GRUB2 and GRUB Legacy. GRUB Legacy only receives bug fixes. Check your GRUB version as follows.

  1. Log on to a Linux instance using Workbench.

  2. Identify your GRUB version:

    GRUB2

    Check the structure of the GRUB configuration directory:

    sudo ls /etc/grub.d/

    If the output includes files such as 00_header and 40_custom, you are using GRUB2. Example output:

    00_header  05_debian_theme  10_linux  20_linux_xen  30_os-prober  30_uefi-firmware  40_custom  41_custom

    GRUB Legacy

    Check the contents of the /boot/grub/ directory:

    sudo ls /boot/grub/

    If the /boot/grub directory contains a menu.lst file, you are using GRUB Legacy.

Locate the configuration file

GRUB2 and GRUB Legacy use different configuration file paths.

  • GRUB2: /boot/grub/grub.cfg or /boot/grub2/grub.cfg.

  • GRUB Legacy: /boot/grub/menu.lst or /boot/grub/grub.conf.

Navigate to the /boot directory to find the GRUB configuration file.

Get disk partition UUIDs

Obtain the UUID of each disk partition for use in the GRUB configuration file.

  1. View disk partition UUIDs:

    sudo blkid

    Example output:

    /dev/vda1: LABEL="/" UUID="e7e8xxxx-xxxx-xxxx-xxxx-xxxxb9263645" TYPE="ext4" PARTUUID="0efbxxxx-01"

    Here, the UUID of /dev/vda1 is e7e8xxxx-xxxx-xxxx-xxxx-xxxxb9263645.

Modify the configuration file

Important

The following example uses the GRUB2 configuration file /boot/grub2/grub.cfg. If you use GRUB Legacy or a customized GRUB configuration, adjust the commands in Step 1 and Step 2 accordingly.

  1. Back up the current GRUB configuration file:

    sudo cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
    Important

    To restore the GRUB configuration file, run:

    sudo cp -f /boot/grub2/grub.cfg.bak /boot/grub2/grub.cfg

  2. Open the GRUB configuration file:

    sudo vim /boot/grub2/grub.cfg
  3. Press i to enter insert mode. Replace all occurrences of root=/dev/vda1 with root=UUID=e7e8xxxx-xxxx-xxxx-xxxx-xxxxb9263645.

    linux   /boot/vmlinuz-3.16.0-4-amd64 root=/dev/vda1 ro single debian-installer=en_US net.ifnames=0 vga=792 console=tty0 console=ttyS0,115200n8

    Modified line:

    linux   /boot/vmlinuz-3.16.0-4-amd64 root=UUID=e7e8xxxx-xxxx-xxxx-xxxx-xxxxb9263645 ro single debian-installer=en_US net.ifnames=0 vga=792 console=tty0 console=ttyS0,115200n8
  4. Press Esc to exit insert mode, then type :wq to save and exit.

  5. (Optional) Verify that all disk partition identifiers in GRUB now use UUID:

    sudo cat /boot/grub2/grub.cfg

References

To configure the fstab file to auto-mount a data disk, see Auto-mount data disk using UUID.