# grub-mkconfig does not use UUID

## davidshen84

I made sure I have this line in my /etc/default/grub:

 *Quote:*   

> # GRUB_DISABLE_LINUX_UUID=true

 

But grub-mkconfig still generate boot entries like:

 *Quote:*   

> linux   /boot/vmlinuz-4.8.7-gentoo root=/dev/sdc2 

 

Any idea why?

I have my Gentoo installed on a removable drive, if it uses the drive letter, I have to make sure the drive is detected in the correct order. Very annoying...Please help

----------

## Fitzcarraldo

 *davidshen84 wrote:*   

> I made sure I have this line in my /etc/default/grub:
> 
> ```
> # GRUB_DISABLE_LINUX_UUID=true
> ```
> ...

 

If you really have got the hash character in that line, that would explain why. You need to uncomment that line in /etc/default/grub.

EDIT: Whoops, my bad.

----------

## charles17

 *davidshen84 wrote:*   

> But grub-mkconfig still generate boot entries like:
> 
>  *Quote:*   linux   /boot/vmlinuz-4.8.7-gentoo root=/dev/sdc2  

 

But that isn't the whole menuentry, is it?

Something like this?

```

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-<here my uuid of /dev/sda6 >' {

        load_video

        insmod gzio

        insmod part_msdos

        insmod ext2

        set root='hd0,msdos1'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  <here uuid of my /dev/sda1>

        else

          search --no-floppy --fs-uuid --set=root <here uuid of my /dev/sda1>

        fi

        echo    'Loading Linux 4.4.26-gentoo ...'

        linux   /vmlinuz-4.4.26-gentoo root=/dev/sda6 ro  

}
```

----------

## davidshen84

Yes, the full menuentry is more like the one you given. And the UUID after "--set=root" is actually correct. But I think the kernel only care what you passed in, by using the root=... part. And on my system, it is always the device pass.

----------

## TiccTech

I also ran into this problem today -- I took two older drives out of a file server, and it failed during boot due to /boot/grub/grub.cfg setting root=/dev/sde3 instead of using a UUID. The same UUID was now on /dev/sdc3.

A little digging into /etc/grub.d/10_linux (which appears to be used by grub-mkconfig) led me to this:

```
  elif test -z "${initramfs}" ; then

    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's

    # no initrd or builtin initramfs, it can't work here.

```

Which I interpret to mean that if you boot your kernel directly from the disk, not from initrd, then you can't use UUIDs.

And sure enough, the two of my Gentoo machines that don't have initrds put root=/dev/sd* on the kernel command line, whereas the other two, which have RAID1 root partitions, and therefore boot with initrd, use root=UUID=*.

So perhaps you should configure your system to use an initrd?

I'm not going to bother -- my device names only change every few years.

----------

## Fitzcarraldo

Looks like you're correct:

 *Gentoo Wiki - 'GRUB2/Config Variables' wrote:*   

> 
> 
> Variable...............................Default..Description
> 
> GRUB_DISABLE_LINUX_UUID..false.......If true, ${GRUB_DEVICE} is passed in the root parameter on the kernel command line.
> ...

 

----------

## =DvD=

Same problem here.

Without initramfs we should be able to pass the PARTUUID to the kernel tho

Solved modifing the output of grub-mkconfig with sed  :Neutral: 

```
grub-mkconfig | sed 's/root=\/dev\/sda9/root=PARTUUID=3278f49b-fb89-4b39-9c0d-09c012946e20/g' > /boot/grub/grub.cfg
```

----------

## Josef.95

>=sys-boot/grub-2.04 has now PARTUUID support :)

```
# grep UUID /etc/default/grub 

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel

GRUB_DISABLE_LINUX_UUID=true

GRUB_DISABLE_LINUX_PARTUUID=false
```

 works for me with grub-mkconfig -o /boot/grub/grub.cfg

----------

## 389292

Grub supports PARTUUID now, unfortunately switch_root (part of busybox) does not, and it complicates encrypted installs without LUKS headers on the drive..

----------

## Andry77

 *Josef.95 wrote:*   

> >=sys-boot/grub-2.04 has now PARTUUID support 
> 
> ```
> # grep UUID /etc/default/grub 
> 
> ...

 

I had the same problem. Josef.95 thanks for the hint.

----------

