• 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

CentOS / RHEL : How to log all LVM commands

by admin

By default, the LVM configuration does not allow you to log the commands that are used in a shell or in a GUI (e.g system-config-lvm) environment. However, it’s possible to active logging using the configuration file /etc/lvm/lvm.conf.

Activate logging for all LVM commands

To active logging follow these steps.
1. Edit the lvm.conf file and find the log section. The default configuration looks like the following:

# vi /etc/lvm/lvm.conf
log {
     verbose = 0 
     syslog = 1 
     #file = "/var/log/lvm2.log"
     overwrite = 0 
     level = 0 
     indent = 1 
     command_names = 0 
     prefix = "  "
     # activation = 0
}

NOTE: It is possible for lvm to log messages directly to a separate file ( by uncommenting the #file = “/var/log/lvm2.log” option). However, using syslog has two advantages.
a. The /var/log/messages file is automatically handled by logrotate, whereas a new lvm2.log file would require new logrotate configuration to ensure it does not grow uncontrollably.
b. Messages directed to /var/log/messages will automatically be prepended with a timestamp. Using a separate file will not include timestamps by default. Timestamps are useful for correlating messages with other known events when troubleshooting.

2. Change the level = 0 to a value between 2 and 7.
level 0 – produces no output.
level 7 – is the most verbose output.

3. Save the changes and exit. It’s not necessary to restart any service. Log messages will start being produced as soon as an lvm command is executed. Log messages will be saved in /var/log/messages.

Disabling LVM logging

Enabling LVM commands logging may flood your /var/log/messages file. You can disable lvm debug logging in /etc/lvm/lvm.conf i.e. use “level = 0”. For Example:

# vi /etc/lvm/lvm.conf
log {
     verbose = 0 
     syslog = 1 
     #file = "/var/log/lvm2.log"
     overwrite = 0 
     level = 0          ### disabled LVM verbose logging
     indent = 1 
     command_names = 0 
     prefix = "  "
     # activation = 0
}

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

Some more articles you might also be interested in …

  1. lsusb: command not found
  2. echo: command not found
  3. How To Disable MD5-based HMAC Algorithm’s for SSH
  4. usermod Command Examples in Linux
  5. Troubleshooting slow network communication or Connection Timeouts in Linux
  6. nmcli networking Command Examples
  7. What are the Network Bonding Modes In CentOS / RHEL
  8. How to use FTP under Linux to transfer files
  9. semanage: command not found
  10. dolt branch: Manage Dolt branches

You May Also Like

Primary Sidebar

Recent Posts

  • gixy Command Examples
  • gitsome Command Examples
  • gitmoji Command Examples
  • gitlint Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright