# How do I make GRUB2 use root=UUID=<UUID> ?

## piedar

I've got an odd situation: my Gentoo won't boot when the secondary hard drive is connected.  It fails with "Kernel panic - not syncing: No init found."  I believe this is due to the last line in the main entry of my grub.cfg:

```
menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-1fbc72ec-190b-4acc-88b4-5b8babffbfbc' {

        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  1fbc72ec-190b-4acc-88b4-5b8babffbfbc

        else

          search --no-floppy --fs-uuid --set=root 1fbc72ec-190b-4acc-88b4-5b8babffbfbc

        fi

        echo    'Loading Linux 3.5.7-gentoo ...'

        linux   /boot/vmlinuz-3.5.7-gentoo root=/dev/sda1 ro  amd_iommu=off

}
```

I'm guessing that the secondary drive is at /dev/sda at that point during boot, which is why the kernel can't find init.  How do I make GRUB2 use root=UUID=<UUID> instead?  I see there's an option in /etc/default/grub called GRUB_DISABLE_LINUX_UUID, but it's commented out, and even setting it explicitly to false doesn't help.

```
sys-boot/grub-2.00-r1 was built with the following:

USE="(multilib) nls sdl truetype -custom-cflags -debug -device-mapper -doc -efiemu -libzfs -mount -static" GRUB_PLATFORMS="pc -coreboot -efi-32 -efi-64 -emu -ieee1275 -multiboot -qemu -qemu-mips -yeeloong"

CFLAGS=""

LDFLAGS=""
```

----------

## VoidMage

IIRC, booting by UUID requires a proper initramfs.

Booting by PARTUUID doesn't, but - per definition - only works for GPT partitioned disks.

----------

## piedar

Thanks for the info.  I came across this helpful thread (see especially post #6 by NeddySeagoon) not long after posting.  I've managed to avoid the need for an initrd to this point, so I tried and succeeded with a workaround hack:

/etc/default/grub

```
GRUB_CMDLINE_LINUX="root=/dev/sdb1 ro"
```

This confirmed my suspicion that the drives are ordered differently in GRUB than they are once the system is booted.  I remember making sure the primary drive was listed first in the motherboard config; could the choice of SATA ports on the motherboard have an effect on drive ordering?

----------

