LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-17-2011, 10:35 AM   #1
persson121
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Rep: Reputation: 0
How do make an initrd file?


Hello.

I have compiled the linux kernel. My bzImage is 1,14 mb big

Anyway. It's only 2 programs i need and it's Python and Busybox. I have compiled python and busybox and put them together in a folder. Busybox is 146 kb and pyton is 4,4 mb.

But how do i make an initrd file of them? Or should a make an initrd file of them?

I get this error when a runt with a compiled busybox to gz format as initrd, and without initrd.

Quote:
VFS: Cannot open root device "sda1" or unknow-block(0,0)
Please append a correct "root=" boot option; here are the available partions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)Pid: 1, comm: swapper Not tainted 2.6.38.3 #1
Do you know how to make an initrd?
 
Old 04-17-2011, 01:02 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It is probably beyond the scope of this forum to explain all of the details of such an endeavor. When I Google searched for 'How do make an initrd file', I got over 400,000 hits, of which the first 20 or so looked like they were pretty clearly on topic. Maybe you could try that, and if there are aspects that are still not clear, ask here.

In general, an initrd is a compressed cpio archive. The bootloader uses it to create a RAM disk, and then tells the kernel where to find the RAM disk. You haven't said anything about the system architecture on which you are building the initrd, nor about the system architecture for the target host. These are both germane to the subject.

An initrd is usually used in one of two cases. If the host lacks any other form of block media, then it can run entirely from a RAM disk. This will usually result in a fast boot time, but no non-volatile storage. Emebdded systems sometimes use this. Another use-case is for a kernel that is generic with respect to supported hardware, and the initrd supplies the necessary kernel drivers for the specific host, in order to perform a more complete boot. This is a common practice for desktop and server oriented hosts. Your application seems to lean toward the former case.

--- rod.
 
Old 04-17-2011, 01:26 PM   #3
persson121
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr View Post
It is probably beyond the scope of this forum to explain all of the details of such an endeavor. When I Google searched for 'How do make an initrd file', I got over 400,000 hits, of which the first 20 or so looked like they were pretty clearly on topic. Maybe you could try that, and if there are aspects that are still not clear, ask here.

In general, an initrd is a compressed cpio archive. The bootloader uses it to create a RAM disk, and then tells the kernel where to find the RAM disk. You haven't said anything about the system architecture on which you are building the initrd, nor about the system architecture for the target host. These are both germane to the subject.

An initrd is usually used in one of two cases. If the host lacks any other form of block media, then it can run entirely from a RAM disk. This will usually result in a fast boot time, but no non-volatile storage. Emebdded systems sometimes use this. Another use-case is for a kernel that is generic with respect to supported hardware, and the initrd supplies the necessary kernel drivers for the specific host, in order to perform a more complete boot. This is a common practice for desktop and server oriented hosts. Your application seems to lean toward the former case.

--- rod.
Yea, i know that. But how do make it - dono?

Can i make a init file. Just a file. The file contains with...
Quote:
#!/bin/busybox sh
mkdir -p /dev /proc /sys
mount -t devtmpfs devfs /dev
mkdir -p /dev/pts
mount -t devpts ptsfs /dev/pts
mount -t proc procfs /proc
mount -t sysfs sysfs /sys
exec /bin/busybox sh
Then i write to make busybox to an initrd file?
Quote:
find | cpio --quiet -H newc -o | gzip -9 -n > /way/to/usb/boot/initramfs.cpio.gz
 
Old 04-17-2011, 05:05 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
An initrd usually must contain enough of a filesystem to be mounted as a root filesystem. So, no, you cannot just make it a shell script. The shell script is referring to all sorts of things. Where do you think the kernel will find any of the files you reference in the script? The answer must be that it is in the filesystem, which IS the initrd.
Perhaps if you find an existing initrd, and unroll its contents, you will be able to see what form to follow.

--- rod.
 
Old 04-17-2011, 05:42 PM   #5
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
@ Original Poster:

1. You are very well on the right track. You should make links in bin/ of your initrd to all of the busybox modules, so that there is a mount command present that you have mentioned in your init script.

2. You have to satisfy dependencies for dynamic executables, i.e
Code:
[djshaji@darkstar ~]$ ldd /usr/bin/python
	linux-gate.so.1 =>  (0xffffe000)
	libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0xb76d3000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb76b8000)
	libdl.so.2 => /lib/libdl.so.2 (0xb76b3000)
	libutil.so.1 => /lib/libutil.so.1 (0xb76af000)
	libm.so.6 => /lib/libm.so.6 (0xb7684000)
	libc.so.6 => /lib/libc.so.6 (0xb74fa000)
	/lib/ld-linux.so.2 (0xb7895000)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make initrd that contains root file system? Caldus Linux - Software 5 05-19-2010 10:33 PM
How to create new initrd.gz (or initrd.img) file? kkpal Programming 2 12-10-2007 08:38 AM
making kernel RPM. does not make initrd file mindcry Linux - Software 5 08-12-2004 10:20 PM
initrd how to make one? watashiwaotaku7 Linux - General 18 03-19-2004 11:53 PM
How do you make a initrd and vmlinux file? britishnemesis Linux - General 10 11-03-2003 09:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration