All Products
Search
Document Center

:Modify the GRUB configuration file to identify disk partitions by UUID

Last Updated:Jan 28, 2026

GRUB is a program that boots the operating system. Its configuration file can identify a disk partition by either its device name or its Universally Unique Identifier (UUID). This guide explains how to modify the GRUB configuration file to use a UUID to identify a disk partition.

Background information

If you use a device name (such as /dev/vda1) to identify a disk partition in the GRUB configuration file, that device name can change after operations like importing an image to start an instance. If the specified device name no longer points to the correct partition, the kernel might fail to load the file system, which prevents the system from starting.

Procedure

To ensure the system can reliably identify the root file system disk partition, we recommend configuring GRUB to identify the partition by its UUID. Follow these steps.

Warning

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

Check the GRUB version

The GRUB program has two major versions: GRUB2 and GRUB Legacy. GRUB Legacy is no longer in active development, except for bug fixes. Follow these steps to check your GRUB version.

  1. Connect to a Linux instance using Workbench.

  2. Use one of the following methods to identify your GRUB version.

    GRUB2

    Run the following command to check the structure of your system's 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

    Run the following command to check the contents of the /boot/grub/ directory.

    sudo ls /boot/grub/

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

Locate the GRUB configuration file

The configuration files for GRUB2 and GRUB Legacy are in different locations.

  • GRUB2: The configuration file is typically located at /boot/grub/grub.cfg or /boot/grub2/grub.cfg.

  • GRUB Legacy: The configuration file is typically located at /boot/grub/menu.lst or /boot/grub/grub.conf.

You can refer to the preceding example to go to the /boot directory and check the GRUB configuration file.

Get the current disk information

You need to obtain the disk partition information of the current instance to use in the GRUB configuration file.

  1. Run the following command to view the disk partition information for the current instance:

    sudo blkid

    Example output:

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

    In this example, the UUID of the /dev/vda1 device is e7e8xxxx-xxxx-xxxx-xxxx-xxxxb9263645.

Modify the GRUB configuration file

Important

The following example assumes that the GRUB2 configuration file is /boot/grub2/grub.cfg. If you use GRUB Legacy or if your system has a customized GRUB configuration, you must adjust the commands in Step 1 and Step 2 to match your environment.

  1. Run the following command to 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 the following command:

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

  2. Run the following command to open the GRUB configuration file:

    sudo vim /boot/grub2/grub.cfg
  3. Press i to enter insert mode. In the configuration file, 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

    The 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. After you finish editing, press the Esc key to exit insert mode, and then type :wq to save the file and exit.

  5. (Optional) Run the following command to view the modified configuration file. This ensures that all disk partition identifiers in GRUB now use the UUID format.

    sudo cat /boot/grub2/grub.cfg

Reference

To learn how to configure the fstab file to automatically mount a data disk, see Automatically mount a data disk using a UUID in /etc/fstab.