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 05-18-2012, 03:46 PM   #1
0x53h
LQ Newbie
 
Registered: May 2012
Posts: 23

Rep: Reputation: Disabled
Boot process; execution of init; initramfs


This is my first post, so please point me in the right direction if needed. My studies have focused on embedded systems and right now gaining a full understanding of the Linux boot process. I would like to be able to create a BusyBox environment mostly from scratch.

My understanding so far is that after the kernel loads, init is executed. The default location of init is /sbin/init. The BusyBox faq states that you should be able to statically compile a simple 'Hello World' program and use it in place of init to see the message displayed.

1. Is it true that a statically compiled Hello World program should execute at the end of the kernel loading if I simply place it in /sbin/init (or point to it with an init=/sbin/init boot parameter)? Because that hasn't worked for me yet.

2. In beginning to research this problem I've come across how-to documents showing the creation if an initramfs. I don't want to go down a deprecated path again; done that too many times. Is initramfs still relevant?

Any additional sage advice would be super-appreciated. I've spent a week learning so much already, but could definitely have used guidance in avoiding some of the outdated materials I've found.
 
Old 05-18-2012, 05:12 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,345

Rep: Reputation: Disabled
Don't know if this qualifies as "sage advice", but the boot process works like this:
  1. A boot loader loads the Linux kernel file into memory. It may also load an initrd/initramfs image, depending on the configuration.
  2. The boot loader executes the kernel file, possibly also passing on some boot parameters.
  3. The kernel file decompresses itself, and initializes the hardware. Devices are served by built-in drivers, if available.
  4. The kernel attempts to mount the root file system. The name of the root device may have been given as a parameter by the boot loader. If not, defaults given at compile time are used. The root device may be a physical disk or the file system from step 1. The file system driver must be compiled into the kernel for this to work.
  5. Assuming the previous step succeded, /sbin/init is executed. I've heard rumours that some systems with initrds start /linuxrc instead, but my Slackware initrd uses the standard /sbin/init.
And yes, using a statically compiled "Hello world" executable as /sbin/init should work (for very small quantities of "work").

Initramfs is just a (compressed) cpio archive that gets copied to a tempfs file system in RAM and then used as a root file system. It's an alternative to the older initrd concept, where a (compressed) image file containing a file system is used. Since initramfs is the more recent of the two, it's not likely to be deprecated any time soon (but then neither is initrd).
 
Old 05-19-2012, 11:26 AM   #3
0x53h
LQ Newbie
 
Registered: May 2012
Posts: 23

Original Poster
Rep: Reputation: Disabled
It does work! At least, as you described, for limited quantities of "work". I had been compiling on a 64-bit system, but booting x86. The kernel only complains that init couldn't be found and to try passing the init= parameter; not a mention about inability to run. Thank you - I had been questioning whether the file system was mounting, I was putting the file in the wrong place, everything - you helped narrow it down.

I'll have to look further into the differences between the two (initramfs and initrd) to evaluate which would be a better fit for the hardware I'm targeting.
 
  


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
[SOLVED] what will happen if init dies during boot process? redhat2010@rocketmail.co Linux - Newbie 2 02-20-2010 02:59 AM
how modify initramfs...init script bluepenguine Linux - Embedded & Single-board computer 3 07-31-2009 04:34 AM
Cant find /init during PowerPC initramfs boot kermitG Linux - Embedded & Single-board computer 1 02-16-2009 09:59 AM
Bug in initramfs /init detected while booting from Fedora 9 liveusb nikhil010586 Linux - Newbie 1 09-16-2008 12:54 PM
[SOLVED] Optimize slack boot process / init scripts ? H_TeXMeX_H Slackware 73 10-12-2007 04:47 AM

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

All times are GMT -5. The time now is 10:35 PM.

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