# [SOLVED] Kernel panics during boot when USB is attached

## NP_complete

My goal is to keep my portable USB drive plugged in semi-permanently.  I don't want to have to plug and unplug it on each boot.  But that's what I'm facing, or the kernel becomes hysterical:

 *Quote:*   

> end kernel panic - not syncing: VFS: Unable to mount rootfs on unknown block(0,4)

 

Tried changing the boot order in the BIOS - nothing.  Tried installing and activating autofs - nothing.  Without the USB attached - normal boot.

Someone please advise.  Many thanks.Last edited by NP_complete on Wed Mar 02, 2016 10:38 am; edited 1 time in total

----------

## totony

 *NP_complete wrote:*   

> end kernel panic - not syncing: VFS: Unable to mount rootfs on unknown block(0,4)

 

This is usually caused by the kernel choosing the wrong rootfs on boot, try appending root=<your partition> to your kernel options.

----------

## toralf

 *NP_complete wrote:*   

> or the kernel becomes hysterical

 Just in a case where you had specified in your BIOS to look first for an OS at USB (before internal disks) than you shouldn't blame the kernel  :Wink: 

----------

## szatox

Point kernel to the root filesystem with it's UUID or LABEL instead of (hd....)

Those things leave less room for mistakes.

----------

## NeddySeagoon

szatox,

LABEL= or UUID=  are filesystem features.  An initrd is required to use those features to mount root.

PARTUUID= works without an initrd.  

NP_complete,

If things are moving around, you will need to write fstab in terms of filesystem UUIDs.  That works because mount is available once root is mounted. 

```
# now ssd

UUID=cf559dbe-81bb-45b7-bbdd-0bcdc81e066b               /               ext4            noatime,discard         0 1
```

Be aware that a partition has a PARTUUID and the filesystem on it has a (different) UUID. Don't confuse them.

Your Gentoo won't mind, it just won't boot or mount things.  

```
/sbin/blkid
```

will tell you what you need to know.

----------

## s4e8

another method is add "usb_storage.delay_use=10" to kernel parameter, delay 10 seconds to initialize usb mass-storage devices, through UASP devices has not delay params.

----------

## NP_complete

Thank y'all for help!

NeddySeagoon,

You didn't say this explicitly, but it sounds like I need initramfs (which supercedes initrd) to be able to mount USB drives on boot.  Am I correct?

I've re-done fstab in terms of UUIDs and updated grub.cfg via grub2-mkconfig, but nothing changed.  The kernel looks to /dev/sda4, instead of UUID=<something>, for a root partition.

I just noticed that the kernel prints this before failing:

 *Quote:*   

> Please append a correct "root=" boot option; here are the available options:

 

----------

## NeddySeagoon

NP_complete,

I use the the terms initrd and initramfs interchangably.

No, that's not right, initramfs is more typing, so I probably don't use it at all.

The difference is really one of internal structure. Traditionally, an initrd was a compressed ext2 filesystem in a file and a initramfs is a compressed cpio archive of cpio archives.  Both work.

You don't need initrd/initramfs to boot from USB or to mount USB partitions at boot.

You do need usb storage support built into your kernel.

You need rootdelay= or rootwait on your kernel command line.  This overcomes the problem of root being mounted before the USB subsystem is started, which is the normal course of events. Its a verybadthing for root on USB.

See  /usr/src/linux/Documentation/kernel-parameters.txt  to learn what rootdelay= and rootwait do.

You do need an initrd/initramfs to use root=UUID= or root=LABLE= as they both depend on the user space mount command.

root=PARTUUID= and root=/dev/sd.. are both handled by the kernel.

Maybe grub is being too clever for its own good and translating whatever you pass the setup to /dev/sd...

----------

## NP_complete

I won!  And the takeaway is:

1. Do the fstab in terms of UUIDs.

2. In /etc/default/grub, make GRUB_CMDLINE_LINUX contain root=PARTUUID=<the root partition's PARTUUID>.

3. Right or wrong, I never ended up needing rootdelay/rootwait.

My GRUB still inexplicably prepends root=/dev/sda-<something> to the command line at boot, so now I have two "root=" entries in there.  Perhaps there is a way to get rid of the first "root=", but it's probably not essential.

Thanks much, NeddySeagoon!

----------

