44

Is there a way to find out with what parameters did the kernel boot?

For example if I specify noexec=off at the grub command line? Can I see this sort of info after the system has finished booting?

62

You can run cat /proc/cmdline.

Example:

[01:31] ~ $ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-2.6.38-7-generic root=UUID=025c4231-b7bb-48bf-93e9-d20c5b5ce123 ro crashkernel=384M-2G:64M,2G-:128M quiet splash bootchart=disable acpi_enforce_resources=lax vga=792 vt.handoff=7
  • Try tr ' ' '\n' < /proc/cmdline to get linebreaks between the parameters. – mwfearnley Mar 15 '18 at 9:53
8

An alternative way is to check the output of dmesg (line 5 here):

$ dmesg | grep "Command line"
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.19.0-33-generic root=UUID=81dba11f-f76e-4ed4-8120-e6da6328b1ee ro

But note that this might not work if many things have been logged (e.g. if the machine has been running for a long time) because initial startup lines may have been pushed out of the ringbuffer.

1

Actually, the parameter is located between __setup_start and __setup_end in the kernel. In the following code, the p->str is the parameter name

Following kernel code could be found at linux-3.4.5/init/main.c:388

/* Check for early params. */
static int __init do_early_param(char *param, char *val)
{
    const struct obs_kernel_param *p;
    for (p = __setup_start; p < __setup_end; p++) {
        if ((p->early && parameq(param, p->str)) ||
            (strcmp(param, "console") == 0 &&
             strcmp(p->str, "earlycon") == 0)
        ) {
            if (p->setup_func(val) != 0)
                printk(KERN_WARNING
                       "Malformed early option '%s'\n", param);
        }
    }


    /* We accept everything at this stage. */
    return 0;
}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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