Monday, October 20, 2014

Linux -- list current boot parameters

You may need to list the current boot parameters while your Linux system is running.. There parameters are boot arguments.. When the kernel is booted directly by the BIOS , you can be sure that no additional/unexpected arguments are given on the fly, but when the kernel is booted by using a boot loader such as Grub, additional arguments can be supplied on the fly, and this may cause you some problems with your enterprise applications.

Lets take a look at the boot arguments;

The Linux kernel accepts certain 'command-line options' or 'boot time parameters' at the moment it is started. In general this is used to supply the kernel with information about hardware parameters that the kernel would not be able to determine on its own, or to avoid/override the values that the kernel would otherwise detect.

Any arguments not recognized by the system/not picked up by kernel is treated as an Environment variable decleration, such as 'TERM=vt100.. Some arguments which are not picked up by kernel and also not recoqnized as an environment variable , are passed to the init process. Argument 'Single' is a good example of this type..

Following is an example of edition kernel boot parameters before the boot operation using Grub boot loader.. You see that the string single added to the end of the kernel line.. This arguments instructs it to boot the computer in single user mode, and not launch all the usual daemons.

You can get the full list of these parameters using the following link;

Okay we have seen the boot arguments/parameters so far, lets see how to get the list of current boot parameters of a running  Linux Operating system;

Usually bootloader passes the boot parameters to the kernel command line, which is an in-memory buffer.
We can reach the kernel command line using /proc filesystem, and following is the command we are looking for :)
cat /proc/cmdline

/proc/[pid]/cmdline is a read-only file holds the complete command line for the process, unless the process is a zombie. In the latter case, there is nothing in this file: that is, a read on this file will return 0 characters. The command-line arguments appear in this file as a set of strings separated by null bytes ('\0'), with a further null byte after the last string.
cat /proc/cmdline 
ro root=/dev/VolGroup00/LogVol00 rhgb quiet

As you see by looking to the example output above; the system in this example was booted using ro,root,rhgb and quiet arguments..
So we can understand that the kernel is mounted read only(ro), the root is located in LogVol00(root),  the boot operation was done using redhat graphical boot, which is a GUI tool with booting screen(rhgb) and lastly the boot messages before the rhgb were hidden during the boot operation ..(quiet)

No comments :

Post a Comment