Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Robust/Elegant USB Booting?

5 views
Skip to first unread message

andy.so...@gmail.com

unread,
May 7, 2006, 4:54:51 PM5/7/06
to
Hi,

After looking through archives and such, there doesn't seem to
have been much discussion regarding a real solution to USB-mass-storage
booting since David Welton published an updated blkdev_wakeup patch a
year ago (March 30 2005).

Considering the number of people out there trying to do USB
solid-state/system-on-a-flashdrive booting, and the fact that rootdelay
is a bit of a stopgap measure, does anyone out there have any
unpublished, updated and robust solutions which might be eligible to be
rolled into the official kernel? It would be really nice to have a more
elegant solution, like David's, integrated in.

Andrew Somerville

andy.so...@gmail.com

unread,
May 9, 2006, 2:46:15 AM5/9/06
to
After doing a bit more searching I have found a parsimonious patch by
Heikki Linnakangas which might be eligible for kernel consideration. I
have been told that this patch is basically a 2.6.x update of a 2.4.x
patch originally written by Randy.Dunlap and Eric Lammerts which can be
found here:

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

The patch basically does and endless loop of root mounting attempts
untill something becomes available. Since failing to mount the root
partition is fatal, and endless loop is no big deal. Should apply
cleanly to the latest in 2.6.x

Comments, opinions ?

init/do_mounts.c | 63
+++++++++++++++++++++++++++++++++---------------------
init/do_mounts.h | 4 ++-
2 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -282,11 +282,14 @@ static int __init do_mount_root(char *na
return 0;
}

-void __init mount_block_root(char *name, int flags)
+static int first_try = 1;
+
+int __init mount_block_root(char *name, int flags)
{
char *fs_names = __getname();
char *p;
char b[BDEVNAME_SIZE];
+ int success;

get_fs_names(fs_names);
retry:
@@ -294,6 +297,7 @@ retry:
int err = do_mount_root(name, p, flags, root_mount_data);
switch (err) {
case 0:
+ success = 1;
goto out;
case -EACCES:
flags |= MS_RDONLY;
@@ -301,20 +305,26 @@ retry:
case -EINVAL:
continue;
}
- /*
- * Allow the user to distinguish between failed sys_open
- * 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");
+ /* Print a warning on the first attempt */
+ if(first_try) {
+ first_try = 0;
+ /*
+ * Allow the user to distinguish between failed sys_open
+ * 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("Retrying. Please verify the \"root=\" boot option\n");
+ }
+ success = 0;
+ goto out;

- panic("VFS: Unable to mount root fs on %s", b);
}
panic("VFS: Unable to mount root fs on %s", __bdevname(ROOT_DEV, b));
out:
putname(fs_names);
+ return success;
}

#ifdef CONFIG_ROOT_NFS
@@ -360,7 +370,7 @@ void __init change_floppy(char *fmt, ...
}
#endif

-void __init mount_root(void)
+int __init mount_root(void)
{
#ifdef CONFIG_ROOT_NFS
if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) {
@@ -384,7 +394,7 @@ void __init mount_root(void)
}
#endif
create_dev("/dev/root", ROOT_DEV, root_device_name);
- mount_block_root("/dev/root", root_mountflags);
+ return mount_block_root("/dev/root", root_mountflags);
}

/*
@@ -404,23 +414,26 @@ void __init prepare_namespace(void)

md_run_setup();

- if (saved_root_name[0]) {
- root_device_name = saved_root_name;
- ROOT_DEV = name_to_dev_t(root_device_name);
- if (strncmp(root_device_name, "/dev/", 5) == 0)
- root_device_name += 5;
- }
+ do {
+ if (saved_root_name[0]) {
+ root_device_name = saved_root_name;
+ ROOT_DEV = name_to_dev_t(root_device_name);
+ if (strncmp(root_device_name, "/dev/", 5) == 0)
+ root_device_name += 5;
+ }

- is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+ is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;

- if (initrd_load())
- goto out;
+ if (initrd_load())
+ break;

- if (is_floppy && rd_doload && rd_load_disk(0))
- ROOT_DEV = Root_RAM0;
+ if (is_floppy && rd_doload && rd_load_disk(0))
+ ROOT_DEV = Root_RAM0;
+
+ if(mount_root())
+ break;
+ } while(1);

- mount_root();
-out:
umount_devfs("/dev");
sys_mount(".", "/", NULL, MS_MOVE, NULL);
sys_chroot(".");
diff --git a/init/do_mounts.h b/init/do_mounts.h
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -11,8 +11,8 @@

dev_t name_to_dev_t(char *name);
void change_floppy(char *fmt, ...);
-void mount_block_root(char *name, int flags);
-void mount_root(void);
+int mount_block_root(char *name, int flags);
+int mount_root(void);
extern int root_mountflags;
extern char *root_device_name;

0 new messages