View previous topic :: View next topic |
Author |
Message |
neyuru Apprentice

Joined: 21 Mar 2020 Posts: 177
|
Posted: Tue Apr 21, 2020 6:18 am Post subject: kernel panic when USB is connected at boot.[SOLVED] |
|
|
Code: | 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: | 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 |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 47014 Location: 56N 3W
|
Posted: Tue Apr 21, 2020 9:24 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
alamahant l33t

Joined: 23 Mar 2019 Posts: 651
|
Posted: Tue Apr 21, 2020 11:09 am Post subject: |
|
|
Also to avoid having your computer freeze during kernel panics,as a remedy you can add something like
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
is fantastic...It will find your root even if not explicitly declared in /etc/default/grub.
But it is better if you do. |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 47014 Location: 56N 3W
|
Posted: Tue Apr 21, 2020 11:29 am Post subject: |
|
|
alamahant,
Code: | 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. |
|
Back to top |
|
 |
alamahant l33t

Joined: 23 Mar 2019 Posts: 651
|
Posted: Tue Apr 21, 2020 11:35 am Post subject: |
|
|
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: |
Kernel panic - not syncing: VFS. Unable to mount rootfs on unknown-block
|
Maybe its a different case... |
|
Back to top |
|
 |
neyuru Apprentice

Joined: 21 Mar 2020 Posts: 177
|
Posted: Tue Apr 21, 2020 1:32 pm Post subject: |
|
|
NeddySeagoon wrote: | neyuru,
As /etc/fstab is on the root filesystem, it cannot be read until root is mounted. |
That makes 200% sense
So, do I need to reissue the command
Code: | grub-mkconfig -o /boot/grub/grub.cfg |
after the fstab was modified? |
|
Back to top |
|
 |
neyuru Apprentice

Joined: 21 Mar 2020 Posts: 177
|
Posted: Tue Apr 21, 2020 1:37 pm Post subject: |
|
|
alamahant wrote: |
Also if you DO use an initrd then
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? |
|
Back to top |
|
 |
alamahant l33t

Joined: 23 Mar 2019 Posts: 651
|
Posted: Tue Apr 21, 2020 3:35 pm Post subject: |
|
|
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.
 |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 47014 Location: 56N 3W
|
Posted: Tue Apr 21, 2020 3:57 pm Post subject: |
|
|
neyuru,
Yes but ...
Code: | 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. |
|
Back to top |
|
 |
pietinger Guru

Joined: 17 Oct 2006 Posts: 508 Location: Bavaria
|
Posted: Tue Apr 21, 2020 6:13 pm Post subject: Re: kernel panic when USB is connected at boot. |
|
|
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: | 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: | # 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" |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 47014 Location: 56N 3W
|
Posted: Tue Apr 21, 2020 6:17 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
neyuru Apprentice

Joined: 21 Mar 2020 Posts: 177
|
Posted: Wed Apr 22, 2020 1:00 am Post subject: solution |
|
|
For all interested in the solution:
OPTION 1. This applies to GPT partitions in UEFI.
1) Find the PARTUUID of your root file system.
2) Add the following line to /etc/default/grub
Code: | GRUB_CMDLINE_LINUX="root=PARTUUID=xxx-yyy-zzz" |
where xxx-yyy-zzz is the PARTUUID you found on step 1).
3) Configure GRUB:
Code: | 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: | linux /vmlinuz-x-y-z root=/dev/sdXY ro |
where /dev/sdXY is your root filesystem partition.
3) Edit this line to:
Code: | 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: | 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. |
|
Back to top |
|
 |
neyuru Apprentice

Joined: 21 Mar 2020 Posts: 177
|
Posted: Wed Apr 22, 2020 1:04 am Post subject: Re: kernel panic when USB is connected at boot. |
|
|
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! |
|
Back to top |
|
 |
|