Linux - GeneralThis 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
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Depends. There are several. The one most people use these days is GRUB, which will boot Windows too. Old-fashioned people like me use LILO which won't boot any modern Windows. Then there's syslinux, which is used mainly for usb memory sticks and its cousin isolinux which is used for Cds and DVDs. And that's just for traditional BIOS booting. For UEFI, you can use GRUB again or ELILO, or just use a self-booting kernel .
Or are you talking about after booting when the system is already running? In that case, the answer is the kernel. A process requests to fork off another process and the kernel creates a task structure for it. The child process requests to execute a new program and the kernel loads it.
TheLInux LOader is LILO. GRUB has replaced it in the great majority of distros. Slackware still defaults to LILO, but offers GRUB as an alternative.
Every OS has a boot loader. Operating systems that expect never to share the computer, such as Windows and MacOS, just don't let it come to the screen. Never versions of Ubuntu hide the GRUB menu unless Ubuntu is installed for dual-booting.
Last edited by frankbell; 10-17-2019 at 07:50 PM.
Reason: More information
The only ressource I found so far that *explicitly* uses the term "loader" and clearly defines what it is, is this technical article from Embedded Artistry (annotated link) :
Quote:
On Linux or OS X, the loader is a function in the exec() family typically execve() or execvp().
@dugan
The lwn article you linked to : I've already skimmed through it sarching for "loader", but since I couldn't find any result I just skipped it. But since you mentioned it in your post I've searched it again, this time for just "load", and found this sentence :
Quote:
Loading an ELF binary is handled by the load_elf_binary() function,
Neither articles mention *fork* as being *the* loader or part of the loader, I think fork happens before the actual loading.
So is it the exec system call or is it the load_elf_binary internal kernel function ? or maybe exec calls load_elf_binary ?
Searching further, I also found this article from linuxjournal, mistakingly calling execve "a program"
Quote:
The loader is a program called execve, which loads the code and data of the executable object file into memory and then runs the program by jumping to the first instruction.
Neither articles mention *fork* as being *the* loader or part of the loader, I think fork happens before the actual loading.
So is it the exec system call or is it the load_elf_binary internal kernel function ? or maybe exec calls load_elf_binary ?
OK, let's take it in steps. First of all both fork and execve are system calls: that is they are functions called by a program in user space but executed by the kernel. While the kernel is executing them, the user process halts.
Fork causes the kernel to duplicate the task structure for the process. The task structure is a data structure inside the kernel which contains everything the kernel knows about that process. The first field is the process's unique ID (PID) and the second is the PID of the parent process (PPID). Other fields include a link to the executing program, a link to the current working directory, a link to the process's memory map, fields for user and group IDs, and one for environmental variables. There are also dynamic fields like elapsed time and core time. When the task structure is first created, most of these fields are simple duplicates of those in the parent's task structure, but there is a new PID and PPID, and all the time fields are zeroed.
The child process then calls execve (or a C-library wrapper for it like execv or execl) and this causes the link to the currently executing program to be replaced by one to the new program. A new memory map is created and the first page of the new program's executable image is loaded. Et voila!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.