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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lvdisplay error: “Failed to create directory /var/lock/lvm. File-based locking initilisation failed.”

By admin

The Problem

On CentOS/RHEL 6.x with Logical Volume Manger, all the LVM commands return locking error immediately after boot up as shown below:

# lvdisplay
Failed to create directory /var/lock/lvm
File-based locking initilisation failed.

The Solution

Above message is getting logged due to a check added in lvm code to verify if the path mentioned for locking_dir option in /etc/lvm/lvm.conf file is available or not and then print an error if the path used for locking_dir option is not available. This error is typically observed when /var is created as a separate filesystem. In most cases this happens if the /var/ filesystem is mounted as read-only.

$ grep -i "locking_dir" etc/lvm/lvm.conf 
    # Configuration option global/locking_dir.
    locking_dir = "/var/lock/lvm"

Workaround:

1. Configure the locking_dir option in /etc/lvm/lvm.conf to a path in root (/) filesystem itself, as shown below:

# vi /etc/lvm/lvm.conf
locking_dir = "/run/lock"

2. Make sure that above directory is present on server, or you could create the same manually using following command:

# mkdir -p /run/lock

3. Run the lvm commands by defining temporary locking directory

# lvdisplay --config 'global { locking_dir = "/run/lock" } '
# pvdisplay --config 'global { locking_dir = "/run/lock" } '
# vgdisplay --config 'global { locking_dir = "/run/lock" } '

Permanent Solution:

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.

Filed Under: CentOS/RHEL 6, Linux, OEL 6

Some more articles you might also be interested in …

  1. How to recover from a corrupt RPM database (rebuilding an RPM database)
  2. How to disable swap in Linux
  3. How to Rebuild GRUB on MSDOS Partition Type in CentOS/RHEL/OEL 7
  4. Understanding rsyslog Actions
  5. How to Disable NUMA in CentOS / RHEL 6,7
  6. Yum Fails with “Error: database disk image is malformed” in /var/log/messages
  7. “passwd: Module is unknown” – error while changing the password in CentOS/RHEL 6
  8. How to Make User Account Read-Only in CentOS/RHEL 7
  9. CentOS / RHEL 6 : How to extract initramfs image and edit/view it
  10. What is the purpose of “mysql.sys@localhost” user

You May Also Like

Primary Sidebar

Recent Posts

  • Basics of client connectivity in Oracle Data Guard configuration
  • ORA-354 ORA-353 and ORA-312: Possible corruption in Online Redo Log File Members in a Redo Log Group
  • How to relocate the redo log files to a different location on disk
  • Oracle Database: Redo log operations (Add/Drop/Change Location)
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary