Why don't we include File System drivers in the kernel itself instead of using Initrd/Initramfs

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















The Linux kernel contains very minimal code that is necessary to boot on a majority of devices but I don't get the point of having Initrd/Initramfs.
As far as I've understood Initrd/Initramfs job is to temporary provide the file system drivers to actually load the root file system.

If this the case, then why don't we simply add the necessary file system drivers into the kernel itself.
We have to ultimately load both the kernel and the Initrd/Initramfs so why no integrate both into one image file since both of them take the same amount of memory.




*******Update******



1. What actually constitutes the linux kernel? Is it just the vmlinuz image(approximately 5-6MB) or the collection of loadable modules,vmlinuz image, initrd file and other components.


2. Why is the size of the kernel image vmlinuz(approx 5-6MB) less than size of initrd file(approx 18MB). The kernel contains the code for many other things as compared to initrd that just contains code to mount the File system.










share|improve this question
























  • When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

    – supriady
    Dec 26 '16 at 13:54











  • @supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:59











  • You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

    – supriady
    Dec 26 '16 at 14:11











  • When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

    – supriady
    Dec 26 '16 at 14:18

















2















The Linux kernel contains very minimal code that is necessary to boot on a majority of devices but I don't get the point of having Initrd/Initramfs.
As far as I've understood Initrd/Initramfs job is to temporary provide the file system drivers to actually load the root file system.

If this the case, then why don't we simply add the necessary file system drivers into the kernel itself.
We have to ultimately load both the kernel and the Initrd/Initramfs so why no integrate both into one image file since both of them take the same amount of memory.




*******Update******



1. What actually constitutes the linux kernel? Is it just the vmlinuz image(approximately 5-6MB) or the collection of loadable modules,vmlinuz image, initrd file and other components.


2. Why is the size of the kernel image vmlinuz(approx 5-6MB) less than size of initrd file(approx 18MB). The kernel contains the code for many other things as compared to initrd that just contains code to mount the File system.










share|improve this question
























  • When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

    – supriady
    Dec 26 '16 at 13:54











  • @supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:59











  • You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

    – supriady
    Dec 26 '16 at 14:11











  • When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

    – supriady
    Dec 26 '16 at 14:18













2












2








2


2






The Linux kernel contains very minimal code that is necessary to boot on a majority of devices but I don't get the point of having Initrd/Initramfs.
As far as I've understood Initrd/Initramfs job is to temporary provide the file system drivers to actually load the root file system.

If this the case, then why don't we simply add the necessary file system drivers into the kernel itself.
We have to ultimately load both the kernel and the Initrd/Initramfs so why no integrate both into one image file since both of them take the same amount of memory.




*******Update******



1. What actually constitutes the linux kernel? Is it just the vmlinuz image(approximately 5-6MB) or the collection of loadable modules,vmlinuz image, initrd file and other components.


2. Why is the size of the kernel image vmlinuz(approx 5-6MB) less than size of initrd file(approx 18MB). The kernel contains the code for many other things as compared to initrd that just contains code to mount the File system.










share|improve this question
















The Linux kernel contains very minimal code that is necessary to boot on a majority of devices but I don't get the point of having Initrd/Initramfs.
As far as I've understood Initrd/Initramfs job is to temporary provide the file system drivers to actually load the root file system.

If this the case, then why don't we simply add the necessary file system drivers into the kernel itself.
We have to ultimately load both the kernel and the Initrd/Initramfs so why no integrate both into one image file since both of them take the same amount of memory.




*******Update******



1. What actually constitutes the linux kernel? Is it just the vmlinuz image(approximately 5-6MB) or the collection of loadable modules,vmlinuz image, initrd file and other components.


2. Why is the size of the kernel image vmlinuz(approx 5-6MB) less than size of initrd file(approx 18MB). The kernel contains the code for many other things as compared to initrd that just contains code to mount the File system.







boot linux-kernel initramfs initrd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 14:04









Rui F Ribeiro

41.9k1483142




41.9k1483142










asked Dec 26 '16 at 13:22









Shivam aggarwalShivam aggarwal

13116




13116












  • When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

    – supriady
    Dec 26 '16 at 13:54











  • @supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:59











  • You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

    – supriady
    Dec 26 '16 at 14:11











  • When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

    – supriady
    Dec 26 '16 at 14:18

















  • When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

    – supriady
    Dec 26 '16 at 13:54











  • @supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:59











  • You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

    – supriady
    Dec 26 '16 at 14:11











  • When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

    – supriady
    Dec 26 '16 at 14:18
















When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

– supriady
Dec 26 '16 at 13:54





When you talked about kernel.You should talk the whole kernel process.Linux kernel is having kernel config, system.map, vmlinuz and initramfs also /lib/modules/kernel-version.All linux drivers are in /lib/modules/kernel-version/fs. When you enabled file system driver on kernel config. Kernel will load file system driver automatically without do modprobe command. Linux Kernel is not just initrd/initramfs.

– supriady
Dec 26 '16 at 13:54













@supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

– Shivam aggarwal
Dec 26 '16 at 13:59





@supriady I'm a bit confused now. What exactly is Linux kernel, is it just the vmlinuz image file or all the above components you mentioned. If it constitutes all of the above modules then why is said that linux kernel is so small ? Including these files would take up large memory.

– Shivam aggarwal
Dec 26 '16 at 13:59













You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

– supriady
Dec 26 '16 at 14:11





You can search about linux kernel when you want a detail information. When you read about how to build linux kernel from source code. You will understand about linux kernel.

– supriady
Dec 26 '16 at 14:11













When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

– supriady
Dec 26 '16 at 14:18





When you enabled all drivers on kernel.Kernel would take up large memory.Kernel 4.x contains 5 millions source code.Linux kernel is so small when you used embedded linux like vanilla kernel on android.

– supriady
Dec 26 '16 at 14:18










2 Answers
2






active

oldest

votes


















2














First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.



Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.



The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.



I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.



Answer to edits:



  1. It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.


  2. Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.






share|improve this answer

























  • Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:56






  • 2





    @Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

    – Olivier
    Dec 26 '16 at 14:36












  • what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

    – Shivam aggarwal
    Dec 26 '16 at 14:48











  • You've now made the question too broad unfortunately.

    – Philip Kendall
    Dec 26 '16 at 15:33






  • 1





    @Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

    – Olivier
    Dec 27 '16 at 13:47


















2














It's a bit of a chicken and the egg problem... You can (and usually should) let lots of your drivers be modules, it keep your kernel lean and saves memory (until and if you need the module). However you do need some drivers built into your kernel - specifically for whatever device your booting from (eg. CD-ROM drive, HDD, ...), the filesystem used (eg. iso9660, ext4, ...), and any additional drivers needed to support this (eg. USB-support, SCSI-support, ...). If you don't, your kernel won't be able to access the medium and the filesystem where the modules for additional drivers resides, and thus can't load them into the kernel.



If you make a customized kernel for your own system - where you know in advance what hardware (HDD-type, DVD-drive type, etc.) you've got - this is not a problem. You just need drivers for what you actually got or think you may need. And you only need to include into the kernel, the drivers needed at boot-time.



However, if your making an install-disc for a distro, you must include drivers for all possible hardware users are likely to encounter! Including them all to the kernel, would make the kernel hopelessly bloated and it would take too much RAM on low-end systems. Making all drivers modules won't work, because the modules may be needed for loading them. The solution is initrd!



initrd is the image of a RAM-disk that is loaded into memory at start. All drivers likely to be needed lays on this as modules. As long as the kernel includes drivers to read a DVD, to read the filesystem on a DVD, and to read a RAM-disk; it will be able to access and load on demand the driver-modules from the initrd. This solves the problem for those who makes distros to make the kernel both small and include drivers for every hardware it may run on.



Most users probably keep using initrd-boot after they've installed Linux on their harddrives... This is not really neccessery, as they could build a custom-kernel - perhaps with additional kernel-modules - customized for the hardware they actually got. The two-step process of first loading the initrd, takes a bit of extra time during boot.






share|improve this answer























  • But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

    – Shivam aggarwal
    Dec 26 '16 at 15:51






  • 1





    You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

    – Johan Myréen
    Dec 26 '16 at 22:44











  • @JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

    – Shivam aggarwal
    Dec 27 '16 at 11:35







  • 1





    Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

    – Johan Myréen
    Dec 27 '16 at 12:30











  • @JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

    – Shivam aggarwal
    Dec 27 '16 at 15:57











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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f332817%2fwhy-dont-we-include-file-system-drivers-in-the-kernel-itself-instead-of-using-i%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









2














First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.



Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.



The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.



I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.



Answer to edits:



  1. It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.


  2. Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.






share|improve this answer

























  • Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:56






  • 2





    @Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

    – Olivier
    Dec 26 '16 at 14:36












  • what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

    – Shivam aggarwal
    Dec 26 '16 at 14:48











  • You've now made the question too broad unfortunately.

    – Philip Kendall
    Dec 26 '16 at 15:33






  • 1





    @Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

    – Olivier
    Dec 27 '16 at 13:47















2














First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.



Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.



The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.



I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.



Answer to edits:



  1. It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.


  2. Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.






share|improve this answer

























  • Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:56






  • 2





    @Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

    – Olivier
    Dec 26 '16 at 14:36












  • what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

    – Shivam aggarwal
    Dec 26 '16 at 14:48











  • You've now made the question too broad unfortunately.

    – Philip Kendall
    Dec 26 '16 at 15:33






  • 1





    @Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

    – Olivier
    Dec 27 '16 at 13:47













2












2








2







First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.



Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.



The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.



I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.



Answer to edits:



  1. It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.


  2. Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.






share|improve this answer















First, it's not just the filesystem drivers. It's also the drivers for whatever storage device the filesystem is on. And possibly more if you use LVM, encryption, etc.



Regardless, it's definitely possible to build them into the kernel. I know slackware at least has a kernel choice named 'huge' which does just that and does not require an initramfs for typical PC hardware.



The downside is that such a kernel has to include everything anyone might possibly need: every possible filesystem that might be used as root, the device drivers for whatever might hold that filesystem, etc. So you end up with a bloated kernel which contains a lot of unused code and wastes memory.



I think there are also some drivers which can only be built as kernel modules but that's more a design choice than a real technical limitation.



Answer to edits:



  1. It probably depends who you ask and in what context. To me, it's everything which runs in kernel space so that includes all the drivers. A kernel developer might have a different view with many more names for different pieces.


  2. Actually, the vast majority of the kernel code is loadable modules and drivers. Some of those are quite large. On my system, btrfs alone is 500 kB compressed. NFS is nearly as large. ext4 is 300 kB. There is a huge number of supported storage devices as well and you might need any of them to get your root filesystem. Just browse through /lib/modules/*/kernel/drivers/ on a linux system and you'll see.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 26 '16 at 15:52

























answered Dec 26 '16 at 13:52









OlivierOlivier

54637




54637












  • Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:56






  • 2





    @Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

    – Olivier
    Dec 26 '16 at 14:36












  • what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

    – Shivam aggarwal
    Dec 26 '16 at 14:48











  • You've now made the question too broad unfortunately.

    – Philip Kendall
    Dec 26 '16 at 15:33






  • 1





    @Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

    – Olivier
    Dec 27 '16 at 13:47

















  • Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

    – Shivam aggarwal
    Dec 26 '16 at 13:56






  • 2





    @Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

    – Olivier
    Dec 26 '16 at 14:36












  • what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

    – Shivam aggarwal
    Dec 26 '16 at 14:48











  • You've now made the question too broad unfortunately.

    – Philip Kendall
    Dec 26 '16 at 15:33






  • 1





    @Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

    – Olivier
    Dec 27 '16 at 13:47
















Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

– Shivam aggarwal
Dec 26 '16 at 13:56





Thanks alot for the clear answer. But what is the problem even if the kernel gets bloated because in either case the same memory is used up. Kernel + FS drivers = Kernel + Initrd = Same amount of memory.

– Shivam aggarwal
Dec 26 '16 at 13:56




2




2





@Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

– Olivier
Dec 26 '16 at 14:36






@Shivam initrd memory is freed during boot as it is no longer needed once you have the real root fs. Only the modules which were actually loaded need to remain in memory. With the big kernel nothing can be unloaded. I think it can't even be swapped out. Also, the default initrd does not need to contain everything if you have an alternate complete one in case your hardware changes.

– Olivier
Dec 26 '16 at 14:36














what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

– Shivam aggarwal
Dec 26 '16 at 14:48





what is actually the meaning of linux kernel. What all does it consist of? I've made some edits into the question, please review them and update the answer. It'll be of great help. Thanks.

– Shivam aggarwal
Dec 26 '16 at 14:48













You've now made the question too broad unfortunately.

– Philip Kendall
Dec 26 '16 at 15:33





You've now made the question too broad unfortunately.

– Philip Kendall
Dec 26 '16 at 15:33




1




1





@Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

– Olivier
Dec 27 '16 at 13:47





@Shivam Yes that's correct. But it is also possible to customize the initrd to contain only the required drivers so it is much smaller. It's also possible to compile a custom kernel for very low memory devices.

– Olivier
Dec 27 '16 at 13:47













2














It's a bit of a chicken and the egg problem... You can (and usually should) let lots of your drivers be modules, it keep your kernel lean and saves memory (until and if you need the module). However you do need some drivers built into your kernel - specifically for whatever device your booting from (eg. CD-ROM drive, HDD, ...), the filesystem used (eg. iso9660, ext4, ...), and any additional drivers needed to support this (eg. USB-support, SCSI-support, ...). If you don't, your kernel won't be able to access the medium and the filesystem where the modules for additional drivers resides, and thus can't load them into the kernel.



If you make a customized kernel for your own system - where you know in advance what hardware (HDD-type, DVD-drive type, etc.) you've got - this is not a problem. You just need drivers for what you actually got or think you may need. And you only need to include into the kernel, the drivers needed at boot-time.



However, if your making an install-disc for a distro, you must include drivers for all possible hardware users are likely to encounter! Including them all to the kernel, would make the kernel hopelessly bloated and it would take too much RAM on low-end systems. Making all drivers modules won't work, because the modules may be needed for loading them. The solution is initrd!



initrd is the image of a RAM-disk that is loaded into memory at start. All drivers likely to be needed lays on this as modules. As long as the kernel includes drivers to read a DVD, to read the filesystem on a DVD, and to read a RAM-disk; it will be able to access and load on demand the driver-modules from the initrd. This solves the problem for those who makes distros to make the kernel both small and include drivers for every hardware it may run on.



Most users probably keep using initrd-boot after they've installed Linux on their harddrives... This is not really neccessery, as they could build a custom-kernel - perhaps with additional kernel-modules - customized for the hardware they actually got. The two-step process of first loading the initrd, takes a bit of extra time during boot.






share|improve this answer























  • But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

    – Shivam aggarwal
    Dec 26 '16 at 15:51






  • 1





    You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

    – Johan Myréen
    Dec 26 '16 at 22:44











  • @JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

    – Shivam aggarwal
    Dec 27 '16 at 11:35







  • 1





    Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

    – Johan Myréen
    Dec 27 '16 at 12:30











  • @JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

    – Shivam aggarwal
    Dec 27 '16 at 15:57















2














It's a bit of a chicken and the egg problem... You can (and usually should) let lots of your drivers be modules, it keep your kernel lean and saves memory (until and if you need the module). However you do need some drivers built into your kernel - specifically for whatever device your booting from (eg. CD-ROM drive, HDD, ...), the filesystem used (eg. iso9660, ext4, ...), and any additional drivers needed to support this (eg. USB-support, SCSI-support, ...). If you don't, your kernel won't be able to access the medium and the filesystem where the modules for additional drivers resides, and thus can't load them into the kernel.



If you make a customized kernel for your own system - where you know in advance what hardware (HDD-type, DVD-drive type, etc.) you've got - this is not a problem. You just need drivers for what you actually got or think you may need. And you only need to include into the kernel, the drivers needed at boot-time.



However, if your making an install-disc for a distro, you must include drivers for all possible hardware users are likely to encounter! Including them all to the kernel, would make the kernel hopelessly bloated and it would take too much RAM on low-end systems. Making all drivers modules won't work, because the modules may be needed for loading them. The solution is initrd!



initrd is the image of a RAM-disk that is loaded into memory at start. All drivers likely to be needed lays on this as modules. As long as the kernel includes drivers to read a DVD, to read the filesystem on a DVD, and to read a RAM-disk; it will be able to access and load on demand the driver-modules from the initrd. This solves the problem for those who makes distros to make the kernel both small and include drivers for every hardware it may run on.



Most users probably keep using initrd-boot after they've installed Linux on their harddrives... This is not really neccessery, as they could build a custom-kernel - perhaps with additional kernel-modules - customized for the hardware they actually got. The two-step process of first loading the initrd, takes a bit of extra time during boot.






share|improve this answer























  • But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

    – Shivam aggarwal
    Dec 26 '16 at 15:51






  • 1





    You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

    – Johan Myréen
    Dec 26 '16 at 22:44











  • @JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

    – Shivam aggarwal
    Dec 27 '16 at 11:35







  • 1





    Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

    – Johan Myréen
    Dec 27 '16 at 12:30











  • @JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

    – Shivam aggarwal
    Dec 27 '16 at 15:57













2












2








2







It's a bit of a chicken and the egg problem... You can (and usually should) let lots of your drivers be modules, it keep your kernel lean and saves memory (until and if you need the module). However you do need some drivers built into your kernel - specifically for whatever device your booting from (eg. CD-ROM drive, HDD, ...), the filesystem used (eg. iso9660, ext4, ...), and any additional drivers needed to support this (eg. USB-support, SCSI-support, ...). If you don't, your kernel won't be able to access the medium and the filesystem where the modules for additional drivers resides, and thus can't load them into the kernel.



If you make a customized kernel for your own system - where you know in advance what hardware (HDD-type, DVD-drive type, etc.) you've got - this is not a problem. You just need drivers for what you actually got or think you may need. And you only need to include into the kernel, the drivers needed at boot-time.



However, if your making an install-disc for a distro, you must include drivers for all possible hardware users are likely to encounter! Including them all to the kernel, would make the kernel hopelessly bloated and it would take too much RAM on low-end systems. Making all drivers modules won't work, because the modules may be needed for loading them. The solution is initrd!



initrd is the image of a RAM-disk that is loaded into memory at start. All drivers likely to be needed lays on this as modules. As long as the kernel includes drivers to read a DVD, to read the filesystem on a DVD, and to read a RAM-disk; it will be able to access and load on demand the driver-modules from the initrd. This solves the problem for those who makes distros to make the kernel both small and include drivers for every hardware it may run on.



Most users probably keep using initrd-boot after they've installed Linux on their harddrives... This is not really neccessery, as they could build a custom-kernel - perhaps with additional kernel-modules - customized for the hardware they actually got. The two-step process of first loading the initrd, takes a bit of extra time during boot.






share|improve this answer













It's a bit of a chicken and the egg problem... You can (and usually should) let lots of your drivers be modules, it keep your kernel lean and saves memory (until and if you need the module). However you do need some drivers built into your kernel - specifically for whatever device your booting from (eg. CD-ROM drive, HDD, ...), the filesystem used (eg. iso9660, ext4, ...), and any additional drivers needed to support this (eg. USB-support, SCSI-support, ...). If you don't, your kernel won't be able to access the medium and the filesystem where the modules for additional drivers resides, and thus can't load them into the kernel.



If you make a customized kernel for your own system - where you know in advance what hardware (HDD-type, DVD-drive type, etc.) you've got - this is not a problem. You just need drivers for what you actually got or think you may need. And you only need to include into the kernel, the drivers needed at boot-time.



However, if your making an install-disc for a distro, you must include drivers for all possible hardware users are likely to encounter! Including them all to the kernel, would make the kernel hopelessly bloated and it would take too much RAM on low-end systems. Making all drivers modules won't work, because the modules may be needed for loading them. The solution is initrd!



initrd is the image of a RAM-disk that is loaded into memory at start. All drivers likely to be needed lays on this as modules. As long as the kernel includes drivers to read a DVD, to read the filesystem on a DVD, and to read a RAM-disk; it will be able to access and load on demand the driver-modules from the initrd. This solves the problem for those who makes distros to make the kernel both small and include drivers for every hardware it may run on.



Most users probably keep using initrd-boot after they've installed Linux on their harddrives... This is not really neccessery, as they could build a custom-kernel - perhaps with additional kernel-modules - customized for the hardware they actually got. The two-step process of first loading the initrd, takes a bit of extra time during boot.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 26 '16 at 15:31









Baard KopperudBaard Kopperud

4,50342845




4,50342845












  • But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

    – Shivam aggarwal
    Dec 26 '16 at 15:51






  • 1





    You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

    – Johan Myréen
    Dec 26 '16 at 22:44











  • @JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

    – Shivam aggarwal
    Dec 27 '16 at 11:35







  • 1





    Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

    – Johan Myréen
    Dec 27 '16 at 12:30











  • @JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

    – Shivam aggarwal
    Dec 27 '16 at 15:57

















  • But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

    – Shivam aggarwal
    Dec 26 '16 at 15:51






  • 1





    You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

    – Johan Myréen
    Dec 26 '16 at 22:44











  • @JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

    – Shivam aggarwal
    Dec 27 '16 at 11:35







  • 1





    Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

    – Johan Myréen
    Dec 27 '16 at 12:30











  • @JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

    – Shivam aggarwal
    Dec 27 '16 at 15:57
















But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

– Shivam aggarwal
Dec 26 '16 at 15:51





But now that the distro vendors have included all needed modules(i.e. USB, CD-ROM, HDD, etc) in the initrd and we ultimately have to load initrd in the memory so won't it cause problems on low memory devices since it contains all possible drivers that were removed from the kernel to make less bloaty!

– Shivam aggarwal
Dec 26 '16 at 15:51




1




1





You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

– Johan Myréen
Dec 26 '16 at 22:44





You have to differentiate between two things here: loading the ramfs into memory and loading modules into the kernel. Only the needed modules are linked into the kernel from the initramfs, after which the it can be deleted before passing control to the init program. See Managing the initial ramfs (initramfs) archive.

– Johan Myréen
Dec 26 '16 at 22:44













@JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

– Shivam aggarwal
Dec 27 '16 at 11:35






@JohanMyréen I think you've exactly caught the issue. So are loading modules in kernel and loading ramfs in memory different things? If so, Why? Because even if the modules are getting loaded into the kernel even then memory is being consumed(the kernel space is getting larger). Also if I keep all my drivers into the kernel can't I unload the less useful ones later? or is it just possible to remove ramfs from the memory thereby removing the useless drivers.

– Shivam aggarwal
Dec 27 '16 at 11:35





1




1





Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

– Johan Myréen
Dec 27 '16 at 12:30





Kernel modules are specially built object code files, containing executable code, data and a symbol table containing the names and other attributes of the entry points the module provides, and the names of the symbols in the kernel the module is dependent on. Loading a module means this object code file is linked into the kernel at run time, instead of being linked statically when the kernel image was built. A kernel module in the ramfs is just a file like any other file on a file system. All module files (no matter it they have been loaded or not) can eventually be deleted from the ramfs.

– Johan Myréen
Dec 27 '16 at 12:30













@JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

– Shivam aggarwal
Dec 27 '16 at 15:57





@JohanMyréen Sir I really like your easy way of explanation. Thanks a lot. Sir if possible can you please join me on a chat room( chat.stackexchange.com/rooms/50778/discussion-on-initramfs )so that I can get some more clarifications, I think the comment section is getting too long :) . Otherwise can also I ask my further doubts here itself. Completely up to you Sir. Please do reply.

– Shivam aggarwal
Dec 27 '16 at 15:57

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f332817%2fwhy-dont-we-include-file-system-drivers-in-the-kernel-itself-instead-of-using-i%23new-answer', 'question_page');

);

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






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay