my situation is this : I have a freshly compiled kernel, all the applications and libraries compiled for the new platform, I know how to boot using my bootloader of choice, but I don't have a root filesystem .

I would like to know if there is an official or well tested guide about how to populate a new root filesystem for a given linux kernel, which libraries a linux kernel really needs and all the bells and whistles that I need to run a linux kernel and a minimalistic linux box .

I think that the obvious one is the C library, I need a c library anyway, but I don't really know if I can get away with just a C library + all the extra programs and libraries of my likings, or the kernel needs something else, even in terms of config files I haven't really found something explicit about which files the linux kernel is expecting to find on a root filesystem .

All that I found is something about the directories structure of a filesystem that wants to be linux-compatible which basically says that you should have /lib,/usr,/bin and more directories, but really nothin substantial about creating a new filesystem .


this question is not about how to create a filesystem, how to boot it or anything else; I just want to know which files are required to complete the pair kernel + filesystem so I can boot a new linux box .

  • Not entirely sure what you are looking for but maybe the following might help: wiki.gentoo.org/wiki/Custom_Initramfs – phk Oct 14 '16 at 15:21
  • @phk like this tldp.org/HOWTO/Bootdisk-HOWTO/buildroot.html but with less etc... inside the article because I can't work with etc... since I need the specs . – user31223 Oct 14 '16 at 15:25
  • How about using a builder like buildroot.org? – phk Oct 14 '16 at 15:26
  • I do believe you'll find the information in the Linux From Scratch project, chapter 6 in particular. (It isn't minimal, though; the hints might have something useful for that.) – Nominal Animal Oct 14 '16 at 15:27
  • @phk I literally just need a vanilla kernel running with the minimum amount of cr*p and as small as possible, in my case it's probably better to just create files by hand since this is the last step that I need and I don't really pretend much . I can always compile later if I need more executables or libraries . – user31223 Oct 14 '16 at 15:28

The Linux kernel does not care much. The boot loader tells the kernel where to mount a root filesystem -- typically an initial ramdisk image (initrd), but it can also be the actual root filesystem --, and the kernel will start the init process from /sbin/init (/init on a initramfs) unless told otherwise.

Even the location of the kernel filesystems -- /proc, /sys, /dev if udev, and so on -- is basically up to the userspace to decide.

The Linux Standards Base project standardized these across various Linux distributions. (Well, more or less. There are still some small differences in e.g. device naming, and there is talk about merging /usr/bin into /bin and /usr/lib into /lib). A version of it was accepted as an ISO standard, ISO/IEC 23360. The current version of LSB, as of October 2016, is LSB 5.

The Linux kernel developers try very hard to keep stuff backwards-compatible in the userspace interface. This is why version 2.6 information is very much applicable to 4.4. It is pretty much only when new facilities and interfaces are introduced that new versions diverge from the older ones, and you need to find the documentation for those.

You mention you've already compiled some libraries and applications. If so, the compile-time settings you used (check configure settings, --prefix and so on) and the directories those libraries and applications look for their configuration files (and timezone files for the C library, internationalization, and so on) determine the directory structure you absolutely do need.

Linux From Scratch! is a community which develops books on how to compile and build a fully working Linux distribution from scratch. It is not exactly minimal -- you can omit certain packages in some situations, strip others, and so on --, but everything is explained.

Rob Landley is well known for documenting Linux kernel stuff. His intro to initramfs, how to use initramfs, and programming for initramfs, are very interesting if you want to make a minimal system that runs directly from an initramfs, like many embedded devices do.

As to systemctl or systemd in general, I'd point you to its home page, and bid you good luck. I myself am looking for ways to avoid it, and use more robust init systems instead, ones that still acknowledge the Unix philosophy rather than agglomerating into a monolithic mess by whim. (In my experience, the former stay functional and maintainable in the long term, and the latter, while often loved by end users due to the agglomerated new features and outer polish, makes for fragile and broken systems and system administrators in the long term. Your experience and opinions may vary; I'm just describing mine.)

When I developed a simple benchmarking USB stick for evaluating Linux cluster nodes, I examined the minimal Debian and CentOS systems you can install, to find out the details OP is asking (except that I was not looking for a minimal system, but a small lightweight system that can run the same binaries as are run on the final cluster itself; i.e., including basic services and libraries). Today, I'd recommend looking at Devuan, because it supports multiple init systems. Experimenting these in virtual machines should be very informative.

Practice rules over theory or standards. There are no enforced standards, or any standards really; even LSB and ISO/IEC 23360 are more like guidelines for successful interoperability. The Linux kernel documentation extracted from the Linux kernel sources does describe the kernel expectations, but as mentioned, there are very, very few, that affect the filesystem tree. And even those tend to be boot-time or compile-time configurable.

  • checking the tree of some random application is easy, my problem was really just the kernel itself given the fact that I couldn't find docs anywhere about what I was trying to do, I'll try to boot just the kernel and see what will happen . I have discarded systemd myself but because is yet another executable to care for and it has some extra requirements for the kernel ( and I'd like to keep things small and short for now ), plus I don't really need more "parallelization" or stuff like that . < continues ... > – user31223 Oct 15 '16 at 11:29
  • At this point I think that my options are _ with initrd _ or _ without initrd _ and I'll try to make sense of all the initrd docs and tutorials to see what the kernel needs and what I can do . Thanks for the help ! – user31223 Oct 15 '16 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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