Does the bootloader load the kernel fully into memory
I read that the bootloader (Grub, or U-boot etc. ) locates the kernel (from maybe the HDD, or even flash memory if it's an embedded system) and loads it into memory on startup.
Now, does this mean that the bootloader loads the kernel fully into available RAM and then passes control to it? My guess is that the kernel will not fully fit into the RAM and so there will be swapping of the kernel instructions from RAM to the storage device and vice-versa.
What I don't understand is, the bootloader has stopped executing at this stage and the kernel has taken over, so how can the bootloader take care about loading the rest of the kernel in and out of memory if it doesn't fully fit at first?
linux memory startup boot-loader
add a comment |
I read that the bootloader (Grub, or U-boot etc. ) locates the kernel (from maybe the HDD, or even flash memory if it's an embedded system) and loads it into memory on startup.
Now, does this mean that the bootloader loads the kernel fully into available RAM and then passes control to it? My guess is that the kernel will not fully fit into the RAM and so there will be swapping of the kernel instructions from RAM to the storage device and vice-versa.
What I don't understand is, the bootloader has stopped executing at this stage and the kernel has taken over, so how can the bootloader take care about loading the rest of the kernel in and out of memory if it doesn't fully fit at first?
linux memory startup boot-loader
add a comment |
I read that the bootloader (Grub, or U-boot etc. ) locates the kernel (from maybe the HDD, or even flash memory if it's an embedded system) and loads it into memory on startup.
Now, does this mean that the bootloader loads the kernel fully into available RAM and then passes control to it? My guess is that the kernel will not fully fit into the RAM and so there will be swapping of the kernel instructions from RAM to the storage device and vice-versa.
What I don't understand is, the bootloader has stopped executing at this stage and the kernel has taken over, so how can the bootloader take care about loading the rest of the kernel in and out of memory if it doesn't fully fit at first?
linux memory startup boot-loader
I read that the bootloader (Grub, or U-boot etc. ) locates the kernel (from maybe the HDD, or even flash memory if it's an embedded system) and loads it into memory on startup.
Now, does this mean that the bootloader loads the kernel fully into available RAM and then passes control to it? My guess is that the kernel will not fully fit into the RAM and so there will be swapping of the kernel instructions from RAM to the storage device and vice-versa.
What I don't understand is, the bootloader has stopped executing at this stage and the kernel has taken over, so how can the bootloader take care about loading the rest of the kernel in and out of memory if it doesn't fully fit at first?
linux memory startup boot-loader
linux memory startup boot-loader
edited Dec 18 '18 at 23:12
asked Dec 18 '18 at 22:55
Engineer999
1143
1143
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The kernel is fully loaded into RAM on startup, and it is not swapped. The kernel does not know and does not care where it is loaded from. It could be loaded from the network, and it is hard to swap over tftp.
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
add a comment |
It's more accurate to say that the bootloader loads the entirety of what it's told to load as the kernel into memory. it doesn't really have to be the kernel itself, it could be a second-stage bootloader (and in most cases, this is actually what's technically happening, because GRUB jumps to a decompression routine that extracts the real kernel), or it could be a type-1 hypervisor which then loads and executes the Linux kernel.
Put simply, it all has to fit in memory and have enough space left over for things like userspace, or the system can't boot (this is part of why it's so hard to build a Linux system that runs with less than about 64M of RAM these days). The same can be said about every other UNIX system I know of (SVR4, BSD, Solaris, IRIX, Ultrix, Xenix, etc). It's just too much of a pain to handle swapping of memory in kernel-space for it to be worth implementing.
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489787%2fdoes-the-bootloader-load-the-kernel-fully-into-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The kernel is fully loaded into RAM on startup, and it is not swapped. The kernel does not know and does not care where it is loaded from. It could be loaded from the network, and it is hard to swap over tftp.
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
add a comment |
The kernel is fully loaded into RAM on startup, and it is not swapped. The kernel does not know and does not care where it is loaded from. It could be loaded from the network, and it is hard to swap over tftp.
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
add a comment |
The kernel is fully loaded into RAM on startup, and it is not swapped. The kernel does not know and does not care where it is loaded from. It could be loaded from the network, and it is hard to swap over tftp.
The kernel is fully loaded into RAM on startup, and it is not swapped. The kernel does not know and does not care where it is loaded from. It could be loaded from the network, and it is hard to swap over tftp.
answered Dec 19 '18 at 7:04
Johan Myréen
7,44011524
7,44011524
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
add a comment |
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
You could sell t-shirts with “it is hard to swap over tftp”! 🤣
– Stephen Kitt
Dec 19 '18 at 7:07
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
Where does virtual memory come into all this?
– Engineer999
Dec 19 '18 at 21:57
add a comment |
It's more accurate to say that the bootloader loads the entirety of what it's told to load as the kernel into memory. it doesn't really have to be the kernel itself, it could be a second-stage bootloader (and in most cases, this is actually what's technically happening, because GRUB jumps to a decompression routine that extracts the real kernel), or it could be a type-1 hypervisor which then loads and executes the Linux kernel.
Put simply, it all has to fit in memory and have enough space left over for things like userspace, or the system can't boot (this is part of why it's so hard to build a Linux system that runs with less than about 64M of RAM these days). The same can be said about every other UNIX system I know of (SVR4, BSD, Solaris, IRIX, Ultrix, Xenix, etc). It's just too much of a pain to handle swapping of memory in kernel-space for it to be worth implementing.
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
add a comment |
It's more accurate to say that the bootloader loads the entirety of what it's told to load as the kernel into memory. it doesn't really have to be the kernel itself, it could be a second-stage bootloader (and in most cases, this is actually what's technically happening, because GRUB jumps to a decompression routine that extracts the real kernel), or it could be a type-1 hypervisor which then loads and executes the Linux kernel.
Put simply, it all has to fit in memory and have enough space left over for things like userspace, or the system can't boot (this is part of why it's so hard to build a Linux system that runs with less than about 64M of RAM these days). The same can be said about every other UNIX system I know of (SVR4, BSD, Solaris, IRIX, Ultrix, Xenix, etc). It's just too much of a pain to handle swapping of memory in kernel-space for it to be worth implementing.
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
add a comment |
It's more accurate to say that the bootloader loads the entirety of what it's told to load as the kernel into memory. it doesn't really have to be the kernel itself, it could be a second-stage bootloader (and in most cases, this is actually what's technically happening, because GRUB jumps to a decompression routine that extracts the real kernel), or it could be a type-1 hypervisor which then loads and executes the Linux kernel.
Put simply, it all has to fit in memory and have enough space left over for things like userspace, or the system can't boot (this is part of why it's so hard to build a Linux system that runs with less than about 64M of RAM these days). The same can be said about every other UNIX system I know of (SVR4, BSD, Solaris, IRIX, Ultrix, Xenix, etc). It's just too much of a pain to handle swapping of memory in kernel-space for it to be worth implementing.
It's more accurate to say that the bootloader loads the entirety of what it's told to load as the kernel into memory. it doesn't really have to be the kernel itself, it could be a second-stage bootloader (and in most cases, this is actually what's technically happening, because GRUB jumps to a decompression routine that extracts the real kernel), or it could be a type-1 hypervisor which then loads and executes the Linux kernel.
Put simply, it all has to fit in memory and have enough space left over for things like userspace, or the system can't boot (this is part of why it's so hard to build a Linux system that runs with less than about 64M of RAM these days). The same can be said about every other UNIX system I know of (SVR4, BSD, Solaris, IRIX, Ultrix, Xenix, etc). It's just too much of a pain to handle swapping of memory in kernel-space for it to be worth implementing.
answered Dec 19 '18 at 20:27
Austin Hemmelgarn
5,99111016
5,99111016
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
add a comment |
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
could you explain where virtual memory and the MMU comes into all this then?
– Engineer999
Dec 19 '18 at 21:58
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
The kernel itself provides all the abstractions for virtual memory, both those used internally and those for userspace. GRUB intentionally doesn't use virtual memory (because it would have to stick around in the background to keep providing it, which is not what a bootloader is for), and a lot of the early startup code in the kernel doesn't either because there are somethings that really do just need to be done before setting up virtual memory.
– Austin Hemmelgarn
Dec 20 '18 at 12:38
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489787%2fdoes-the-bootloader-load-the-kernel-fully-into-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown