Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

kernel panic when USB is connected at boot.[SOLVED]

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
13 posts • Page 1 of 1
Author
Message
neyuru
Apprentice
Apprentice
Posts: 191
Joined: Sat Mar 21, 2020 6:51 am

kernel panic when USB is connected at boot.[SOLVED]

  • Quote

Post by neyuru » Tue Apr 21, 2020 6:18 am

Code: Select all

Kernel panic - not syncing: VFS. Unable to find rootfs
The problem is clear, the kernel doesn't find my root fs (if I plug a USB before booting. Else, it works just fine).

I'm using GPT partitioning. Instead of the ordinary /dev/sdx naming scheme, I've tried changing the fstab file so that it uses PARTUUID:

Code: Select all

PARTUUID="xxyyzz"		/hdd		ntfs		defaults		0 0
PARTUUID="yyxxzz"		/boot		vfat		defaults,noatime	0 2
PARTUUID="xxzzyy"		none		swap		sw,discard=once		0 0
PARTUUID="yyzzxx"		/		ext4		noatime		0 1
/dev/sr0		/mnt/cdrom	auto		noauto,ro	0 0
(those are just placeholders for the real long partition ID's). The idea behind using PARTUUID's is that, in theory, no two partitions have the same ID. I was guessing that by giving the exact name (PARTUUID) to the fstab file, grub would succesfully find and route the partitions. Notice I don't have allocation in fstab for USB's (I would prefer automatic detection by udev, if posible.)

I am currently using systemd but this also happened in an OpenRC installation. The one thing that is different in my system that might be related to this problem is that the first disk (aka /dev/sda) is not where the system is installed. This disk is for data and is mounted in /hdd as shown in the fstab example. The system is installed in the second disk (aka /dev/sdb), which has 3 partitions and are mounted in /boot,/ and "none" (for the swap).

This might be a very easy problem to solve but I have not found the solution, can anyone help?
Last edited by neyuru on Wed Apr 22, 2020 1:00 am, edited 1 time in total.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Apr 21, 2020 9:24 am

neyuru,

As /etc/fstab is on the root filesystem, it cannot be read until root is mounted.
For root, its only used by rootfsck to know whatthe root filesystem in.

Your grub.cfc needs to use root=PARTUUID= to locate root too. Thats how the kernel knows where root is when its not mounted.
If you have an initrd, you may use UUID. UUID needs the userspace mount command. The kernel understands PARTUUID.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
alamahant
Advocate
Advocate
Posts: 4034
Joined: Sat Mar 23, 2019 12:12 pm

  • Quote

Post by alamahant » Tue Apr 21, 2020 11:09 am

Also to avoid having your computer freeze during kernel panics,as a remedy you can add something like

Code: Select all

panic=20
In kernel command line in /etc/default/grub.
This will automatically cause a reboot if panic occurs.
Do not forget to update grub after modifying this file.
Also if you DO use an initrd then

Code: Select all

sys-kernel/dracut
is fantastic...It will find your root even if not explicitly declared in /etc/default/grub.
But it is better if you do.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Apr 21, 2020 11:29 am

alamahant,

Code: Select all

Kernel panic - not syncing: VFS. Unable to find rootfs	
but its panicing at boot.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
alamahant
Advocate
Advocate
Posts: 4034
Joined: Sat Mar 23, 2019 12:12 pm

  • Quote

Post by alamahant » Tue Apr 21, 2020 11:35 am

Neddy
I just rechecked.
Even during boot the line
panic=<seconds>
will cause a reboot automatically without having to resort to pressing the power button.
But in my case the msg is

Code: Select all

Kernel panic - not syncing: VFS. Unable to mount rootfs on unknown-block
Maybe its a different case...
Top
neyuru
Apprentice
Apprentice
Posts: 191
Joined: Sat Mar 21, 2020 6:51 am

  • Quote

Post by neyuru » Tue Apr 21, 2020 1:32 pm

NeddySeagoon wrote:neyuru,

As /etc/fstab is on the root filesystem, it cannot be read until root is mounted.
That makes 200% sense :lol:
So, do I need to reissue the command

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg
after the fstab was modified?
Top
neyuru
Apprentice
Apprentice
Posts: 191
Joined: Sat Mar 21, 2020 6:51 am

  • Quote

Post by neyuru » Tue Apr 21, 2020 1:37 pm

alamahant wrote: Also if you DO use an initrd then

Code: Select all

sys-kernel/dracut
is fantastic...It will find your root even if not explicitly declared in /etc/default/grub.
But it is better if you do.
I might be wrong but I don't think I use initrd. I don't recall using it or configuring it :?

What are the benefits of this software?
Top
alamahant
Advocate
Advocate
Posts: 4034
Joined: Sat Mar 23, 2019 12:12 pm

  • Quote

Post by alamahant » Tue Apr 21, 2020 3:35 pm

It is very useful if your sytem uses lvm or encrypted root partitions or raid setups
But beyond that it is cool that it will load all the necessary modules etc, necessary for booting, into a file system in memory before actually mounting the "real"file system.
I ve had very good experiences with dracut..
It mostly works out of the box.
But it may make your booting process slightly slower.
Plz have a look in this
https://wiki.gentoo.org/wiki/Initramfs
and also this
https://wiki.gentoo.org/wiki/Initramfs/Guide
After thus creating an initrd then please remeber to update grub also.
:D
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Apr 21, 2020 3:57 pm

neyuru,

Yes but ...

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg
does not read l/etc/fstab.
You have to fiddle with some gub settings somewhere in /etc.

I don't use grub2 so that's the limit of my knowledge.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
pietinger
Administrator
Administrator
Posts: 6631
Joined: Tue Oct 17, 2006 5:11 pm
Location: Bavaria

Re: kernel panic when USB is connected at boot.

  • Quote

Post by pietinger » Tue Apr 21, 2020 6:13 pm

neyuru wrote:This might be a very easy problem to solve but I have not found the solution, can anyone help?
Hello neyuru,

I think your problem is: Inserting an usb-stick at boottime changes /dev/sda to /dev/sdb (and so on: dev/sdb/ becomes /dev/sdc).

Your BIOS or UEFI always finds grub, and grub always finds the kernel. Grub has to give the kernel - via kernel command line - the adress of its root partition. And I think your grub gives the kernel not a partition UUID, it gives "root=/dev/sdaX" (or "=dev/sdbX). Check your /boot/grub/grub.cfg if you find something like this:

Code: Select all

        echo    'Loading Linux 5.6.4-gentoo ...'
        linux   /vmlinuz-5.6.4-gentoo root=/dev/sda3 ro
If this is true, you have two ways of avoiding this:

1.) You can configure a fixed command line in the kernel ("built-in kernel command line"). Or
2.) You tell grub not to use /dev/sdYX. Therefore you must edit: "/etc/grub.d/10-linux" and comment out the 3rd line of this block:

Code: Select all

# Default to disabling partition uuid support to maintian compatibility with
# older kernels.
GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
After this, mount /boot and do a "grub-mkconfig ..."
Check your new "grub.cfg" in "/boot/grub/grub.cfg"
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56094
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Tue Apr 21, 2020 6:17 pm

pietinger,

That's exactly what is needed.
Thank you.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
neyuru
Apprentice
Apprentice
Posts: 191
Joined: Sat Mar 21, 2020 6:51 am

solution

  • Quote

Post by neyuru » Wed Apr 22, 2020 1:00 am

For all interested in the solution:

OPTION 1. This applies to GPT partitions in UEFI.
1) Find the PARTUUID of your root file system.

Code: Select all

blkid
2) Add the following line to /etc/default/grub

Code: Select all

GRUB_CMDLINE_LINUX="root=PARTUUID=xxx-yyy-zzz"
where xxx-yyy-zzz is the PARTUUID you found on step 1).
3) Configure GRUB:

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg
For MBR this might work but instead of using the PARTUUID, use the UUID label. This is not tested but to avoid possible boot errors you can do this manual configuration:

OPTION 2
1) Boot as normal your system. When the GRUB splash screen appears, hit 'e' for "edit" (do not press enter).
2) In the last line you should see something like this:

Code: Select all

linux /vmlinuz-x-y-z root=/dev/sdXY ro
where /dev/sdXY is your root filesystem partition.
3) Edit this line to:

Code: Select all

linux /vmlinuz-x-y-z root=/dev/sdXY ro root=PARTUUID=xxx-yyy-zzz
(or UUID if you have MBR)
4) Hit F10 or ctrl-x to boot with this options.
5) If this doesn't boot then, upon your next reboot, erase the line you added:

Code: Select all

root=PARTUUID=xxx-yyy-zzz
to get things back as they where.

This manual configuration (OPTION 2) is added automatically by following the steps in (OPTION 1) but is given as reference in case the configuration fails and for being able to revert the settings as they were.
Top
neyuru
Apprentice
Apprentice
Posts: 191
Joined: Sat Mar 21, 2020 6:51 am

Re: kernel panic when USB is connected at boot.

  • Quote

Post by neyuru » Wed Apr 22, 2020 1:04 am

Hello pietinger!

Thanks for the response. I was editing my own solution to the forums before I viewed your suggestion! I haven't tried it but it appears to be another valid solution.

If anyone cares to check my own for errors, i would appreciate it.

Thanks!
Top
Post Reply

13 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic