Copying a working Linux installation from SATA drive to USB flash drive(doesn't work)

Goi

Diamond Member
Oct 10, 1999
6,768
7
91
Hi,

I have a custom linux environment with a 2.6 kernel downloaded from kernel.org with a simple busybox shell as init. The system boots off a SATA drive with root=/dev/sda with lilo, and it works perfectly.

I recently tried to achieve the same thing on a USB flash drive by simply dd-ing the SATA drive partition contents to the flash drive, but I'm getting the following error when booting up:

Code:
VFS: Cannot open root device "801" or unknown-block(8,1)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)
Pid: 1, comm: swapper not tainted 2.6.35.14 #1

I only have a single flash drive plugged into the USB port, with no other SATA/IDE drives connected. AFAIK, that makes the flash drive /dev/sda, which translates to 801, so why isn't it booting up correctly?

My aim is to have a USB stick that boots up very quickly to a busybox shell, with nothing displayed to the screen till the shell, and with no GUI at all. All the Linux distros that I've seen for USB sticks are too complex.

Thanks.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It saying unknown block implies that the drivers aren't loaded so it doesn't know what driver it should use to handle /dev/sda (major 8, minor 1). Do you see the USB modules load and attempt to detect the drive before the panic? You may need a script that just loops waiting for /dev/sda to appear before kicking off init.
 

Goi

Diamond Member
Oct 10, 1999
6,768
7
91
I thought about that, but I'm not sure how to see if the drivers have been loaded. My screen only holds that many lines before the kernel panic. I actually don't have an init program - my environment is so simple that I get lilo to run the busybox shell as init. Correct me if I'm wrong since I'm a bit fuzzy on the linux bootup process, but since it's a kernel panic at this stage, I don't think init is even run yet?
 

Goi

Diamond Member
Oct 10, 1999
6,768
7
91
OK, I figured out one part of the problem - USB Mass Storage drivers were not built into the original kernel. I booted up from the old kernel in a SATA drive, then plugged in a USB flash drive, and while it was detected as a USB device, fdisk couldn't see it.

I then rebuilt the kernel with USB Mass Storage driver support, and now in the same boot scenario I can see it as /dev/sdb.

However, dd-ing the disk image to a USB flash drive and booting up from it produced the same kernel panic message, so I'm pretty much back to my original problem.

Any advice?

Thanks.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I haven't been keeping up with lkml lately, but statically built modules weren't recommended and had odd side effects the last time I did look. You probably want to look into how to build a custom initramfs.