I hope to check the value of log_buf_len via sysctl, but sysctl -a doesn't show it, why and is there any other way to check its value


The value of log_buf_len is set once and for all when the kernel is configured and built OR when it is booted with a parameter log_buf_len=NNN: you cannot change it after that. sysctl generally concerns itself with things that you can change in the running kernel: that's probably the reason why log_buf_len is not included.

You can find the configured value of LOG_BUF_SHIFT by just grepping through the kernel config file (assuming that it's available). For example, on my Fedora 29 system, I do

$ grep CONFIG_LOG_BUF_SHIFT /boot/config-5.2.11-100.fc29.x86_64 

log_buf_len is equal to 2^18 then UNLESS it has been set through the boot command line.

If that is the case (or if you don't have access to the config file), then the only way I know is to use gdb to examine the running kernel, but I haven't done that in many years and I really can't remember all the steps - the main difficulty is to get debugging symbols for the kernel you are running. Somebody else will have to provide those instructions though (or perhaps provide a simpler method; e.g. it is possible to write a kernel module that prints out the value when it is loaded - there are many tutorials on writing simple kernel modules, e.g. here: that tutorial dates from the days of the 2.6 kernel and things may be different today but I (naively?) don't expect things to be very different).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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