# Kernel panic on boot, but only when usb drive connected

## Chris.B.

Hello,

I'm having a problem booting my system. Problem only shows when I connect usb drive to the computer. For some reason the drive names change, grub doesn't seem to grasp it and fails to boot. The details can be seen here:

http://www.tiikoni.com/tis/view/?id=290fcb6

Gentoo is on the Sandisk drive, here sdd - but normally sdc (sdc1 is BIOS boot partition, sdc2 is root filesystem).

Here sda is the usb drive that complicates the boot process for some reason.

In /etc/fstab I use the UUID instead of device path, in GRUB configuration this UUID is also mentioned. Do you have any idea what can be the problem here?

Here follows grub.cfg:

```

#

# DO NOT EDIT THIS FILE

#

# It is automatically generated by grub2-mkconfig using templates

# from /etc/grub.d and settings from /etc/default/grub

#

### BEGIN /etc/grub.d/00_header ###

if [ -s $prefix/grubenv ]; then

  load_env

fi

if [ "${next_entry}" ] ; then

   set default="${next_entry}"

   set next_entry=

   save_env next_entry

   set boot_once=true

else

   set default="0"

fi

if [ x"${feature_menuentry_id}" = xy ]; then

  menuentry_id_option="--id"

else

  menuentry_id_option=""

fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then

  set saved_entry="${prev_saved_entry}"

  save_env saved_entry

  set prev_saved_entry=

  save_env prev_saved_entry

  set boot_once=true

fi

function savedefault {

  if [ -z "${boot_once}" ]; then

    saved_entry="${chosen}"

    save_env saved_entry

  fi

}

function load_video {

  if [ x$feature_all_video_module = xy ]; then

    insmod all_video

  else

    insmod efi_gop

    insmod efi_uga

    insmod ieee1275_fb

    insmod vbe

    insmod vga

    insmod video_bochs

    insmod video_cirrus

  fi

}

if [ x$feature_default_font_path = xy ] ; then

   font=unicode

else

insmod part_gpt

insmod ext2

set root='hd2,gpt2'

if [ x$feature_platform_search_hint = xy ]; then

  search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

else

  search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

fi

    font="/usr/share/grub/unicode.pf2"

fi

if loadfont $font ; then

  set gfxmode=1920x1200

  load_video

  insmod gfxterm

  set locale_dir=$prefix/locale

  set lang=pl_PL

  insmod gettext

fi

terminal_output gfxterm

if [ x$feature_timeout_style = xy ] ; then

  set timeout_style=menu

  set timeout=3

# Fallback normal timeout code in case the timeout_style feature is

# unavailable.

else

  set timeout=3

fi

### END /etc/grub.d/00_header ###

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

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

   load_video

   set gfxpayload=keep

   insmod gzio

   insmod part_gpt

   insmod ext2

   set root='hd2,gpt2'

   if [ x$feature_platform_search_hint = xy ]; then

     search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

   else

     search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

   fi

   echo   'Wczytywanie systemu Linux 4.1.15-gentoo-r1...'

   linux   /boot/vmlinuz-4.1.15-gentoo-r1 root=/dev/sdc2 ro  

}

submenu 'Opcje zaawansowane dla systemu Gentoo GNU/Linux' $menuentry_id_option 'gnulinux-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.15-gentoo-r1' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.15-gentoo-r1-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.15-gentoo-r1...'

      linux   /boot/vmlinuz-4.1.15-gentoo-r1 root=/dev/sdc2 ro  

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.15-gentoo-r1 (tryb ratunkowy)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.15-gentoo-r1-recovery-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.15-gentoo-r1...'

      linux   /boot/vmlinuz-4.1.15-gentoo-r1 root=/dev/sdc2 ro single 

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.12-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.12-gentoo-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.12-gentoo...'

      linux   /boot/vmlinuz-4.1.12-gentoo root=/dev/sdc2 ro  

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.12-gentoo (tryb ratunkowy)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.12-gentoo-recovery-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.12-gentoo...'

      linux   /boot/vmlinuz-4.1.12-gentoo root=/dev/sdc2 ro single 

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.12-gentoo.old' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.12-gentoo.old-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.12-gentoo.old...'

      linux   /boot/vmlinuz-4.1.12-gentoo.old root=/dev/sdc2 ro  

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.1.12-gentoo.old (tryb ratunkowy)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.1.12-gentoo.old-recovery-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.1.12-gentoo.old...'

      linux   /boot/vmlinuz-4.1.12-gentoo.old root=/dev/sdc2 ro single 

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.0.5-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.0.5-gentoo-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.0.5-gentoo...'

      linux   /boot/vmlinuz-4.0.5-gentoo root=/dev/sdc2 ro  

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.0.5-gentoo (tryb ratunkowy)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.0.5-gentoo-recovery-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.0.5-gentoo...'

      linux   /boot/vmlinuz-4.0.5-gentoo root=/dev/sdc2 ro single 

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.0.5-gentoo.old' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.0.5-gentoo.old-advanced-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.0.5-gentoo.old...'

      linux   /boot/vmlinuz-4.0.5-gentoo.old root=/dev/sdc2 ro  

   }

   menuentry 'Gentoo GNU/Linux, za pomocą systemu Linux 4.0.5-gentoo.old (tryb ratunkowy)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.0.5-gentoo.old-recovery-70c2a86b-b605-4c06-ac6c-f7710ba0bce5' {

      load_video

      set gfxpayload=keep

      insmod gzio

      insmod part_gpt

      insmod ext2

      set root='hd2,gpt2'

      if [ x$feature_platform_search_hint = xy ]; then

        search --no-floppy --fs-uuid --set=root --hint-bios=hd2,gpt2 --hint-efi=hd2,gpt2 --hint-baremetal=ahci2,gpt2  70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      else

        search --no-floppy --fs-uuid --set=root 70c2a86b-b605-4c06-ac6c-f7710ba0bce5

      fi

      echo   'Wczytywanie systemu Linux 4.0.5-gentoo.old...'

      linux   /boot/vmlinuz-4.0.5-gentoo.old root=/dev/sdc2 ro single 

   }

}

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

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###

### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###

# This file provides an easy way to add custom menu entries.  Simply type the

# menu entries you want to add after this comment.  Be careful not to change

# the 'exec tail' line above.

menuentry 'Microsoft Windows 7 Ultimate (na /dev/sdd1)' --class windows --class os $menuentry_id_option 'osprober-chain-3E8AA1FA689C0077' {

    insmod part_msdos

    insmod ntfs

    set root='hd3,msdos1'

#    if [ x$feature_platform_search_hint = xy ]; then

#   search --no-floppy --fs-uuid --set=root --hint-bios=hd3,msdos1 --hint-efi=hd3,msdos1 --hint-baremetal=ahci3,msdos1  3E8AA1FA689C0077

#    else

#   search --no-floppy --fs-uuid --set=root 3E8AA1FA689C0077

#    fi

#    parttool ${root} hidden-

#    drivemap -s (hd0) ${root}

    chainloader +1

}

### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###

if [ -f  ${config_directory}/custom.cfg ]; then

  source ${config_directory}/custom.cfg

elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then

  source $prefix/custom.cfg;

fi

### END /etc/grub.d/41_custom ###

```

----------

## NeddySeagoon

Chris.B.,

grub is being too clever for its own good.  The root= passed to the kernel is always /dev/sdc2 

```
 linux   /boot/vmlinuz-4.1.15-gentoo-r1 root=/dev/sdc2 ro
```

You may not use UUID here as you don't have an initrd but you can use PARTUUID, since the kernel understands that.

There is a configure file you can adjust somewere so grub will use root=PARTUUID=.... but I don't have grub2 so I don't know where.

I hate autoblackmagic having a hand in the boot process too because when it breaks, you may not have any internet access, so you need to understand what's happening well enough to fix it.

My way forward would be to add a manual boot stanza in the space provided at the bottom of grub.cfg.

As the kernel is getting confused about drive ordering, mayme the BIOS is too?

----------

## charles17

 *NeddySeagoon wrote:*   

> You may not use UUID here as you don't have an initrd but you can use PARTUUID, since the kernel understands that.
> 
> There is a configure file you can adjust somewere so grub will use root=PARTUUID=.... but I don't have grub2 so I don't know where.

 

Did you mean this one? */etc/default/grub wrote:*   

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

 

----------

## NeddySeagoon

charles17,

Probably.

----------

## Chris.B.

Thanks @NeddySeagoon, I've put 

```
root=PARTUUID=
```

 in the grub.cfg configuration file and now my system boots correctly.

Is there a way to make my system always apply the same paths (/dev/sd*) to the same drives? I suppose this is the BIOS/UEFI issue, but it drives me nuts. In the past everything worked as expected, now.. new hardware, new software, new problems  :Sad: 

----------

