When working with LVM (Logical Volume Manager), you might encounter the frustrating "Device excluded by a filter
" error while trying to extend a volume group. This typically occurs when the system's LVM filter configuration prevents access to the specified device.
The most frequent reasons for this issue include:
- LVM filters configured in
/etc/lvm/lvm.conf
- Device not properly initialized for LVM use
- Permissions issues on the device
- Device already in use by another system
First, examine your current LVM configuration:
# Check current filter settings
grep filter /etc/lvm/lvm.conf
# Alternative method to view active filters
lvmconfig --type default --withcomments | grep filter
1. Temporarily Override Filters
For testing purposes, you can temporarily override filters:
vgextend --config 'devices { filter = [ "a|.*|" ] }' vg_name /dev/sdb
2. Permanently Modify LVM Configuration
Edit /etc/lvm/lvm.conf
and adjust the filter line. A common configuration would be:
filter = [ "a|^/dev/sd.*|", "r|.*|" ]
After making changes, refresh LVM:
pvscan --cache
vgscan --mknodes
3. Verify Device Availability
Before adding to LVM, ensure the device is properly prepared:
# Check if device has existing signatures
pvdisplay /dev/sdb
# Wipe existing signatures if needed
wipefs -a /dev/sdb
If the issue persists, consider these additional checks:
# Check device major:minor numbers
ls -l /dev/sdb
# Verify device is not busy
lsof /dev/sdb
# Check kernel messages
dmesg | grep sdb
Here's a complete example of properly adding a device to a volume group:
# Prepare the physical device
pvcreate /dev/sdb
# Check for filters
grep filter /etc/lvm/lvm.conf
# Temporarily allow all devices if needed
vgextend --config 'devices { filter = [ "a|.*|" ] }' my_vg /dev/sdb
# Verify the extension
vgs
pvs
To avoid similar problems:
- Document your LVM filter configuration
- Test new devices with
pvdisplay
before adding to VGs - Consider using device UUIDs instead of paths in filters
- Maintain consistent filter policies across all systems
When working with LVM (Logical Volume Manager) on Linux systems, you might encounter this frustrating error during volume group extension:
vgextend my_vg /dev/sdb
Device /dev/sdb excluded by a filter
The root cause lies in LVM's device filtering system, which controls what physical devices are visible to LVM operations. By default, LVM scans all available block devices in /dev, but certain filters can exclude specific devices.
First, examine your current filter settings:
cat /etc/lvm/lvm.conf | grep filter
You'll typically see something like:
filter = [ "a|.*/|" ] # Accept all devices by default
# Or more restrictive filters like:
filter = [ "r|/dev/sd[a-c]|", "a|.*/|" ]
Filters use regular expressions with these prefixes:
a
- accept patternr
- reject pattern
Here are three ways to resolve this:
1. Temporary Workaround (Testing)
Override filters temporarily for testing:
lvdisplay --config 'devices { filter = [ "a|.*|" ] }'
vgextend --config 'devices { filter = [ "a|.*|" ] }' my_vg /dev/sdb
2. Permanent Solution
Edit /etc/lvm/lvm.conf:
# Backup first!
cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
# Then modify the filter line to include your device:
filter = [ "a|/dev/sdb|", "a|/dev/sd[a-z]|", "r|.*|" ]
3. Alternative Approach
If using device mapper paths instead:
ls -l /dev/mapper/
vgextend my_vg /dev/mapper/mpatha
After modifying filters, refresh LVM:
pvscan
vgscan
lvscan
For a system where /dev/sdb is a new SSD, but being filtered out:
# Check if device is visible to LVM:
pvs /dev/sdb
# If filtered, temporarily accept all:
vgextend --config 'devices { filter = [ "a|.*|" ] }' my_vg /dev/sdb
# Then make permanent change to lvm.conf:
filter = [ "a|/dev/sdb|", "a|/dev/sda[0-9]|", "r|.*|" ]
For deeper investigation:
lvmdump -m lvm.log
dmsetup table
lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT