[blfs-support] kernel panic when booting with connected external disk

Michael Shell list1 at michaelshell.org
Wed Mar 13 19:34:59 PDT 2013


On Wed, 13 Mar 2013 12:36:30 +0100
"Dr.-Ing. Edgar Alwers" <edgaralwers at gmx.de> wrote:

> When an external disk is connected from the very beginning (USB), 
> the boot process of the LFS system stops with a kernel panic:


I think what is happening is that when the USB drive is connected
the kernel name/number of the device for the / root filesystem is being
changed such that the kernel no longer sees it under the name/number it
expects and therefore cannot mount the root filesystem which then
results in a panic.

There is a fundamental problem with device naming in that:

 1. numbering devices sequentially is simple, but results in device
    numbers/names being order dependent which causes name changes to
    occur as devices are added/removed from the system.

 2. creating a unique ID for each device avoids problems with
    ordering, but involves a lot of complexity especially if
    the various tools, kernels and boot loaders do not yet support
    them. Furthermore, there are times when it might be desirable
    to boot based on device order - if a drive should fail or be
    removed then whatever "took its place" ideally should
    automatically become the new default boot device - as was
    the case in the "C:, IDE primary master" days.


The question then becomes: What is changing the device name/number
of / and why is Ubuntu not effected by it? If it is the BIOS,
Ubuntu must be configured in some way that is not bothered by the
number change. It also may be that the LFS kernel is changing the
device name/number of / in way that is different from the kernel of
Ubuntu. Note that all of this takes place before udev can even load.
So, changes to udev's configuration won't be of any help.

In your error message:

"VFS Mount root on devices 8:5"

what does the corresponding *successful* message say when
LFS is booted without the USB drive which can be seen from

dmesg

e.g., "VFS: Mounted root (ext2 filesystem) readonly on device 8:1."

and how do the respective "x:y" numbers correspond to the major
minor numbers in the /dev/sd* devices?:

ls -l /dev/sd*

You should be able to get the LFS system to boot with the
USB drive connected if you pass the "correct"

root=/dev/sdx

parameter to LFS at the boot prompt.
https://wiki.archlinux.org/index.php/Kernel_parameters

But, this is not a permanent solution if you expect to boot with
the USB drive attached a lot.

There is a way to avoid this device numbering problem by referencing
a unique code for each device. One is the UUID, but the kernel requires
an initial ram disk (initrd) to be able to use UUID. 

If Ubuntu were using a initrd in conjunction with a UUID boot
device specification, then that would explain why Ubuntu is not confused
by the presence of the USB drive, while LFS is.

A second (and different!) unique ID is the so-called partition
UUID (PARTUUID) which can be passed to the kernel directly and
does not require an initrd but using PARTUUID requires the
partition to be setup by special tools such as gdisk:

http://www.linux-archive.org/gentoo-user/481167-mounting-root-partition-uuid-no-initrd-needed.html

Be careful and make backups before using any such tools on
your partitions!

Furthermore, look at the lack luster response of grub developers
to add support for PARTUUID booting:

http://lists.gnu.org/archive/html/bug-grub/2012-03/msg00056.html

Even blkid does not provide PARTUUID info ... well, as of 2011:

http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/4256

Here's another discussion of interest here:

http://www.linuxquestions.org/questions/linux-kernel-70/enable-uuid-support-in-kernel-%5Bwithout-initrd%5D-903023/

My favorite line is by syg00: "Search PARTUUID - you may not like the
answer."

Here's an article showing how to use PARTUUID:

http://archives.gentoo.org/gentoo-user/msg_35eb3187ef8be8a23cdec253b66b5a59.xml

Looks quite "doable" under LFS to me.

Anyway, tell us what device names are being assigned to your drives on
the LFS system with and without the USB drive being connected
(you'll have to get this info from the screen boot messages before
the panic in the case of the former).

Also, show us your boot (grub/lilo) configuration for the LFS and
Ubuntu installations.

Possible solutions that come to mind include:

 1. Changing the BIOS configuration to alter the numbering of
    an external USB drive so as not to disturb the SATA drive
    numbers. This is perhaps the easiest approach - if it can be
    done.
 2. Some kind of change to the kernel configuration or setup
    that keeps USB devices from using /dev/sdx numbering.
    Remember, this would have to be before udev comes up, 
    so it's a kernel configuration/setup/coding issue. I don't
    know if or how something like that could be done.
 3. Using a UUID boot device specifier with LFS, but this
    will require the use of initrd.
 4. Using the PARTUUID specifier with LFS, but this will require
    special partition tools and may not yet be supported by
    grub (although the gentoo article above suggests you can
    get it to work just fine even on an older pre-EFI machine).
    You will not need an initial ram disk for this approach.


I should warn you that I am not the most knowledgeable person on this
topic, but I thought I would post what I do know and hope that your
answers to my questions can lead to an answer from someone that can
provide a better solution.


  Cheers,

  Mike Shell






More information about the blfs-support mailing list