Find the answer to your Linux question:
Results 1 to 3 of 3
I'm trying to create a Linux image for an embedded system so that I can boot from a USB stick (or USB flash card reader). I can't use any other ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3

    Question [SOLVED] Booting from a USB stick: VFS: Cannot open root device


    I'm trying to create a Linux image for an embedded system so that I can boot from a USB stick (or USB flash card reader). I can't use any other drive (i.e. no CD/DVD drive, etc.).

    I'm working from a previous configuration that was not decided by me. Basically, the image is created from scratch using PTXdist (see ptxdist.org) and written to an ext3 partition (previously to a flash drive, now to a USB drive). We use EXTLINUX as a bootloader. The whole process takes place on a Debian system.

    I had to "hack" init/do_mounts.c so that the USB device (USB stick or USB card reader) could be detected. There are patches to do that for old versions of the kernel, just search "usb-storage-root.patch" on Google.

    Here's what my do_mounts.c file looks like:

    Code:
    get_fs_names(fs_names);
    retry:
      for (p = fs_names; *p; p += strlen(p)+1) {
        int err = do_mount_root(name, p, flags, root_mount_data);
        switch (err) {
          case 0:
            goto out;
          case -EACCES:
            flags |= MS_RDONLY;
            goto retry;
          case -EINVAL:
            continue;
        }
        /*
         * Allow the user to distinguish between failed sys_open
         * and bad superblock on root device.
         * and give them a list of the available devices
         */
    #ifdef CONFIG_BLOCK
        __bdevname(ROOT_DEV, b);
    #endif
        printk("VFS: Cannot open root device \"%s\" or %s, retrying in 1s.\n",
          root_device_name, b);
        printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");
    
        printk_all_partitions();
    
        /* wait 1 second and try again */
        current->state = TASK_INTERRUPTIBLE;
        schedule_timeout(HZ);
        goto retry;
    }
    See my kernel options (attachment). Basically, I've enabled pretty much everything starting with CONFIG_USB_STORAGE, CONFIG_BLK_DEV, CONFIG_SCSI, etc.

    My extlinux.conf file looks like this:

    Code:
    DEFAULT linux
     LABEL linux
     SAY Now booting the kernel from EXTLINUX...
     KERNEL /boot/bzImage
     APPEND rw root=/dev/sdb1
    When I boot my embedded system with my USB stick, everything goes fine until I get this:

    Code:
    VFS: Cannot open root device "sdb1" or unknown-block(0,0), retrying in 1s.
    Please append a correct "root=" boot option: here are the available partitions:
    ...
    0820        249088 sdb driver: sd
      0821       249072 sdb1
    So, basically, my USB stick (~250 MB) is correctly detected as sdb1 (thanks to my hack in do_mounts.c), but I still get an error. Previously, the USB stick wasn't even detected and I was getting the usual "Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)" error message and the USB stick wasn't even listed as an available partition.

    ext3 is enabled. I've tried with ext2. Same result.

    I've also tried with grub. Same result.

    What should I do?

    Olivier
    Attached Files Attached Files

  2. #2
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3
    I'd add that I've tried with two different USB devices: a USB stick (4 GB) and a multi-card reader (with a 250 MB SD card). Both lead to the same result ("VFS: Cannot open root device").

  3. #3
    Just Joined!
    Join Date
    Apr 2011
    Posts
    3

    Solution: initramfs

    The solution is *not* to boot from the USB device directly, but to use an initramfs image. More info here:

    sourcemage.org/HowTo/Initramfs
    jootamam.net/howto-initramfs-image.htm

    In the init script, you can easily wait for USB devices before calling switch_root. Example:

    Code:
    try_count=1
    while [ $try_count -le 20 ]
    do
      if [[ -e "${root}" ]] ; then
        break
      fi
      sleep 1
      mdev -s
      let try_count=$try_count+1
      echo -n "."
    done

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •