• 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

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. Order of environment calls for different OS shells in Linux
  2. How to disable FIPS mode on CentOS/RHEL 7
  3. How to identify the HBA cards/ports and WWN in Linux
  4. How to move /tmp on a separate disk as a separate mount point (Online)
  5. cpufreq-set Command Examples in Linux
  6. mpg123: command not found
  7. gpg: command not found
  8. a2enconf: command not found
  9. lvcreate Command Examples in Linux
  10. coredumpctl Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright