读取Linux内核参数
有没有办法在启动时找到传递给内核(/proc/cmdline)的参数,而无需读取proc中的任何文件?我可能有一个进程需要在挂载 /proc 之前读取启动参数。
Is there a way to find the parameters passes to the kernel (/proc/cmdline) at boot time without reading any files in proc? I might have a process that needs to read the boot parameters before /proc is mounted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
似乎内核将引导行上的任何内容作为参数传递给 init - 除非有 ' = ' 或 ' 。 '
将 Linux 启动选项传递给 Init
It seems the kernel passes anything on the boot line as a arg to init- unless there is a ' = ' or a ' . '
Passing Linux boot opts to Init
我确信有更好的方法,但我确实在 dmesg 中看到了它
I'm sure there's a better way, but I do see it in dmesg
我想更好地了解您的要求,因为几乎可以保证您已经安装了
/proc
。挂载/proc
是init
所做的第一件事。Ubuntu 与新贵:
/etc/init/mountall.conf
,startup
事件的一部分带 initscripts 的 Fedora:
/etc/rc.sysinit
,它所做的第二件事(设置主机名之后)您的代码几乎肯定会在此之后运行。
当您替换
init
时,请看一下init
是如何做到的。 初始化 git 存储库。似乎有一个名为
boot_command_line
的全局符号。I'd like to understand your requirements better, because you are pretty much guaranteed to have
/proc
mounted. Mounting/proc
is one of the very first things thatinit
does.Ubuntu with upstart:
/etc/init/mountall.conf
, part of thestartup
eventFedora with initscripts:
/etc/rc.sysinit
, second thing it does (after setting the hostname)Your code is almost certain to run after this.
Seeing as you're replacing
init
, take a look at howinit
does it. init git repo.There seems to be a global symbol called
boot_command_line
.