Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Kernel panics during boot when USB is attached
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
NP_complete
Tux's lil' helper
Tux's lil' helper


Joined: 21 Mar 2009
Posts: 137

PostPosted: Mon Feb 29, 2016 5:15 am    Post subject: [SOLVED] Kernel panics during boot when USB is attached Reply with quote

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
Back to top
View user's profile Send private message
totony
n00b
n00b


Joined: 03 Dec 2014
Posts: 40

PostPosted: Mon Feb 29, 2016 6:37 am    Post subject: Re: Kernel panics on boot when USB is attached Reply with quote

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.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3942
Location: Hamburg

PostPosted: Mon Feb 29, 2016 9:35 am    Post subject: Re: Kernel panics on boot when USB is attached Reply with quote

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 ;)
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3493

PostPosted: Mon Feb 29, 2016 5:03 pm    Post subject: Reply with quote

Point kernel to the root filesystem with it's UUID or LABEL instead of (hd....)
Those things leave less room for mistakes.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54808
Location: 56N 3W

PostPosted: Mon Feb 29, 2016 5:39 pm    Post subject: Reply with quote

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.

Code:
# 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.

Code:
/sbin/blkid
will tell you what you need to know.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
s4e8
Guru
Guru


Joined: 29 Jul 2006
Posts: 311

PostPosted: Tue Mar 01, 2016 2:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
NP_complete
Tux's lil' helper
Tux's lil' helper


Joined: 21 Mar 2009
Posts: 137

PostPosted: Tue Mar 01, 2016 8:16 am    Post subject: Reply with quote

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:
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54808
Location: 56N 3W

PostPosted: Tue Mar 01, 2016 6:12 pm    Post subject: Reply with quote

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...
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
NP_complete
Tux's lil' helper
Tux's lil' helper


Joined: 21 Mar 2009
Posts: 137

PostPosted: Wed Mar 02, 2016 10:36 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum