Problem booting barebone Linux kernel vmlinux with initramfs
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Problem booting barebone Linux kernel vmlinux with initramfs
*** Could someone please help me with this issue or point me to the right forum for this question? ***
I have stuck with this issues for the past few days and I hope someone can shed some lights on my problem. I’m trying to load x86 Linux kernel onto an x86-based router. Unlike regular PC, the BIOS is merged with a home-grown bootloader called Rommon which will take the place of GRUB to boot Linux. The router doesn’t have any hard drive, so I’m using initramfs as our root file system.
I checked out the latest kernel code from linux.org version 2.6.31 and compiled to vmlinux image. Separately, I create my own initramfs and prepare the initramfs.cpio file. To bundle both of them, I do “make menuconfig” and include the path to my initramfs.cpio (/ws/initramfs.cpio) to Initramfs source file.
General Setup --->[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
() Initramfs source file(s)
As for the boot command, I used “root=/dev/ram rw console=ttyS0,9600” but I keep getting this error message:
…
serial8250: ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A
Platform driver 'serial8250' needs updating - please use dev_pm_ops
brd: module loaded
loop: module loaded
nbd: registered device at major 43
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
i8042.c: No controller found.
mice: PS/2 mouse device common for all mice
i2c /dev entries driver
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
Using IPI No-Shortcut mode
ramdisk_ecxecute_command = /init
Freeing unused kernel memory: 2112k freed
Warning: unable to open an initial console.
Failed to execute /init
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
Pid: 1, comm: swapper Not tainted 2.6.31-rc2 #24
Call Trace:
[<c12849a0>] ? kernel_init+0x0/0xb0
[<c102b662>] ? panic+0x42/0xf0
[<c12849a0>] ? kernel_init+0x0/0xb0
Clocksource tsc unstable (delta = 550368123 ns)
[<c10012ad>] ? init_post+0xad/0x120
[<c1284a31>] ? kernel_init+0x91/0xb0
[<c100395f>] ? kernel_thread_helper+0x7/0x18
Changing the boot parameter to “root=/dev/ram rw init=/sbin/init console=ttyS0,9600” also didn’t work. The init script is at the top level of my rootfs. I'm not sure why it couldn't find it to execute. Does anyone know what I did wrong and how to fix it? Any suggestion is greatly appreciated.
Last edited by huyhoang3673; 08-10-2009 at 01:38 AM.
Reason: No response in 48 hours
Can someone please help me with this issue or point me to another forum that can help me resolve this issue? It's been 3 days and I got no reply for this issue. There must be many Linux guru out there who can help me with this.
Yes, I have Busybox in the /bin directory of my rootfs. This /bin directory along with other directories /proc /dev /etc ... are packaged into initramfs.cpio and bundled with vmlinux image.
How can I move my question to other forums that you suggested? The rules said I can't double post the question. the admin has to move it for me but who is the admin?
You can click on the "Report" button and ask that your post be moved, but there's no guarantee that someone will read your post there that hasn't read it already, here. It's worth trying, though.
Is this some version of OpenWRT? You might want to check the forums at https://forum.openwrt.org/, as they will be more focused on this type of system.
I had the same problem. My solutions were as follows:
Put bash in the /bin directory. Since I didn't have a static binary version of it floating around, I simply copied the binary as well as the associated libraries to /lib. Don't forget to run:
Quote:
ldconfig -r /path/to/rootfs -c /etc/ld.so.cache
If you want networking, you'll need to install more libraries (as described in the man page). NOTE: I'm sure you can use ash (instead of bash), I just wanted to get it working. Now that is, I can spend the time getting it working with ash.
Make a symlink for the bin directories that busybox wants to install into:
Start your /init so the general flow is the following:
Quote:
#!/bin/bash
mount -t proc /proc /proc
mount -t sysfs /sys /sys
/bin/busybox --install -s
rm -f /linuxrc # created by busybox
# do whatever here
exec /bin/bash
Make sure all copied libraries are executable
Make sure all scripts/binaries needed are executable
And finally, to test your setup, chroot into the environment and test your init script. If you receive any errors, then start up won't work as well.
Quote:
chroot /path/to/rootfs
Last edited by raxip; 08-13-2009 at 03:37 PM.
Reason: Fixed ldconfig command and added additional steps.
All other directories are empty.
Here is the content of my init script:
#!/bin/bash
#Mount things needed by this script
mount -t proc proc /proc
mount -t sysfs sysfs /sys
#Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk
#Clear the screen
clear
#Create all the symlinks to /bin/busybox
busybox --install -s
#Create device nodes
mknod /dev/null c 1 3
mknod /dev/tty c 5 0
mdev -s
exec /bin/bash
But I got error when I run the "chroot" command:
[root@ngd-build1]# chroot root_fs
chroot: cannot run command `/bin/bash': Permission denied
What did I do wrong? What do you expect after running "chroot". How do you bundle this rootfs into Linux kernel? Or what do you have to specify so that when Linux boot up, it uses the rootfs that you created?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.