How to generate a grub.cfg that uses UUID's not LABELs?

Hi
This party my boot partiton “/sda4/grub2/grub.cfg”




### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE Leap 42.1'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-4dcdceb4-2121-4437-a201-52ce1cf93ade' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt 
    insmod ext2
    set root='hd0,gpt4'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  e285fbbd-72f9-4783-a7b7-53f9e7d03b14
    else
      search --no-floppy --fs-uuid --set=root e285fbbd-72f9-4783-a7b7-53f9e7d03b14
    fi
    echo    'Loading Linux 4.1.25-2.gc2b80b3-default ...'
    linuxefi /vmlinuz-4.1.25-2.gc2b80b3-default root=UUID=4dcdceb4-2121-4437-a201-52ce1cf93ade ro  resume=/dev/system/swap splash=silent quiet showopts
    echo    'Loading initial ramdisk ...'
    initrdefi /initrd-4.1.25-2.gc2b80b3-default
}
submenu 'Advanced options for openSUSE Leap 42.1' --hotkey=1 $menuentry_id_option 'gnulinux-advanced-4dcdceb4-2121-4437-a201-52ce1cf93ade' {
    menuentry 'openSUSE Leap 42.1, with Linux 4.1.25-2.gc2b80b3-default' --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.25-2.gc2b80b3-default-advanced-4dcdceb4-2121-4437-a201-52ce1cf93ade' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt 
        insmod ext2
        set root='hd0,gpt4'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  e285fbbd-72f9-4783-a7b7-53f9e7d03b14
        else
          search --no-floppy --fs-uuid --set=root e285fbbd-72f9-4783-a7b7-53f9e7d03b14
        fi
        echo    'Loading Linux 4.1.25-2.gc2b80b3-default ...'
        linuxefi /vmlinuz-4.1.25-2.gc2b80b3-default root=UUID=4dcdceb4-2121-4437-a201-52ce1cf93ade ro  resume=/dev/system/swap splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrdefi /initrd-4.1.25-2.gc2b80b3-default
    }
}


### END /etc/grub.d/10_linux ###


Can I use ‘hd0,gpt4’ instead of ‘UUID’
set root=‘hd0,gpt4’
to
set root=UUID
How can do that?

I’m not sure that I understand the question.

The “grub.cfg” that you are showing does use UUIDs rather than labels.
Here’s an excerpt:


set root='hd0,gpt4'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  e285fbbd-72f9-4783-a7b7-53f9e7d03b14
    else
      search --no-floppy --fs-uuid --set=root e285fbbd-72f9-4783-a7b7-53f9e7d03b14
    fi

The first line is just setting a default value. The next few lines are searching for UUID=e285fbbd-72f9-4783-a7b7-53f9e7d03b14. If the search is successful, then root is set to the partition with that UUID. The default value of ‘hd0,gpt4’ will only be used if the search for UUID fails.

Thanks
I thought that grub does not use uuid for mount /boot partition
I understand now. uses uuid and label