LVM: Device /dev/sXXX excluded by a filter.

root's picture

This error, is normal if you want to add a disk or partition to LVM and was previously used.
For example, below I was trying to add /dev/sdb1 to LVM:

13:59:10 root@eeny:~# pvcreate /dev/sdb1
  Device /dev/sdb1 excluded by a filter.

When you see this, usually a disk wipe can fix it.
!!! WARNING - THIS WILL DESTROY YOUR DATA SO BE SURE YOU DO NOT NEED ANYTHING ON THIS DRIVE BEFORE EXECUTING THIS COMMAND !!!

14:03:07 root@eeny:~# wipefs -a /dev/sdb
/dev/sdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdb: 8 bytes were erased at offset 0x3a3817d5c00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdb: calling ioctl to re-read partition table: Success

I have recreated the partitions, executed pvcreate command and the same error:

14:06:09 root@eeny:~# pvcreate /dev/sdb1
  Device /dev/sdb1 excluded by a filter.

Time to dig in deeper so I ran pvcreate comand with "-vvv".
This command have a lot output so I have removed everything but what caught my attention:

14:08:00 root@eeny:~# pvcreate /dev/sdb1 -vvv
[...]
md filter full 1 excluding md component /dev/sdb1
[...]

Indeed, this disk has been used previously in a mdadm raid array but I thought wipefs command will remove this also. It turns out it does not.
So, I was stuck. Usually I dig more but I do not have always the time for it so what I did was a bit unconventional but it worked.
I have formated partition as btrfs, which specified I need to run it with "-f" because there is an existing filesystem as linux raid member, and then I added it to LVM.

4:35:26 root@eeny:~# mkfs.btrfs /dev/sdb1
btrfs-progs v4.20.1 
See http://btrfs.wiki.kernel.org for more information.

/dev/sdb1 appears to contain an existing filesystem (linux_raid_member).
ERROR: use the -f option to force overwrite of /dev/sdb1
14:35:34 root@eeny:~# mkfs.btrfs -f /dev/sdb1
btrfs-progs v4.20.1 
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               9694152c-b1b0-4010-8119-e885a3eadec4
Node size:          16384
Sector size:        4096
Filesystem size:    1000.00GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1  1000.00GiB  /dev/sdb1

14:35:48 root@eeny:~# pvcreate /dev/sdb1
WARNING: btrfs signature detected on /dev/sdb1 at offset 65600. Wipe it? [y/n]: y
  Wiping btrfs signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.

And success :)

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.