Skip to contentSkip to conversation

waiting 10s before mounting root filesystem?

DISCUSSION William Park 12 participants 32 messages Dec 27, 2004 – Dec 31, 2004 VFS

lore
Share & tools
lore
#0 lore raw

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
#1 lore raw

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Cheers,
Trent

Quoted 19 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Signature · 8 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 2 lines
Trent Lloyd <[email protected]>
Bur.st Networking Inc.
#2 lore raw

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c until the root filesystem can be mounted.... not that beautiful - but it works :)

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Cheers,
Andreas

PS: In the same manner you can do it with 2.6

Quoted 32 lines · Trent Lloyd

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Cheers,
Trent

Quoted 21 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Signature · 8 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#3 lore raw
Quoted 4 lines · Andreas Unterkircher

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c until the root filesystem can be mounted.... not that beautiful - but it works :)

PS: In the same manner you can do it with 2.6

There's a patch for 2.6 (slightly nicer, with a wait queue), see
http://marc.theaimsgroup.com/?l=linux-kernel&m=109122295308836&w=2

Eric

#4 lore raw
In reply to Andreas Unterkircher
Quoted 19 lines · Andreas Unterkircher
Quoted 10 lines
Quoted 9 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Quoted 3 lines

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c
until the root filesystem can be mounted.... not that beautiful - but it works :)

Quoted 6 lines

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Cheers,
Andreas

PS: In the same manner you can do it with 2.6

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c renamed from init/do_mounts.c--orig +7 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 
+#if 0	/* original code */
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:
Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
#5 lore raw
Quoted 34 lines · William Park
Quoted 19 lines · Andreas Unterkircher
Quoted 10 lines
Quoted 9 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Quoted 3 lines

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c
until the root filesystem can be mounted.... not that beautiful - but it works :)

Quoted 6 lines

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Cheers,
Andreas

PS: In the same manner you can do it with 2.6

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c retry: · line 303

Quoted 3 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +0 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 

How about adding a loglevel to this printk() while you are at it? like this for instance:

	printk(KERN_ERR "Please append a correct \"root=\" boot option\n");

or maybe that should be KERN_CRIT ...

init/do_mounts.c retry: · line 307

Quoted 4 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +3 -0
+#if 0	/* original code */
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");

^^^ And here I think a loglevel of KERN_INFO would be resonable :

	printk (KERN_INFO "Waiting 5 seconds to try mounting root fs again...\n");

init/do_mounts.c retry: · line 309

Quoted 2 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +2 -0
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);

I could be mistaken, but I would have said that msleep would have been better here.???

init/do_mounts.c retry: · line 313

Quoted 4 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +2 -0
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));

^^^ and this one :

	panic(KERN_CRIT "VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
Signature · 1 line
Jesper Juhl
#6 lore raw
Quoted 39 lines · Jesper Juhl
Quoted 11 lines · William Park
Quoted 1 line · Andreas Unterkircher

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c retry: · line 303

Quoted 3 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +0 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 

How about adding a loglevel to this printk() while you are at it? like this for instance:

	printk(KERN_ERR "Please append a correct \"root=\" boot option\n");

or maybe that should be KERN_CRIT ...

init/do_mounts.c retry: · line 307

Quoted 4 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +3 -0
+#if 0	/* original code */
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");

^^^ And here I think a loglevel of KERN_INFO would be resonable :

	printk (KERN_INFO "Waiting 5 seconds to try mounting root fs again...\n");

init/do_mounts.c retry: · line 309

Quoted 2 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +2 -0
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);

I could be mistaken, but I would have said that msleep would have been better here.???

Quoted 11 lines

init/do_mounts.c retry: · line 313

Quoted 4 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +2 -0
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));

^^^ and this one :

	panic(KERN_CRIT "VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
Signature · 1 line
Jesper Juhl

Jesper, I have no idea what I'm doing. :-) I simply adapted the 2.4 patch for 2.6.10 kernel.

Ideally, motherboard should support booting from USB key drive directly. I'm told that most modern motherboards do support usbboot, but my machine doesn't. So, I trying to load the kernel from floppy (harddisk for testing purpose). This is part of my attempt to build Linux thin-client out of mini-ITX type of computer (Via CLE266 chipset, Via C3 cpu).

Now, I need to find a machine that actually can do usbboot...

Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
#7 lore raw
Quoted 10 lines · William Park

[...]

Ideally, motherboard should support booting from USB key drive directly. I'm told that most modern motherboards do support usbboot, but my machine doesn't. So, I trying to load the kernel from floppy (harddisk for testing purpose). This is part of my attempt to build Linux thin-client out of mini-ITX type of computer (Via CLE266 chipset, Via C3 cpu).

Now, I need to find a machine that actually can do usbboot...

You will have the same problem even if the BIOS supports booting from USB. The BIOS will load the bootloader and map the USB drive as if it were a regular disk, so that the INTxx calls (can't say the number from memory) that LILO (or another bootloader) uses to load the kernel and initrd into memory will work.

After that, the kernel boots the same way as if it were loaded from a floppy. It still needs to discover the USB drive to mount the root filesystem, and that will still take the 5 seconds you were complaining about.

As Trent Lloyd already mentioned, you could solve this using a small initrd and a "nash" script, instead of patching the kernel, although I'm in favor of a patch of this sort getting into mainline.

After all, what is the use of kernel saying "Panic, can not mount the root filesystem" instead of saying "humm... no root file system there. Let me try again in a second or so and see if anything as come up..."?

Signature · 4 lines
Paulo Marques - www.grupopie.com

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu
#8 lore raw
Quoted 18 lines · Paulo Marques
Quoted 10 lines · William Park

[...]

Ideally, motherboard should support booting from USB key drive directly. I'm told that most modern motherboards do support usbboot, but my machine doesn't. So, I trying to load the kernel from floppy (harddisk for testing purpose). This is part of my attempt to build Linux thin-client out of mini-ITX type of computer (Via CLE266 chipset, Via C3 cpu).

Now, I need to find a machine that actually can do usbboot...

You will have the same problem even if the BIOS supports booting from USB. The BIOS will load the bootloader and map the USB drive as if it were a regular disk, so that the INTxx calls (can't say the number from memory) that LILO (or another bootloader) uses to load the kernel and initrd into memory will work.

Quoted 4 lines

After that, the kernel boots the same way as if it were loaded from a floppy. It still needs to discover the USB drive to mount the root filesystem, and that will still take the 5 seconds you were complaining about.

Ah, right.

Quoted 4 lines

As Trent Lloyd already mentioned, you could solve this using a small initrd and a "nash" script, instead of patching the kernel, although I'm in favor of a patch of this sort getting into mainline.

I read Documentation/initrd.txt and I don't understand it. If I understand it right, I have to build a complete root filesystem with all the stuffs necessary for mounting the second (real) root filesystem. If I'm loading the kernel from floppy, then I only have 200k to work with. I'll try initrd.txt, step by step over the holidays.

Quoted 4 lines

After all, what is the use of kernel saying "Panic, can not mount the root filesystem" instead of saying "humm... no root file system there. Let me try again in a second or so and see if anything as come up..."?

Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
#9 lore raw
Quoted 6 lines · William Park

[...]
I read Documentation/initrd.txt and I don't understand it. If I understand it right, I have to build a complete root filesystem with all the stuffs necessary for mounting the second (real) root filesystem. If I'm loading the kernel from floppy, then I only have 200k to work with. I'll try initrd.txt, step by step over the holidays.

Yes, but if you use "nash" as a script parser and compile everything you need static with dietlibc or uClibc (or some other small libc replacement), 200k will be plenty to accomplish what you want. You'll probably be able to find pre-compiled binaries like these on the net, if you search for them.

Of course this is much more work than simply patch the kernel to wait a little, but with this training you'll be able to handle similar situations in the future were there is no patch to solve them.

Signature · 4 lines
Paulo Marques - www.grupopie.com

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu
#10 lore raw
Quoted 14 lines · Paulo Marques
Quoted 6 lines · William Park

[...] I read Documentation/initrd.txt and I don't understand it. If I understand it right, I have to build a complete root filesystem with all the stuffs necessary for mounting the second (real) root filesystem. If I'm loading the kernel from floppy, then I only have 200k to work with. I'll try initrd.txt, step by step over the holidays.

Yes, but if you use "nash" as a script parser and compile everything you need static with dietlibc or uClibc (or some other small libc replacement), 200k will be plenty to accomplish what you want. You'll probably be able to find pre-compiled binaries like these on the net, if you search for them.

Quoted 3 lines

Of course this is much more work than simply patch the kernel to wait a little, but with this training you'll be able to handle similar situations in the future were there is no patch to solve them.

I finally wrote a script to build 200MB root filesystem from Slackware distribution (A, AP, N, X series). And, now, you're telling me to build a 200kB root filesystem? I need beer...

Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing. 
#11 lore raw
Quoted 3 lines · William Park

I finally wrote a script to build 200MB root filesystem from Slackware distribution (A, AP, N, X series). And, now, you're telling me to build a 200kB root filesystem? I need beer...

You don't need beer, you need busybox. The smallest initrd I made with busybox is 99kB (finds boot cdrom and sets up a ram disk as rootfs).

Signature · 1 line
Andreas Steinmetz                       SPAMmers use [email protected]
#12 lore raw
Quoted 7 lines · Andreas Steinmetz
Quoted 3 lines · William Park

I finally wrote a script to build 200MB root filesystem from Slackware distribution (A, AP, N, X series). And, now, you're telling me to build a 200kB root filesystem? I need beer...

You don't need beer, you need busybox. The smallest initrd I made with busybox is 99kB (finds boot cdrom and sets up a ram disk as rootfs).

Hmmm... Since we have the equivalent function in slightly less than 7 kB in Formilux, I think that I should document a bit more when I have some time so that others can reuse it... I find it a shame to still need 99 kB to find a CDROM, particularly when you need to put this on floppies.

Regards,
Willy

#13 lore raw
In reply to William Park
Quoted 3 lines · In article <[email protected]> you wrote:

I finally wrote a script to build 200MB root filesystem from Slackware distribution (A, AP, N, X series). And, now, you're telling me to build a 200kB root filesystem? I need beer...

You only need to have the one executable file and supporting files like config files, shells or libs. In case of a static compiled script you need no libs nor shell. You will probably need some mount and usb tools, not more.

Bernd

#14 lore raw
In reply to Paulo Marques
Quoted 8 lines · Paulo Marques
Quoted 6 lines · William Park

[...]
I read Documentation/initrd.txt and I don't understand it. If I understand it right, I have to build a complete root filesystem with all the stuffs necessary for mounting the second (real) root filesystem. If I'm loading the kernel from floppy, then I only have 200k to work with. I'll try initrd.txt, step by step over the holidays.

Quoted 5 lines

Yes, but if you use "nash" as a script parser and compile everything you need static with dietlibc or uClibc (or some other small libc replacement), 200k will be plenty to accomplish what you want. You'll probably be able to find pre-compiled binaries like these on the net, if you search for them.

ash is also a great little shell for stuff like that - it's very close to bash syntax (which most people are familliar with) and it's resonably small.

Also, busybox is something you want to take a look at, it's a single binary that implements tiny versions of a lot of unix utilities - current version implements these (note it includes a tiny ash shell as well):

addgroup, adduser, adjtimex, ar, arping, ash, awk, basename, bunzip2, busybox, bzcat, cal, cat, chgrp, chmod, chown, chroot, chvt, clear, cmp, cp, cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, devfsd, df, dirname, dmesg, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, egrep, env, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, fold, free, freeramdisk, fsck.minix, ftpget, ftpput, getopt, getty, grep, gunzip, gzip, halt, hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod, install, ip, ipaddr, ipcalc, iplink, iproute, iptunnel, kill, killall, klogd, lash, last, length, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, ls, lsmod, makedevs, md5sum, mesg, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, modprobe, more, mount, msh, mt, mv, nameif, nc, netstat, nslookup, od, openvt, passwd, patch, pidof, ping, ping6, pipe_progress, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, rm, rmdir, rmmod, route, rpm, rpm2cpio, run-parts, rx, sed, seq, setkeycodes, sha1sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top, touch, tr, traceroute, true, tty, udhcpc, udhcpd, umount, uname, uncompress, uniq, unix2dos, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which, who, whoami, xargs, yes, zcat

Most of these are ofcourse somewhat limited in functionality compared to their full-blown cousins, but for use on a initrd busybox can be close to the only app you need, and you can build it to include or exclude the commands you need/don't need, so it can get quite tiny.
A static build of busybox with just the commands that you need enabled and linked against uClibc or similar is what I would use.

Take a look : http://www.busybox.net/

Signature · 1 line
Jesper Juhl
#15 lore raw
In reply to William Park
Quoted 38 lines · William Park
Quoted 19 lines · Andreas Unterkircher
Quoted 10 lines
Quoted 9 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Quoted 3 lines

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c
until the root filesystem can be mounted.... not that beautiful - but it works :)

Quoted 6 lines

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Cheers,
Andreas

PS: In the same manner you can do it with 2.6

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 
+#if 0	/* original code */

init/do_mounts.c retry: · line 314

Quoted 10 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +6 -0
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:

William,

Solar version which is now merged in v2.4 looks better (5s sleep is too long and only one try) IMO.

It sleeps 1s each time, 10 times. More reliable and faster.

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

#16 lore raw
Quoted 52 lines · Marcelo Tosatti
Quoted 38 lines · William Park
Quoted 19 lines · Andreas Unterkircher
Quoted 10 lines
Quoted 9 lines

How do I make the kernel to wait about 10s before attempting to mount root filesystem? Is there obscure kernel parameter?

I can load the kernel from /dev/fd0, then mount /dev/hda2 as root filesystem. But, I can't seem to mount /dev/sda1 (USB key drive) as root filesystem. All relevant USB and SCSI modules are compiled into the kernel. I think kernel is too fast in panicking. I would like the kernel to wait about 10s until 'usb-storage' and 'sd_mod' work out all the details.

Quoted 3 lines

This is really suited to the task of an initrd, then you can spin until the usb storage device comes up in a bash script or something similar.

Or you could try a patch from Randy Dunlap & Eric Lammerts [1] which loops around in do_mounts.c
until the root filesystem can be mounted.... not that beautiful - but it works :)

Quoted 6 lines

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Cheers,
Andreas

PS: In the same manner you can do it with 2.6

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 
+#if 0	/* original code */

init/do_mounts.c retry: · line 314

Quoted 10 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +6 -0
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:

William,

Quoted 5 lines

Solar version which is now merged in v2.4 looks better (5s sleep is too long and only one try) IMO.

It sleeps 1s each time, 10 times. More reliable and faster.

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

That's a nice patch. Why not make the same change in 2.6?
I forward ported the patch linked above with a few minor changes - my version differs from the original in these ways :
- use ssleep() instead of schedule_timeout.
- rename tries to retries and actually retry the specified nr of times ( if (retries--) {...} instead of if (--tries) {...} ).
- use a short instead of int to hold the retry count.
- change the text outputted a little bit.
- retry a few more times (15 instead of 9) since if we fail here we are going to panic() we might as well try hard, and who knows how slow some devices can be?

Andrew, would you consider including the patch below in 2.6 ?

init/do_mounts.c +11 -2
diff -up linux-2.6.10-bk2-orig/init/do_mounts.c linux-2.6.10-bk2/init/do_mounts.c
@@ -6,6 +6,7 @@
 #include <linux/suspend.h>
 #include <linux/root_dev.h>
 #include <linux/security.h>
+#include <linux/delay.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -278,6 +279,7 @@ void __init mount_block_root(char *name,
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	short retries = 15;
 
 	get_fs_names(fs_names);
 retry:
@@ -297,9 +299,16 @@ retry:
 		 * and bad superblock on root device.
 		 */
 		__bdevname(ROOT_DEV, b);
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
+		if (retries--) {
+			printk(KERN_WARNING "VFS: Cannot open root device "
+				"\"%s\" or %s, retrying in 1s.\n",
 				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+			ssleep(1);
+			goto retry;
+		}
+		printk(KERN_CRIT "VFS: Cannot open root device \"%s\" or %s, giving up.\n",
+				root_device_name, b);
+		printk(KERN_CRIT "Please append a correct \"root=\" boot option\n");
 
 		panic("VFS: Unable to mount root fs on %s", b);
 	}
#17 lore raw
Quoted 38 lines · William Park
Quoted 29 lines · Marcelo Tosatti
Quoted 15 lines · William Park
Quoted 1 line · Andreas Unterkircher

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 
+#if 0	/* original code */

init/do_mounts.c retry: · line 314

Quoted 10 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +6 -0
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:

William,

Quoted 6 lines

Solar version which is now merged in v2.4 looks better (5s sleep is too long and only one try) IMO.

It sleeps 1s each time, 10 times. More reliable and faster.

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

Quoted 8 lines

Hi Marcelo,

1. Actually, my patch above loops every 5s to reduce screen clutter, whereas the original 2.4 patch (cited by Andreas Unterkircher) loops every 1s. Both loops forever.

But, if a limit of 10 tries is what you want, then here is a patch for 2.6.10:

I agree with you that reducing screen clutter is a good thing. How about something like this that waits for 10+ seconds so even slow devices have a chance to get up but also does some primitive ratelimiting on the messages by only printing one every 3 seconds (but still attempting to mount every 1 sec) ?

This is a small variation on the patch I posted a little while ago.

init/do_mounts.c +12 -2
diff -up linux-2.6.10-bk2-orig/init/do_mounts.c linux-2.6.10-bk2/init/do_mounts.c
@@ -6,6 +6,7 @@
 #include <linux/suspend.h>
 #include <linux/root_dev.h>
 #include <linux/security.h>
+#include <linux/delay.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -278,6 +279,7 @@ void __init mount_block_root(char *name,
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	short retries = 15;
 
 	get_fs_names(fs_names);
 retry:
@@ -297,9 +299,17 @@ retry:
 		 * and bad superblock on root device.
 		 */
 		__bdevname(ROOT_DEV, b);
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
+		if (retries--) {
+			if (retries % 3 == 0)
+				printk(KERN_WARNING "VFS: Cannot open root device "
+					"\"%s\" or %s, retrying in 1s.\n",
+					root_device_name, b);
+			ssleep(1);
+			goto retry;
+		}
+		printk(KERN_CRIT "VFS: Cannot open root device \"%s\" or %s, giving up.\n",
 				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		printk(KERN_CRIT "Please append a correct \"root=\" boot option\n");
 
 		panic("VFS: Unable to mount root fs on %s", b);
 	}
Quoted 7 lines

2. I sincerely hope that this patch get included in the main kernel. USB boot is very important feature, and will become the standard way of booting Linux thin-client as well as other Linux system, embedded or not. It will make Netboot, Etherboot, PXE boot, CF-to-IDE adapter, and initrd all obsolete.

I agree, some version of this should go into 2.6. If we can successfully get the system up and running by retrying the root fs mount a few times then that's a lot better than panicking :)

Signature · 6 lines
Jesper Juhl


PS. Sorry if I messed up the thread a bit, but I had some mailserver 
trouble and lost a few LKML mails so I couldn't reply directly to the 
proper mail.
#18 lore raw
Quoted 5 lines · Jesper Juhl
Quoted 4 lines · William Park
Quoted 3 lines · Marcelo Tosatti
Quoted 2 lines · William Park
Quoted 1 line · Andreas Unterkircher

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

...

Quoted 8 lines
Quoted 8 lines

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

Hi Marcelo,

1. Actually, my patch above loops every 5s to reduce screen clutter, whereas the original 2.4 patch (cited by Andreas Unterkircher) loops every 1s. Both loops forever.

Quoted 8 lines
Quoted 2 lines

But, if a limit of 10 tries is what you want, then here is a patch for 2.6.10:

I agree with you that reducing screen clutter is a good thing. How about something like this that waits for 10+ seconds so even slow devices have a chance to get up but also does some primitive ratelimiting on the messages by only printing one every 3 seconds (but still attempting to mount every 1 sec) ?

Hi Jesper,

I prefer countdown with short message. The 2.4 messages are too long. Incorporating your use of ssleep() and printk() loglevel, here is the latest iteration:

init/do_mounts.c renamed from init/do_mounts.c--orig +9 -3
@@ -6,6 +6,7 @@
 #include <linux/suspend.h>
 #include <linux/root_dev.h>
 #include <linux/security.h>
+#include <linux/delay.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -278,6 +279,7 @@
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	int tryagain = 20;
 
 	get_fs_names(fs_names);
 retry:
@@ -297,9 +299,13 @@
 		 * and bad superblock on root device.
 		 */
 		__bdevname(ROOT_DEV, b);
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
-				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		if (--tryagain) {
+		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
+		    ssleep (1);
+		    goto retry;
+		}
+		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
+		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");
 
 		panic("VFS: Unable to mount root fs on %s", b);
 	}
#19 lore raw
Quoted 41 lines · William Park
Quoted 5 lines · Jesper Juhl
Quoted 4 lines · William Park
Quoted 3 lines · Marcelo Tosatti
Quoted 2 lines · William Park
Quoted 1 line · Andreas Unterkircher

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

...

Quoted 8 lines
Quoted 8 lines

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

Hi Marcelo,

1. Actually, my patch above loops every 5s to reduce screen clutter, whereas the original 2.4 patch (cited by Andreas Unterkircher) loops every 1s. Both loops forever.

Quoted 8 lines
Quoted 2 lines

But, if a limit of 10 tries is what you want, then here is a patch for 2.6.10:

I agree with you that reducing screen clutter is a good thing. How about something like this that waits for 10+ seconds so even slow devices have a chance to get up but also does some primitive ratelimiting on the messages by only printing one every 3 seconds (but still attempting to mount every 1 sec) ?

Hi Jesper,

I prefer countdown with short message. The 2.4 messages are too long. Incorporating your use of ssleep() and printk() loglevel, here is the latest iteration:

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -6,6 +6,7 @@
 #include <linux/suspend.h>
 #include <linux/root_dev.h>
 #include <linux/security.h>
+#include <linux/delay.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>

init/do_mounts.c line 283

Quoted 5 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -278,6 +279,7 @@
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	int tryagain = 20;
 

Ok, I'm nitpicking here, but why int and not short? are we likely to ever want to wait for more than 2 minutes? and if we want to wait ~3min, then unsigned short should do just fine (and unsigned would even be logical since negative retry value doesn't make any sense)....

init/do_mounts.c line 302

Quoted 1 line
init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
+		if (--tryagain) {

I think if (tryagain--) makes more sense. You set tryagain to 20 thereby implying that we will be doing 20 retries, but with --tryagain we will only be doing 19 retries, not 20 - with tryagain-- we will be doing the nr. of retries that we initially initialize 'tryagain' to.

other than that (and it /is/ nitpicking) the patch looks good to me.

Signature · 1 line
Jesper Juhl
#20 lore raw
Quoted 14 lines · Jesper Juhl

[...]

init/do_mounts.c line 283

Quoted 8 lines

#include <linux/nfs_fs.h>
#include <linux/nfs_fs_sb.h>

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -278,6 +279,7 @@
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	int tryagain = 20;
 

Ok, I'm nitpicking here, but why int and not short? are we likely to ever want to wait for more than 2 minutes? and if we want to wait ~3min, then unsigned short should do just fine (and unsigned would even be logical since negative retry value doesn't make any sense)....

Usually it is better to use int's instead of short's because memory accesses for CPU word size data are faster.

With some CPUs, decrementing a short will probably involve reading a int from memory, updating only the correct section of it, and then writing an int. It is only worth the save if you're trying to make a very used struct have a good 2^N size, or something like that.

Of course, things will get more complex with data caches, bus sizes, etc., but I think the premise that the CPU will be more confortable handling its native data size still holds.

Signature · 4 lines
Paulo Marques - www.grupopie.com

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu
#21 lore raw
In reply to William Park

Review

Quoted 11 lines · William Park
(quoted diff) +0 -1
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
 -				root_device_name, b);
 -		printk("Please append a correct \"root=\" boot option\n");
 +		if (--tryagain) {
 +		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
 +		    ssleep (1);
 +		    goto retry;
 +		}
 +		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
 +		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

#22 lore raw
Quoted 15 lines · Andrew Morton

Review

Quoted 11 lines · William Park
(quoted diff) +0 -1
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
 -				root_device_name, b);
 -		printk("Please append a correct \"root=\" boot option\n");
 +		if (--tryagain) {
 +		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
 +		    ssleep (1);
 +		    goto retry;
 +		}
 +		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
 +		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device,

The media may take a while to become readable (think of CDROM).

Quoted 1 line

why not rely upon the user doing that thing and then hitting reset?

I think this is not the case (only) case the patch covers up.

Yes its ugly.

#23 lore raw
Quoted 18 lines · Marcelo Tosatti
Quoted 15 lines · Andrew Morton

Review

Quoted 11 lines · William Park
(quoted diff) +0 -1
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
 -				root_device_name, b);
 -		printk("Please append a correct \"root=\" boot option\n");
 +		if (--tryagain) {
 +		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
 +		    ssleep (1);
 +		    goto retry;
 +		}
 +		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
 +		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device,

Quoted 2 lines

The media may take a while to become readable (think of CDROM).

But the device driver should wait while the media spins up. If it doesn't, the kernel would get I/O errors all over the place in normal operation.

#24 lore raw
In reply to Andrew Morton
Quoted 17 lines · Andrew Morton

init/do_mounts.c line 308

Quoted 10 lines · William Park
init/do_mounts.c renamed from init/do_mounts.c--orig +7 -3
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
-				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		if (--tryagain) {
+		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
+		    ssleep (1);
+		    goto retry;
+		}
+		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
+		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

No, no. The problem is not user interaction.

The problem is that the USB subsystem takes a lot of time to go through the hostcontrollers -> hubs -> devices. By the time it finds the USB mass storage that is supposed to be used as root filesystem, the kernel had already panic'ed.

IMHO the kernel should handle this case just fine, without the need for initrd's. After all the user says "my root filesystem is /dev/sda1", and the kernel panic's even though the filesystem is there. This doesn't seem like a correct bahavior.

Signature · 4 lines
Paulo Marques - www.grupopie.com

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu
#25 lore raw
Quoted 20 lines · Paulo Marques
Quoted 17 lines · Andrew Morton

init/do_mounts.c line 308

Quoted 10 lines · William Park
init/do_mounts.c renamed from init/do_mounts.c--orig +7 -3
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
-				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		if (--tryagain) {
+		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
+		    ssleep (1);
+		    goto retry;
+		}
+		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
+		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

Quoted 6 lines

No, no. The problem is not user interaction.

The problem is that the USB subsystem takes a lot of time to go through the hostcontrollers -> hubs -> devices. By the time it finds the USB mass storage that is supposed to be used as root filesystem, the kernel had already panic'ed.

That would be a USB bug, surely. If /dev/usb/foo is present and functioning correctly, and higher-level code tries to access that device, USB should _not_ error out - it should block the caller until everything is sorted out.

#26 lore raw
Quoted 25 lines · Andrew Morton
Quoted 23 lines · Paulo Marques
Quoted 18 lines · Andrew Morton

init/do_mounts.c line 308

Quoted 10 lines · William Park
init/do_mounts.c renamed from init/do_mounts.c--orig +7 -3
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
-				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		if (--tryagain) {
+		    printk (KERN_WARNING "VFS: Waiting %dsec for root device...\n", tryagain);
+		    ssleep (1);
+		    goto retry;
+		}
+		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or %s\n", root_device_name, b);
+		printk (KERN_CRIT "Please append a correct \"root=\" boot option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

No, no. The problem is not user interaction.

Quoted 7 lines
Quoted 1 line

The problem is that the USB subsystem takes a lot of time to go through the hostcontrollers -> hubs -> devices. By the time it finds the USB mass storage that is supposed to be used as root filesystem, the kernel had already panic'ed.

That would be a USB bug, surely. If /dev/usb/foo is present and functioning correctly, and higher-level code tries to access that device, USB should _not_ error out - it should block the caller until everything is sorted out.

The problem is that, if you use udev (or iack, iack, cough, cough, devfs), the device node is not yet present at the time the kernel tries to mount it, although the hardware is physically there. This is because the USB subsystem is busy going through all the USB tree, enumerating / reseting devices, powering hubs, etc.

I really don't know enough about the internal details, but it seems that the USB startup sequence is asynchronous with respect to the rest of the boot sequence. This is usually allright (I really don't want the detection of my USB scanner to hold back my boot), but in the special case where the root filesystem is in a USB mass storage device, it poses a real problem.

Maybe someone like Grek Kroah, Alan Stern, etc., can shed some more light on this matter.

Signature · 4 lines
Paulo Marques - www.grupopie.com

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu
#27 lore raw
In reply to Andrew Morton
Quoted 14 lines · Andrew Morton
Quoted 6 lines · Paulo Marques
Quoted 3 lines · Andrew Morton

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

Quoted 6 lines

No, no. The problem is not user interaction.

The problem is that the USB subsystem takes a lot of time to go through the hostcontrollers -> hubs -> devices. By the time it finds the USB mass storage that is supposed to be used as root filesystem, the kernel had already panic'ed.

Quoted 4 lines

That would be a USB bug, surely. If /dev/usb/foo is present and functioning correctly, and higher-level code tries to access that device, USB should _not_ error out - it should block the caller until everything is sorted out.

My USB key drive takes 5s to show up as SCSI, from the moment 'uhci_hcd' and 'usb-storage' spit out message. I don't know why. Internally, USB key drive is solid state flash memory, so it should be faster than any spinning disks.

The USB key drive works when I load the USB/SCSI modules as modules. But, when I boot all-compiled-in-kernel and try to mount /dev/sda1 as root device, the kernel panicks before the USB key drive has chance to register. This means that in order to do 'usbboot', one must go through the contorted process of 'initrd' which is advocated only by special interest group whose embedded world is one patch way from becoming obsolete.

#28 lore raw
Quoted 4 lines · William Park

My USB key drive takes 5s to show up as SCSI, from the moment 'uhci_hcd' and 'usb-storage' spit out message. I don't know why. Internally, USB key drive is solid state flash memory, so it should be faster than any spinning disks.

USB keys driven by UB driver come up instantly.

Signature · 2 lines
Tomasz Torcz               RIP is irrevelant. Spoofing is futile.
[email protected]     Your routes will be aggreggated. -- Alex Yuriev
#29 lore raw
Quoted 7 lines · Tomasz Torcz
Quoted 4 lines · William Park

My USB key drive takes 5s to show up as SCSI, from the moment 'uhci_hcd' and 'usb-storage' spit out message. I don't know why. Internally, USB key drive is solid state flash memory, so it should be faster than any spinning disks.

USB keys driven by UB driver come up instantly.

Kernel Helpfile says:

CONFIG_BLK_DEV_UB:
This driver supports certain USB attached storage devices such as flash keys.
Warning: Enabling this cripples the usb-storage driver. If unsure, say N.

I need 'usb-storage', because USB key drive is supposed to be portable harddisk.

#30 lore raw
In reply to Paulo Marques
Quoted 29 lines · Paulo Marques
Quoted 12 lines · Andrew Morton
Quoted 10 lines · William Park
init/do_mounts.c renamed from init/do_mounts.c--orig +2 -3
-		printk("VFS: Cannot open root device \"%s\" or %s\n",
-				root_device_name, b);
-		printk("Please append a correct \"root=\" boot option\n");
+		if (--tryagain) {
+		    printk (KERN_WARNING "VFS: Waiting %dsec for root 

device...\n", tryagain);

init/do_mounts.c renamed from init/do_mounts.c--orig +4 -0
+		    ssleep (1);
+		    goto retry;
+		}
+		printk (KERN_CRIT "VFS: Cannot open root device \"%s\" or 
Quoted 8 lines
Quoted 3 lines

%s\n", root_device_name, b);

(quoted diff) +1 -0
+		printk (KERN_CRIT "Please append a correct \"root=\" boot 

option\n");

Why is this patch needed? If it is to offer the user a chance to insert the correct medium or to connect the correct device, why not rely upon the user doing that thing and then hitting reset?

No, no. The problem is not user interaction.

The problem is that the USB subsystem takes a lot of time to go through the hostcontrollers -> hubs -> devices. By the time it finds the USB mass storage that is supposed to be used as root filesystem, the kernel had already panic'ed.

Quoted 4 lines

IMHO the kernel should handle this case just fine, without the need for initrd's. After all the user says "my root filesystem is /dev/sda1", and the kernel panic's even though the filesystem is there. This doesn't seem like a correct bahavior.

Well, Paulo's has more of a clue than I do.

Some CD drives suffer from the same issues.

#31 lore raw
In reply to Marcelo Tosatti
Quoted 29 lines · Marcelo Tosatti
Quoted 15 lines · William Park
Quoted 1 line · Andreas Unterkircher

[1] http://www.xenotime.net/linux/usb/usbboot-2422.patch

Thanks Andreas. I can now boot from my el-cheapo USB key drive (256MB SanDisk Cruzer Mini). Since mine takes about 5sec to show up, I decided to wait 5sec instead of 1sec. Here is diff for 2.6.10:

init/do_mounts.c renamed from init/do_mounts.c--orig +1 -0
@@ -301,7 +301,14 @@ retry:
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
 
+#if 0	/* original code */

init/do_mounts.c retry: · line 314

Quoted 10 lines
init/do_mounts.c renamed from init/do_mounts.c--orig +6 -0
 		panic("VFS: Unable to mount root fs on %s", b);
+#else
+		printk ("Waiting 5 seconds to try again...\n");
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5 * HZ);
+		goto retry;
+#endif
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:

William,

Quoted 6 lines

Solar version which is now merged in v2.4 looks better (5s sleep is too long and only one try) IMO.

It sleeps 1s each time, 10 times. More reliable and faster.

http://linux.bkbits.net:8080/linux-2.4/[email protected]?nav=index.html|ChangeSet@-3w|[email protected]

Hi Marcelo,

1. Actually, my patch above loops every 5s to reduce screen clutter, whereas the original 2.4 patch (cited by Andreas Unterkircher) loops every 1s. Both loops forever.

But, if a limit of 10 tries is what you want, then here is a patch for 2.6.10:
====================

init/do_mounts.c renamed from init/do_mounts.c--orig +8 -2
@@ -278,6 +278,7 @@
 	char *fs_names = __getname();
 	char *p;
 	char b[BDEVNAME_SIZE];
+	int tryagain = 10;
 
 	get_fs_names(fs_names);
 retry:
@@ -297,11 +298,16 @@
 		 * and bad superblock on root device.
 		 */
 		__bdevname(ROOT_DEV, b);
+		if (--tryagain) {
+		    printk ("VFS: Waiting %dsec for root device...\n", tryagain);
+		    set_current_state (TASK_INTERRUPTIBLE);
+		    schedule_timeout (HZ);
+		    goto retry;
+		}
 		printk("VFS: Cannot open root device \"%s\" or %s\n",
 				root_device_name, b);
 		printk("Please append a correct \"root=\" boot option\n");
-
-		panic("VFS: Unable to mount root fs on %s", b);
+		break;
 	}
 	panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
 out:

====================

The only difference are
- using 'tryagain' instead of 'tries' as counter
- printing countdown of seconds like
VFS: Waiting 9sec for root device...
VFS: Waiting 8sec for root device...
...
VFS: Waiting 1sec for root device...
before printing the final error.

2. I sincerely hope that this patch get included in the main kernel. USB boot is very important feature, and will become the standard way of booting Linux thin-client as well as other Linux system, embedded or not. It will make Netboot, Etherboot, PXE boot, CF-to-IDE adapter, and initrd all obsolete.

Signature · 3 lines
William Park <[email protected]>
Open Geometry Consulting, Toronto, Canada
Linux solution for data processing.