The issue is caused by the use_mlockall parameter in the LVM configuration file /etc/lvm/lvm.conf. As shown below the /etc/lvm/lvm.conf file has below entry:
# cat /etc/lvm/lvm.conf use_mlockall = 0
Configuration option activation/use_mlockall
Prior to version 2.02.62, LVM used mlockall() to pin the whole process’s memory while activating devices, however, later versions of LVM, such as in the example above do not use this functionality. To implement the solution, please execute the following steps:
1. Log in to the server with root user.
2. Edit the
/etc/lvm/lvm.conf configuration file and change the below value:
# vi /etc/lvm/lvm.conf use_mlockall = 0
# vi /etc/lvm/lvm.conf use_mlockall = 1
use_mlockall = 0” means in theory the memory used by lvm and its libs could get swapped out, but that should only affect you in low-memory situations. So, in most situations “mlock failed: Cannot allocate memory” is only informational message, unless you really have low free RAM.