2

Supposedly I passed the kernel a parameter that it doesn't understand, for example blabla or eat=cake, what would the kernel do with these unknown parameters, the traditional case would be passing any unknown parameter to init, in case if the the Linux kernel starts with early user space (initramfs) would it pass it to /init in initramfs?

  • 1
    IIRC they just get ignored. TIAS. – Tom Yan Aug 25 '17 at 14:45
  • @TomYan Nothing happens. – direprobs Aug 25 '17 at 15:13
  • So you got your answer? – Tom Yan Aug 25 '17 at 19:10
  • It seems that what you want to know is, which parts / are everything in the kernel command line passed to the init in the initramfs. I am not sure if all distro / init take similar approach but in Arch/mkinitcpio, the init has function that mount /proc (and more) and parse /proc/cmdline: git.archlinux.org/mkinitcpio.git/tree/init?h=v23#n13 – Tom Yan Aug 25 '17 at 19:18
  • @TomYan I got the answers for my questions by looking at /init in initramfs. In Ubuntu, initramfs is pretty much generic, the /init mounts /proc and /devtmpfs and also runs udevd and among many things it mounts the real root filesystem. Everything is handled at user space. So initramfs in Ubuntu is pretty much complex. That's why I hate generic kernels, their complexity is just not worth it. I'd rather buy the hardware than spend a day trying to figure out something. Plus, having a specific hardware with the appropriate drivers, makes a perfect system. – direprobs Aug 25 '17 at 20:53
3

From the kernel documentation:

The kernel parses parameters from the kernel command line up to --; if it doesn't recognize a parameter and it doesn't contain a ., the parameter gets passed to init: parameters with = go into init's environment, others are passed as command line arguments to init. Everything after -- is passed as an argument to init.

This also applies to /init on an initramfs. In the source code, both the initramfs's /init and the final root's /sbin/init (or other locations) are invoked via run_init_process which uses the same arguments (apart from argument 0 which is the path to the executable). I can't find it stated in the documentation but kernel interfaces are stable so this won't change.

Note that this does not apply to /linuxrc on an initrd. This one is invoked with no arguments, but with the same environment as /init and /sbin/init. It can mount the proc filesystem and read /proc/cmdline to see the kernel command line arguments.

  • For /init in initramfs, /init passed the parameters on to /sbin/init and when I checked /proc/1/cmdline this is what I got: /sbin/initbbbbbb. The path to the executable is there in addition to the unknown parameter. – direprobs Aug 27 '17 at 7:53

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.