Welcome! Log In Create A New Profile

Advanced

Kernel panic when adding 2nd USB storage

Posted by Christian Pontesegger 
Christian Pontesegger
Kernel panic when adding 2nd USB storage
April 14, 2011 05:13PM
Hi,

I am a bit desperate as I cannot make my dockstar boot with a second USB storage attached at boot time. I've seen numerous threads on this, still I did not find a solution that works for me.
I have my USB stick (where / and /boot are located) right next to the ethernet port. A second HD for data is attached next to it.

I've got the latest uBoot from Jeff installed. UBoot is found correctly

Loading file "/boot/uImage" from usb device 0:1 (usbda1)
1 bytes read
Found bootable drive on usb 0:1
Loading file "/boot/uImage" from usb device 0:1 (usbda1)

and kernel starts to boot. When the kernel detects my USB devices it always detects my HDD as sda while the stick remains sdb.

[   29.340502] scsi 1:0:0:0: Direct-Access     Seagate  FA GoFlex Desk   0155 PQ: 0 ANSI: 4
[   29.367443] sd 1:0:0:0: [sda] 3907029167 512-byte logical blocks: (2.00 TB/1.81 TiB)
[   29.376300] sd 1:0:0:0: [sda] Write Protect is off
[   29.381155] sd 1:0:0:0: [sda] Mode Sense: 1c 00 00 00
[   29.386235] sd 1:0:0:0: [sda] Assuming drive cache: write through
[   29.393924] sd 1:0:0:0: [sda] Assuming drive cache: write through
[   29.406849]  sda: sda1 sda2
[   29.411548] sd 1:0:0:0: [sda] Assuming drive cache: write through
[   29.417720] sd 1:0:0:0: [sda] Attached SCSI disk
[   29.422451] scsi 0:0:0:0: Direct-Access                                    PQ: 0 ANSI: 0 CCS
[   29.432317] sd 0:0:0:0: [sdb] 15360000 512-byte logical blocks: (7.86 GB/7.32 GiB)
[   29.441299] sd 0:0:0:0: [sdb] Write Protect is off
[   29.446130] sd 0:0:0:0: [sdb] Mode Sense: 43 00 00 00
[   29.451250] sd 0:0:0:0: [sdb] Assuming drive cache: write through
[   29.460050] sd 0:0:0:0: [sdb] Assuming drive cache: write through
[   29.467334]  sdb: sdb1 sdb2 sdb3
[   29.472799] sd 0:0:0:0: [sdb] Assuming drive cache: write through
[   29.478934] sd 0:0:0:0: [sdb] Attached SCSI removable disk
[   29.639782] usb 1-1.4: Cannot set autoneg
[   29.644622] MOSCHIP usb-ethernet driver 1-1.4:1.0: eth1: register 'MOSCHIP usb-ethernet driver' at usb-orion-ehci.0-1.4, MOSCHIP 7830/7730 usb-NET adapter, 00:13:11:00:06:f2
[   33.408994] List of all partitions:
[   33.412547] 1f00            1024 mtdblock0 (driver?)
[   33.417561] 1f01            4096 mtdblock1 (driver?)
[   33.422604] 1f02           32768 mtdblock2 (driver?)
[   33.427606] 1f03          224256 mtdblock3 (driver?)
[   33.432632] 0800      1953514583 sda driver: sd
[   33.437207]   0801      1952465886 sda1
[   33.441098]   0802         1048635 sda2
[   33.444967] 0810         7680000 sdb driver: sd
[   33.449527]   0811           16033 sdb1
[   33.453411]   0812         6610747 sdb2
[   33.457279]   0813         1052257 sdb3
[   33.461159] No filesystem could mount root, tried:  ext4
[   33.466535] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,2)

It should mount sdb2 as root here, but - I guess - tries sda2 (which is a swap partition).

Without the HDD attached at boot time it works just fine. Any idea how I could fix this behavior? I would prefer to tell the kernel to name the devices accordingly so I could boot with or without HDD attached.

any ideas?
--
thanks
Christian
Christian Pontesegger
Re: Kernel panic when adding 2nd USB storage
April 14, 2011 06:05PM
I've found something.
As I am using gentoo instead of debian I have my own kernel made where boot params were hardcoded to root=/dev/sda2
I can change this to /dev/sdb2 to make it work (which it does).

Still I am looking for a more clever solution as this would not let me boot without my HDD attached.
Re: Kernel panic when adding 2nd USB storage
April 14, 2011 09:08PM
See this thread about automount. Especially a few last posts, should solve your problem.
Christian Pontesegger
Re: Kernel panic when adding 2nd USB storage
April 15, 2011 01:48AM
Thanks for the link. It's all about udev. Unfortuantely I cannot see how this could help me. As udev and its rules reside on root they cannot be seen as I am not able to mount root correctly.

As far as I understand it (please correct me if I'm wrong) uBoot detects my USB stick and loads my kernel uImage. Now it starts the kernel which takes over control. The kernel then re-detects all usb mass storage devices (in wrong order in my case). Now when the kernel tries to mount root it fails as root resides not on the expected disk. (sdb instead of sda).

udev should not be involved in this process yet.
Re: Kernel panic when adding 2nd USB storage
April 15, 2011 02:46AM
Note that I mentioned "only the last few posts". I'd suggest if you use swap file instead of swap partition, then it does not matter where the swap file is (as long as it is at the root, i.e. name it /swapfile1 or /myswapfile or whatever name you've might chosen).

This is my fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/root      /               ext2    noatime,errors=remount-ro 0 1
/swapfile1     swap            swap    defaults          0       0
tmpfs          /tmp            tmpfs   defaults          0       0

So if I happen to have another HDD plugged into the 1st USB port, then it would be sda1 and my USB boot drive would be sdb1. And there is no swap partition for the kernel to look for. Would that work for your kernel if you remove the hard coded part that looks for sda2 or sdb2?



Edited 1 time(s). Last edit at 04/15/2011 02:47AM by bodhi.
Christian
Re: Kernel panic when adding 2nd USB storage
April 15, 2011 04:13PM
bodhi Wrote:
-------------------------------------------------------
> So if I happen to have another HDD plugged into
> the 1st USB port, then it would be sda1 and my USB
> boot drive would be sdb1. And there is no swap
> partition for the kernel to look for. Would that
> work for your kernel if you remove the hard coded
> part that looks for sda2 or sdb2?

The problem is not the swap drives. The problem is that when only the stick is attached root can be found on sda. When stick & HDD are attached, root can be found on sdb, sda contains just some data.
Now -someone- has to tell the kernel where root can be found. Typically this is done by grub which sets the kernel commandline before starting the kernel. On a dockstar uBoot can do it or we hard code it into the kernel.

All this happens before fstab is loaded as fstab resides on root, right?

I need some kind of uboot script saying "if exists some partition sdx whith a file system of y then pass root=/dev/sdx as a kernel parameter". I guess this is doable, I just don't know how
Re: Kernel panic when adding 2nd USB storage
April 15, 2011 05:16PM
Christian, that was just an idea as how we can put everything on one partition and avoid the complication of the USB drives moving around by the Dockstar. But I think you can find info regarding the USB drive scanning during boot in this thread.

http://forum.doozan.com/read.php?3,12,12#msg-12

Jeff explained how the UBoot installer configures this.
John Doe
Re: Kernel panic when adding 2nd USB storage
April 15, 2011 05:40PM
You can probably get around this problem by swapping the USB stick and the hard drive. The boot loader sees the USB devices in the order of the ports (top, next to ethernet, next to that, side), but for some reason your Linux kernel sees your devices in a different order. If it always sees the hard disk as sda, then make the boot loader see it in the same order: attach it to the USB port next to the ethernet port, which is enumerated before the other USB port on the back of the Dockstar.

Another option is to set a distinctive filesystem label on your root partition and use an initial ramdisk that supports selecting the root filesystem by label (or UUID). Then change the Uboot scripts to pass this parameter to the kernel.
Christian
Re: Kernel panic when adding 2nd USB storage
April 18, 2011 04:01PM
Thanks for the advice.
My problem is the kernel, which sees the stick sometimes as sda, sometimes as sdb (depending on existence of secondary USB HD). Both configurations shall boot correctly, which makes me nuts.

I was trying to go with initramfs but failed in creating a bootable system.

Still searching for an idea how to accomplish this...
Re: Kernel panic when adding 2nd USB storage
April 29, 2011 01:25AM
I have almost the same situation, except I am using a Pink V2 plug. In my search the only thing I have found is that the kernel loads a USB physical disk before a flash drive. I have not had any luck finding a work around this beside the "unplugging" of the usb physical, wait for boot, then plugging it back in. Which works just fine, but not what I am looking for.
I hope someone adds to this post and maybe even finds a better fix.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: