LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   BOOT TIME - LINUXSHELL vs BOOTLOADER (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/boot-time-linuxshell-vs-bootloader-4175428609/)

elico 09-23-2012 02:14 AM

BOOT TIME - LINUXSHELL vs BOOTLOADER
 
Hi all

At boot time of the linux based target
how is it determined which executable will run ?

If I understood there are 2 methods
BOOTLOADER and linux shell .

Can you explain which to chose and how linux shell
is written ?

Thanks
Elico

konsolebox 09-23-2012 03:26 AM

Hmm.. I'm not sure what specifically it is that you want to know, but you could refer to these pages:

http://www.ibm.com/developerworks/li...y/l-linuxboot/
http://en.wikipedia.org/wiki/Linux_startup_process
http://en.wikipedia.org/wiki/Init

And according to one of those pages
Quote:

In a desktop Linux system, the first application started is commonly /sbin/init. But it need not be. Rarely do embedded systems require the extensive initialization provided by init (as configured through /etc/inittab). In many cases, you can invoke a simple shell script that starts the necessary embedded applications.

elico 09-23-2012 03:32 AM

Thnks
Great links.

" invoke a simple shell script that starts the necessary embedded applications "

How this shell is written , where in the on board linux file system
it is loaded ?

Elico

konsolebox 09-23-2012 04:42 AM

Quote:

Originally Posted by elico (Post 4786965)
How this shell is written , where in the on board linux file system
it is loaded ?

Executed from a file? e.g. /bin/sh or /bin/bash

Or do you mean a real embedded system? I haven't seen one yet but I bet they depend on busybox. Just a guess.

elico 09-23-2012 07:05 AM

I am talking about a LINUX based embedded cared like HAWKBOARF for example.

In that case how the init shell is written ?

What file extenssion ?

Where in the file system is loaded ?

Thanks
Elico

konsolebox 09-23-2012 07:39 AM

Quote:

Originally Posted by elico (Post 4787075)
I am talking about a LINUX based embedded cared like HAWKBOARF for example.

In that case how the init shell is written ?

What file extenssion ?

Where in the file system is loaded ?

Thanks
Elico

Same as files in a normal desktop system probably. /bin/bash has no extension of course. What I mean here is that busybox is a single static binary file that's included in the system's filesystem in an image, or as a cpio package which is then decompressed to ramdisk, and files like /bin/sh are linked to it (busybox) by symbolic links like sh, cp, ls, etc.

Quote:

Where in the file system is loaded
Depends on how the system's working ROM does it. But Linux as I could always remember is always loaded as an image. That image could just contain the kernel or the whole system already which also includes the filesystem. Where that image is placed, either in a firmware or somewhere, that I can't really tell. ~Try to examine small live CDs, and you might get more idea about it.~ Linux is first loaded in a ramdisk, from an image somewhere then everything starts from there.

Btw, I guess you're not really using Linux right now are you?

elico 09-23-2012 03:45 PM

NO I do not
I want to clarify all issues before dive into this dep waters ..

Elico

konsolebox 09-23-2012 05:29 PM

Well sorry but I think the best way to understand it is to use it. I suggest you try setting up a low-level distro like Slackware or LFS. Being scared, too careful, or conservative about Linux won't help either.

elico 09-24-2012 01:14 AM

Thanks
Elico

theNbomr 09-24-2012 11:10 AM

From your question that is asking to distinguish between two completely different things, I think it would be useful to explain what those things are, and what their respective roles are.
A bootloader is the fist piece of code that runs on a newly booted host (except for a BIOS, in some cases). A bootloader is capable of loading an operating system. It may be very simple in nature, such as an MS-DOS bootloader, or complex and full featured such as grub or U-boot. The fact that some bootloaders have an interactive commandline feature makes some people think that they are using a commandline shell, like bash. Such is not the case, however, and in fact when a bootloader runs, there is no underlying OS (because of course, it is the bootloader's job to load the OS).
A shell is a userspace application that runs by the graces of the underlying OS. In Linux, bash is the most common of these. A shell requires an OS to support it's functionality. Indeed, a shell is a way of exposing much of the OS kernel's functionality to the user.
At boot-time, typically three different and distinct bits of code run. In order, the bootloader starts the process of booting, followed by the kernel which is loaded by the bootloader. The bootloader invokes the kernel by loading it into memory, and making a jump to the kernel entry point. The bootloader may set up a RAM-based filesystem for initial use by the kernel. The kernel then pokes around at some hardware and generally configures itself, and prepares to invoke the first userspace process. This first userspace process is called the init process. The name of said process may be hardwired into the kernel, or may be provided to the kernel by the bootloader. It is commonly a dedicated program that reads /etc/inittab, and uses the instruction found there to initialize the rest of the system (including mounting fileystems). It can be any program accessible by the kernel, and having sufficient resources to function on its own (usually meaning it is statically linked). Sometimes, the init process is simply a shell, or shell script. Always, the init process has PID=1, and is therefore the parent of all subsequent processes.

My recommendation for exploring these elements is to set up a virtual machine to load a small simple SO such a TinyCore Linux. Then, you can explore and modify the init system (which I find to be quite elegant and simple), and learn the fundamentals. Doing so will teach you fundamentals that can be applied to both larger, more complex, traditional desktop/server systems, as well as scaled-down embedded systems.

-- rod.

elico 09-24-2012 11:55 AM

Many thanks
Elico


All times are GMT -5. The time now is 06:47 PM.