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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. How to Disable TLS 1.1 Cockpit port 9090
  2. cpufreq-info Command Examples in Linux
  3. Yum Fails with “Error: database disk image is malformed” in /var/log/messages
  4. pvs Command Examples in Linux
  5. “Volume “myvg/vol01″ Is Not Active Locally” – CentOS/RHEL
  6. manpath Command Examples in Linux
  7. Mutt, Mail and Telnet – Send mails from linux command line or terminal
  8. How to check the PHP version on Linux
  9. dstat: command not found
  10. TIME_WAIT queue troubles

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright