public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* rootfs on USB storage device
@ 2001-11-15  3:22 Jos Nouwen
  2001-11-15  5:07 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Jos Nouwen @ 2001-11-15  3:22 UTC (permalink / raw)
  To: linux-kernel

Since I own a USB Pen Drive, which is perfectly working under Linux, I
wanted to put a linux rescue system on it. But for some reason it wont
work.

I linked in everything neccesary to boot from it: CONFIG_USB,
CONFIG_USB_DEVICEFS, CONFIG_USB_UHCI, CONFIG_USB_STORAGE, CONFIG_SCSI,
CONFIG_BLK_DEV_SD, CONFIG_EXT2_FS. I'm using kernel 2.4.15-pre4.

The problem is that the pendrive gets detected AFTER the kernel tries to
mount the root fs. Checking init/main.c and entering some debug lines
learns that the USB device gets detected when, in function init(), the
console gets opened: 'open("/dev/console", O_RDWR, 0)'. Immediately after
that, the 'init' program will be exec-ed. At the time of the 'open()'
call, the kernel printk()'s "hub.c: USB new device connect on bus1/1,
assigned device number 2", which is obviously the pendrive. It is
correctly registered, and a SCSI disk is emulated. But too late..

Does anybody have a clue as to what the USB bus has to do with
/dev/console?

Thanks for any help,
Jos Nouwen.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: rootfs on USB storage device
  2001-11-15  3:22 Jos Nouwen
@ 2001-11-15  5:07 ` Greg KH
  2001-11-16  2:32   ` Jos Nouwen
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2001-11-15  5:07 UTC (permalink / raw)
  To: Jos Nouwen; +Cc: linux-kernel

On Thu, Nov 15, 2001 at 04:22:33AM +0100, Jos Nouwen wrote:
> 
> Does anybody have a clue as to what the USB bus has to do with
> /dev/console?

It's a timing issue, and has nothing to do with /dev/console.  If you
sit and spin before you try to mount the root fs, the USB subsystem will
have enough time to find the drive.  There's a few patches that do this
in the lkml archives.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: rootfs on USB storage device
  2001-11-15  5:07 ` Greg KH
@ 2001-11-16  2:32   ` Jos Nouwen
  0 siblings, 0 replies; 6+ messages in thread
From: Jos Nouwen @ 2001-11-16  2:32 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

On Wed, 14 Nov 2001, Greg KH wrote:

> On Thu, Nov 15, 2001 at 04:22:33AM +0100, Jos Nouwen wrote:
> >
> > Does anybody have a clue as to what the USB bus has to do with
> > /dev/console?
>
> It's a timing issue, and has nothing to do with /dev/console.  If you
> sit and spin before you try to mount the root fs, the USB subsystem will
> have enough time to find the drive.  There's a few patches that do this
> in the lkml archives.
>
> thanks,
>
> greg k-h

It does not seem so. I included several seconds of mdelay() (and lots of
printk()'s) while I was debugging, and that didnt change a thing. I added
a.o. 4 seconds of mdelay() right before the open(), and 2 seconds right
after the open() and the two dup()'s. The storage device was detected at
the beginning of that last delay. Me thinks this is related to the open().
I added a total of 10 seconds of mdelay() between do_basic_setup() (where
the usb is initialized) and the open(). That is much more time than it
takes to init the USB storage device.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: rootfs on USB storage device
       [not found] <mailman.1005878220.14858.linux-kernel2news@redhat.com>
@ 2001-11-16  3:06 ` Pete Zaitcev
  2001-11-16 13:21   ` Eric Lammerts
  0 siblings, 1 reply; 6+ messages in thread
From: Pete Zaitcev @ 2001-11-16  3:06 UTC (permalink / raw)
  To: josn, Greg KH; +Cc: linux-kernel

> > > Does anybody have a clue as to what the USB bus has to do with
> > > /dev/console?
> >
> > It's a timing issue, and has nothing to do with /dev/console.  If you
> > sit and spin before you try to mount the root fs, the USB subsystem will
> > have enough time to find the drive.  There's a few patches that do this
> > in the lkml archives.
> >
> > greg k-h
> 
> It does not seem so. I included several seconds of mdelay() (and lots of
> printk()'s) while I was debugging, and that didnt change a thing. I added
> a.o. 4 seconds of mdelay() right before the open(), and 2 seconds right
> after the open() and the two dup()'s. The storage device was detected at
> the beginning of that last delay. [...]

I think khubd needs to run to complete whole process and mdelay()
locks it out. You need something that calls schedule() for USB
detection to work. Try to use schedule_timeout() instead of mdelay().

-- Pete

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: rootfs on USB storage device
  2001-11-16  3:06 ` rootfs on USB storage device Pete Zaitcev
@ 2001-11-16 13:21   ` Eric Lammerts
  2001-11-16 17:30     ` Pete Zaitcev
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Lammerts @ 2001-11-16 13:21 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: josn, Greg KH, linux-kernel


On Thu, 15 Nov 2001, Pete Zaitcev wrote:
> I think khubd needs to run to complete whole process and mdelay()
> locks it out. You need something that calls schedule() for USB
> detection to work. Try to use schedule_timeout() instead of mdelay().

This patch works for me.

Eric

--- linux-2.4.14-pre8-ext3/fs/super.c.orig	Fri Nov 16 00:59:18 2001
+++ linux-2.4.14-pre8-ext3/fs/super.c	Fri Nov 16 01:07:26 2001
@@ -1009,11 +1009,13 @@
 		 * Allow the user to distinguish between failed open
 		 * and bad superblock on root device.
 		 */
-		printk ("VFS: Cannot open root device \"%s\" or %s\n",
+		printk ("VFS: Cannot open root device \"%s\" or %s, retrying in 1s.\n",
 			root_device_name, kdevname (ROOT_DEV));
-		printk ("Please append a correct \"root=\" boot option\n");
-		panic("VFS: Unable to mount root fs on %s",
-			kdevname(ROOT_DEV));
+
+		/* wait 1 second and try again */
+		current->state = TASK_INTERRUPTIBLE;
+		schedule_timeout(HZ);
+		goto retry;
 	}

 	check_disk_change(ROOT_DEV);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: rootfs on USB storage device
  2001-11-16 13:21   ` Eric Lammerts
@ 2001-11-16 17:30     ` Pete Zaitcev
  0 siblings, 0 replies; 6+ messages in thread
From: Pete Zaitcev @ 2001-11-16 17:30 UTC (permalink / raw)
  To: Eric Lammerts; +Cc: linux-kernel

> Date: Fri, 16 Nov 2001 14:21:04 +0100 (CET)
> From: Eric Lammerts <eric@lammerts.org>
> To: Pete Zaitcev <zaitcev@redhat.com>
> cc: josn@josn.myip.org, Greg KH <greg@kroah.com>,
>    <linux-kernel@vger.kernel.org>

> > I think khubd needs to run to complete whole process and mdelay()
> > locks it out. You need something that calls schedule() for USB
> > detection to work. Try to use schedule_timeout() instead of mdelay().
> 
> This patch works for me.

Looks like a well done patch but what does happen if root= was
indeed incorrect? I wish there was a way to print something
meaningful for the operator.

-- Pete

P.S. - quoting the patch, saved for future reference
> --- linux-2.4.14-pre8-ext3/fs/super.c.orig	Fri Nov 16 00:59:18 2001
> +++ linux-2.4.14-pre8-ext3/fs/super.c	Fri Nov 16 01:07:26 2001
> @@ -1009,11 +1009,13 @@
>  		 * Allow the user to distinguish between failed open
>  		 * and bad superblock on root device.
>  		 */
> -		printk ("VFS: Cannot open root device \"%s\" or %s\n",
> +		printk ("VFS: Cannot open root device \"%s\" or %s, retrying in 1s.\n",
>  			root_device_name, kdevname (ROOT_DEV));
> -		printk ("Please append a correct \"root=\" boot option\n");
> -		panic("VFS: Unable to mount root fs on %s",
> -			kdevname(ROOT_DEV));
> +
> +		/* wait 1 second and try again */
> +		current->state = TASK_INTERRUPTIBLE;
> +		schedule_timeout(HZ);
> +		goto retry;
>  	}
> 
>  	check_disk_change(ROOT_DEV);

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-11-16 17:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1005878220.14858.linux-kernel2news@redhat.com>
2001-11-16  3:06 ` rootfs on USB storage device Pete Zaitcev
2001-11-16 13:21   ` Eric Lammerts
2001-11-16 17:30     ` Pete Zaitcev
2001-11-15  3:22 Jos Nouwen
2001-11-15  5:07 ` Greg KH
2001-11-16  2:32   ` Jos Nouwen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox