How do I find the boot parameters used by the running kernel?

Solution 1:

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

Solution 2:

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.

Solution 3:

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;
}