The Problem
Unable to extend LVM filesystem. The following error message is received on running the lvextend command:
Read-only locking type set. Write locks are prohibited. Can't get lock for rootvg resize2fs 1.43-WIP (20-Jun-2013) The filesystem is already 1310720 blocks long. Nothing to do!
The Solution
The parameter locking_type is set to 4 in /etc/lvm/lvm.conf.
# grep locking lvm.conf |grep -v '#'
"lvmetad", "metadata", "cache", "locking" ]
locking_type = 4
fallback_to_clustered_locking = 1
fallback_to_local_locking = 1
locking_dir = "/var/lock/lvm"
Setting the locking_type parameter to 4 enforces read-only metadata. Any operations that might want to modify the Volume Group metadata are forbidden.
Hence,the lvextend command fails when locking_type is set to 4 as it tries to modify the Volume Group metadata. Follow the steps outlined below to resolve the issue.
1. Take a backup of /etc/lvm/lvm.conf.
2. Edit the /etc/lvm/lvm.conf file and set the value of locking_type to 1.
3. Save the file.
4. Reboot the server.
The locking_type parameter should look like below when you do the changes:
#grep locking lvm.conf |grep -v '#'
-----
"lvmetad", "metadata", "cache", "locking" ]
locking_type = 1
fallback_to_clustered_locking = 1
fallback_to_local_locking = 1
locking_dir = "/var/lock/lvm"
locking_type parameter values
locking_type defines what type of locking is being used. The following is the list of parameter value and its description:
- 0 – disables locking and also risks corrupting the metadata
- 1(default) – which use flocks on files to avoid conflicting LVM2 commands running concurrently on a single machine.
- 2 – the tools will load the external locking_library.
- 3 – enforces built-in cluster-wide locking.
- 4 – enforces read-only metadata and forbids any operations that might want to modify Volume Group metadata.
For more details on above values, kindly refer the man page for lvm.conf:
# man lvm.conf