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
}

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)