• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Capture More Logs in /var/log/dmesg for CentOS/RHEL

by admin

Sometimes not all log messages in /var/log/dmesg can be captured after Linux OS/kernel boots up because of too many block devices attached to the server. This post illustrates another way to record all bootup log messages besides configuring the serial console.

Basically kernel parameter “log_buf_len” can be configured to increase kernel log buffer size,

Name: log_buf_len, Set the size of the kernel log buffer.

Synopsis: log_buf_len= n [ KMG ]

Description: Set the size of the kernel’s internal log buffer. n must be a power of 2, if not, it will be rounded up to be a power of two. This value can also be changed by the CONFIG_LOG_BUF_SHIFT kernel configuration value.

For CentOS/RHEL 5,6

For CentOS/RHEL 5 and 6, “log_buf_len=8M” can be appended to kernel line for default boot kernel entry in /boot/grub/grub.conf.

For example, if the current kernel line is:

kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=/dev/mapper/vg_root-lv_root

Append the log_buf_len to this line to make it:

kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=/dev/mapper/vg_root-lv_root log_buf_len=8M

Reboot the system for the changes to take effect.

# shutdown -r now

Temporary Change

You may also change the log_buf_len value temporarily while booting the system. Follow the steps given below while booting the system:

1. Press e again to edit the kernel line.
2. Add log_buf_len=8M to the end of the kernel line, as shown in the examples above.
3. Press Enter to temporarily save the changes.
4. Press b to boot with the edited boot entry.

For CentOS/RHEL 7

For CentOS/RHEL 7, the same setting can be appended to “GRUB_CMDLINE_LINUX” line in /etc/default/grub:

# cat /etc/default/grub
GRUB_TIMEOUT=15
GRUB_HIDDEN_MENU_QUIET=false
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
GRUB_CMDLINE_LINUX="console=tty0 log_buf_len=8M"
GRUB_DISABLE_RECOVERY="true"

Then rebuild the grub.cfg which is used at boot using the below command:

# grub2-mkconfig -o /boot/grub2/grub.cfg

For EFI based systems, use the below command:

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Reboot the system

# shutdown -r now

Temporary Change

When booting the system, stop the boot process on the GRUB kernel selection screen by pressing an arrow key up or down.

1. Press e to edit the boot entry.
2. Use up and down arrows to select the kernel line with the vmlinuz file on it.
3. Press End to place the cursor on the end of that line.
4. Add log_buf_len=8M to the end of the kernel line, as shown in the examples above.
5. Press Ctrl+x to boot with the edited boot entry.

Filed Under: CentOS/RHEL, CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. doctl kubernetes options: Provides values available for use with doctl’s Kubernetes commands
  2. How to Setup a sudo Switch to Another User That Has no Password or ssh Key Set in Linux
  3. cosign: Container Signing, Verification and Storage in an OCI registry
  4. CentOS / RHEL : iptables troubleshooting guide
  5. How to Migrate CentOS/RHEL 6 iptables Rules to CentOS/RHEL 7 firewalld
  6. journalctl: command not found
  7. debsecan Command Examples in Linux
  8. fselect: Find files with SQL-like queries
  9. CentOS / RedHat : Beginners guide to log file administration
  10. dirname: Calculates the parent directory of a given file or directory path

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright