OpenWrt Forum Archive

Topic: Editing kernel command line

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

How do I edit the kernel command line of an image? (Or how to build an image with a custom kernel command line.)

Setting the nvram variable kernel_args should do the job.

Or directly modify the kernel configuration file located in target/linux/<your arch>/config

I tried setting the variable but it didn't work.
In "target/linux", the folders are "control", "image", imagebuilder", "linux-2.4", and "package". In "linux-2.4/config" are 3 files named "brcm", "brcm~", and "brcm.modules". I tried opening all three and neither file seems to have the kernel command line. What do I do? (I use whiterussian RC5.)

At least I got the router to see my USB Flash drive! So for now, I can get the router to detect the drive but not boot from it. I got close, though!

From : target/linux/linux-2.4/config/brcm

CONFIG_CMDLINE="root=/dev/mtdblock2 rootfstype=squashfs,jffs2 init=/etc/preinit noinitrd console=ttyS0,115200"

I got it edited (and the router acknowledges the change), but it still doesn't want to boot. Under what device name does a USB drive show up as? (I tried "/dev/sda".)

Usually, you have formatted your USB device, so it mus be something valid such as /dev/sda1, sda2 or anything else according to your partition table.

Try plugging your device in a linux or unix-like computer and see which partition seems to be mountable

There is no partition table on the drive. On a PC, it shows up as "/dev/sda". It's formatted as ext3, which I have enabled support for in the kernel.
I think the problem is the delay. It takes a few seconds for the drive to initialize. How do I make the router wait before trying to mount the drive?

Just a quick thought: Have you actually built in in all the necessary options into you kernel (usb, usb-storage, scsi, ext3)? Your drive will also get recognized if these are built as modules; but these modules are of course not available before mounting the rootfs.

Yes, I did do that. The router actually loads the USB and mass storage drivers but crashes before the drive initializes. The delay between the driver loading and the kernel panic message is very small - about 1/8 of a second or so, which is clearly not enough. The drive takes about 7 seconds to initialize when plugged into a regular Linux system. (I'll set a delay of maybe 10-15 seconds to ensure reliability, or better yet, have it wait until the drive is detected.)
So, I'll just need to know how to set a delay before mounting the drive and I'll continue to work from there. If I get it to work, I'll post the complete guide!

EDIT: I just thought about an alternate solution.
Put a ramdisk image on the router Flash somehow, which the router will first boot to. In the image will be a shell script that will keep on trying to mount the USB drive until it mounts. Then it switches root to the USB drive, gets rid of the ramdisk, and continues to boot as usual.
If a certain keystroke (thinking Ctrl-C) is typed as it is in the "USB bootloader", it provides a simple user interface for troubleshooting (e.g. cut down versions of lsusb and a few basic UNIX commands).

(Last edited by star882 on 10 Jul 2006, 05:56)

With 2.6 kernels, setting the delay is easy: rootdelay=10 would make a 10-sec delay before kernel attempts to mount the rootfs.
It's sufficent for most USB devices.

With 2.4 kernels it's more problematic, and to have the same effect, the kernel needs patching.

I just compiled the 2.6 kernel (kamikaze), and I couldn't get it to boot even with the delay. Can someone post a cut down OpenWRT image that runs on a Belkin v2000? I suspect a wiring mistake or something. I'll try to get it to work after bootup before trying to make the router boot from the drive.

The discussion might have continued from here.