The Problem
lvdisplay command prints the below error on a CentOS/RHEL 6 system:
# lvdisplay Failed to create directory /var/lock/lvm File-based locking initilisation failed.
The Solution
The above error is due to the /var file system is mounted as read only. To resolve the issue, follow the steps outlined below:
1. Edit and modify /etc/lvm/lvm.conf as below:
locking_dir = "/var/lock/lvm"
to
locking_dir = "/tmp/lock/lvm"
2. Run the lvm commands by defining temporary locking directory:
# lvdisplay --config 'global { locking_dir = "/tmp" } ' # pvdisplay --config 'global { locking_dir = "/tmp" } ' # vgdisplay --config 'global { locking_dir = "/tmp" } '
Making Changes Permanent
Mount the /var filesystem with rw option or if the filesystem is read-only due to filesystem corruption, run fsck against the unmounted /var partition to fix it, but ensure you have a valid backup before running fsck.