Are all kernel argument really used by the kernel?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
Why does Linux allow âÂÂinit=/bin/bashâÂÂ?
I read this, answers are saying it's KERNEL running this init program.
Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init
argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.
Also, the root=UUID=xxxx
argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?
It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?
linux-kernel
add a comment |Â
up vote
3
down vote
favorite
Why does Linux allow âÂÂinit=/bin/bashâÂÂ?
I read this, answers are saying it's KERNEL running this init program.
Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init
argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.
Also, the root=UUID=xxxx
argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?
It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?
linux-kernel
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Why does Linux allow âÂÂinit=/bin/bashâÂÂ?
I read this, answers are saying it's KERNEL running this init program.
Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init
argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.
Also, the root=UUID=xxxx
argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?
It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?
linux-kernel
Why does Linux allow âÂÂinit=/bin/bashâÂÂ?
I read this, answers are saying it's KERNEL running this init program.
Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init
argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.
Also, the root=UUID=xxxx
argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?
It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?
linux-kernel
linux-kernel
asked 2 hours ago
ç¥Âç§Âå¾·éÂÂå Â
250110
250110
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
Parameters passed on the kernel command line donâÂÂt have to be meaningful for the kernel: the kernel parameters documentation says
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 doesnâÂÂt apply to init
and root
which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline
. (Thus for example systemd takes the quiet
kernel parameter into account to reduce its output.)
Thany you. So, theinit
, is that the path in the initramfs? Androot
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't findld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system andinit
is loaded from there; otherwise, the kernel mounts the file system on the device given byroot
and loadsinit
from that (if it can mount it). If theinit
program is broken, then the system fails to boot with the âÂÂNo init found.â message.init
is run usingdo_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified ininit=
, or/sbin/init
, from the root file system.
â Stephen Kitt
43 mins ago
add a comment |Â
up vote
1
down vote
Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:
linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0
where lab
is then used in the KickStart configuration to do different things than for other system builds:
%pre
...
case " $(cat /proc/cmdline)" in
...
* lab*)
filesystems_lab
;;
*)
filesystems_common
;;
...
Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Parameters passed on the kernel command line donâÂÂt have to be meaningful for the kernel: the kernel parameters documentation says
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 doesnâÂÂt apply to init
and root
which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline
. (Thus for example systemd takes the quiet
kernel parameter into account to reduce its output.)
Thany you. So, theinit
, is that the path in the initramfs? Androot
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't findld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system andinit
is loaded from there; otherwise, the kernel mounts the file system on the device given byroot
and loadsinit
from that (if it can mount it). If theinit
program is broken, then the system fails to boot with the âÂÂNo init found.â message.init
is run usingdo_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified ininit=
, or/sbin/init
, from the root file system.
â Stephen Kitt
43 mins ago
add a comment |Â
up vote
5
down vote
accepted
Parameters passed on the kernel command line donâÂÂt have to be meaningful for the kernel: the kernel parameters documentation says
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 doesnâÂÂt apply to init
and root
which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline
. (Thus for example systemd takes the quiet
kernel parameter into account to reduce its output.)
Thany you. So, theinit
, is that the path in the initramfs? Androot
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't findld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system andinit
is loaded from there; otherwise, the kernel mounts the file system on the device given byroot
and loadsinit
from that (if it can mount it). If theinit
program is broken, then the system fails to boot with the âÂÂNo init found.â message.init
is run usingdo_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified ininit=
, or/sbin/init
, from the root file system.
â Stephen Kitt
43 mins ago
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Parameters passed on the kernel command line donâÂÂt have to be meaningful for the kernel: the kernel parameters documentation says
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 doesnâÂÂt apply to init
and root
which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline
. (Thus for example systemd takes the quiet
kernel parameter into account to reduce its output.)
Parameters passed on the kernel command line donâÂÂt have to be meaningful for the kernel: the kernel parameters documentation says
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 doesnâÂÂt apply to init
and root
which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline
. (Thus for example systemd takes the quiet
kernel parameter into account to reduce its output.)
answered 1 hour ago
Stephen Kitt
148k23327394
148k23327394
Thany you. So, theinit
, is that the path in the initramfs? Androot
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't findld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system andinit
is loaded from there; otherwise, the kernel mounts the file system on the device given byroot
and loadsinit
from that (if it can mount it). If theinit
program is broken, then the system fails to boot with the âÂÂNo init found.â message.init
is run usingdo_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified ininit=
, or/sbin/init
, from the root file system.
â Stephen Kitt
43 mins ago
add a comment |Â
Thany you. So, theinit
, is that the path in the initramfs? Androot
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't findld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?
â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system andinit
is loaded from there; otherwise, the kernel mounts the file system on the device given byroot
and loadsinit
from that (if it can mount it). If theinit
program is broken, then the system fails to boot with the âÂÂNo init found.â message.init
is run usingdo_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified ininit=
, or/sbin/init
, from the root file system.
â Stephen Kitt
43 mins ago
Thany you. So, the
init
, is that the path in the initramfs? And root
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Thany you. So, the
init
, is that the path in the initramfs? And root
⦠why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find
ld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find
ld-linux.so
ELF or recursion-too-deep script or anything just can't be execve?â ç¥Âç§Âå¾·éÂÂå Â
1 hour ago
1
1
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and
init
is loaded from there; otherwise, the kernel mounts the file system on the device given by root
and loads init
from that (if it can mount it). If the init
program is broken, then the system fails to boot with the âÂÂNo init found.â message. init
is run using do_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.â Stephen Kitt
1 hour ago
If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and
init
is loaded from there; otherwise, the kernel mounts the file system on the device given by root
and loads init
from that (if it can mount it). If the init
program is broken, then the system fails to boot with the âÂÂNo init found.â message. init
is run using do_execve
so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.â Stephen Kitt
1 hour ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
â plugwash
52 mins ago
@plugwash youâÂÂre right, the kernel runs
/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified in init=
, or /sbin/init
, from the root file system.â Stephen Kitt
43 mins ago
@plugwash youâÂÂre right, the kernel runs
/init
from the initramfs, and if that doesnâÂÂt exist, tries to run the program specified in init=
, or /sbin/init
, from the root file system.â Stephen Kitt
43 mins ago
add a comment |Â
up vote
1
down vote
Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:
linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0
where lab
is then used in the KickStart configuration to do different things than for other system builds:
%pre
...
case " $(cat /proc/cmdline)" in
...
* lab*)
filesystems_lab
;;
*)
filesystems_common
;;
...
Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.
add a comment |Â
up vote
1
down vote
Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:
linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0
where lab
is then used in the KickStart configuration to do different things than for other system builds:
%pre
...
case " $(cat /proc/cmdline)" in
...
* lab*)
filesystems_lab
;;
*)
filesystems_common
;;
...
Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:
linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0
where lab
is then used in the KickStart configuration to do different things than for other system builds:
%pre
...
case " $(cat /proc/cmdline)" in
...
* lab*)
filesystems_lab
;;
*)
filesystems_common
;;
...
Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.
Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:
linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0
where lab
is then used in the KickStart configuration to do different things than for other system builds:
%pre
...
case " $(cat /proc/cmdline)" in
...
* lab*)
filesystems_lab
;;
*)
filesystems_common
;;
...
Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.
answered 1 hour ago
thrig
22.9k12854
22.9k12854
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473260%2fare-all-kernel-argument-really-used-by-the-kernel%23new-answer', 'question_page');
);
Post as a guest
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
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
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