I know that they are two different entities. Rootfs is a file system which describes how to store and access data. The kernel is actual code which executes.

However, isn't the kernel code stored inside the Rootfs?

Why is it then, that they are stored on different partitions in flash for example? I always see the partitioning layout of an emmc device in an embedded system for example with one partition for the kernel and another for the Rootfs. This confuses me.

closed as off-topic by Ipor Sircer, Mr Shunz, msp9011, user34720, JigglyNaga Jan 9 at 10:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Ipor Sircer, Mr Shunz, msp9011, Community, JigglyNaga
If this question can be reworded to fit the rules in the help center, please edit the question.

  • There're tons of code stored in rootfs, not just kernel code, they are being excuted IN MEMORY all the time. The partitioning scheme is just a decision by vendors. I think the key point of this question is you don't know the key difference between memory and disk. – 炸鱼薯条德里克 Jan 8 at 3:49
  • @炸鱼薯条德里克 kernel executes in memory yes, but i'm still confused with the Rootfs. Is this stored on disk / flash? – Engineer999 Jan 8 at 13:22
  • As you mentioned in your question, yes, rootfs is stored on your flash, as I mentioned earlier, userspace code stored in rootfs is also excuted in memory. Just remember, all the code excuted in memory. And memory means the storage device that can be directly accessed by CPU, not the physical type of your storge device. – 炸鱼薯条德里克 Jan 8 at 14:16

Older boot loaders could only mount primitive file systems so the kernel was kept on boot and the OS on root. One way of preventing some types of failures due to a full file system is to give each thing it's own file system. Another convenience of multiple partitions is one can easley backup and restore them individually. Some file systems like is ZFS, BTRFS, LVM? are not supported by bootloaders that do not themselves use the Linux kernel.

The problem with these ideas is that updating the kernel can fail if the boot volume becomes full when there is plenty of other space available. Fast Incremental snapshots are only avalable with advanced file systems.

So it's up to the OS distribution to decide what trade-offs to make.

Completely independently of file systems there are some features (security and otherwise) that map the kernel to memory then restrict access to that memory with hardware and/or software to enforce rights and mitigate privilege escalation. See user vs kernel mode.

  • but regarding locations in memory, the kernel and Rootfs are in different locations? This I don't understand – Engineer999 Jan 7 at 22:28

The kernel is RAM-resident executable code. The rootfs is the essential filesystem for the system (initially a ramfs or tmpfs) , but more often is used to refer to a collection of files in a filesystem of some type (e.g. ramfs, ext2/3/4, jffs2, ubifs) that consist of essential initialization and userspace programs. Both are needed to boot a Linux system.

Taken from a sister community in which someone asked a similar question. Click here for more info.

Not the answer you're looking for? Browse other questions tagged or ask your own question.