关于LVM管理PVcreate过程中错误Device /dev/sdb not found (or ignored by filtering)

今天在做环境中一台机器磁盘扩容过程中出现此报错,第一次遇到,说一下情况:

1、我的机器中原本有一个LV 500G,作为nova节点的存储空间,空间不够,想扩容1T,浪潮服务器,加入两块1T磁盘,跟之前两个600G盘一样,做RAID1;(注:此动作需要重启服务器,要做追加,把新加的盘做raid,否则会对之前数据产生不利影响)

2、加入之后开机,发现sdb,执行fdisk,保存退出:

 

3、此时 fdisk -l 或lsblk 发现sdb1,执行partprobe,重新发现分区表;

4、做pv:执行pvcreate,然后报错Device /dev/sdb not found (or ignored by filtering)。

 

百度此报错,说法一:“这是由于挂了盘却没有格式化”,

亲测挂一块裸盘分区后不格式化,依旧能够执行pvcreate /dev/sdb1命令,可见这种说法并不能解决,在格式化之前执行pvcreate 命令并不会有问题(Centos7)。

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   30G  0 disk 
sr0              11:0    1 1024M  0 rom  

[root@localhost ~]# fdisk /dev/sdb 分区转换8e之后

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   30G  0 disk 
└─sdb1            8:17   0   30G  0 part 
sr0              11:0    1 1024M  0 rom  
[root@localhost ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

 

百度报错说法二:执行以下步骤可以解决。

实验后发现,这个也无法解决。

先执行:

1# dd if=/dev/urandom of=/dev/sdb bs=512 count=64

后再次执行

1# pvcreate /dev/sdb

dd if=/dev/urandom是提供永不为空的随机字节数据流,以上命令是把/dev/sdb覆盖分区块,也就是擦除分区,然并卵。

[root@localhost ~]# dd if=/dev/urandom of=/dev/sdb bs=512 count=64
记录了64+0 的读入
记录了64+0 的写出
32768字节(33 kB)已复制,0.015772 秒,2.1 MB/秒
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 19.5G  0 part 
  ├─centos-root 253:0    0 17.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   30G  0 disk 
sr0              11:0    1 1024M  0 rom  

 

百度说法三:按照错误说法,既然已经找到了/dev/sdb1,那肯定就是括号中的原因: ignored by filtering,实验发现确实如此。

解决方案:

(1)找到lvm配置文件:vim /etc/lvm/lvm.conf,搜索找到devices字段中filter

devices {


        # Configuration option devices/dir.
        # Directory in which to create volume group device nodes.
        # Commands also accept this as a prefix on volume group names.
        # This configuration option is advanced.
        dir = "/dev"


        # Configuration option devices/scan.
        # Directories containing device nodes to use with LVM.
        # This configuration option is advanced.
        scan = [ "/dev" ]

。。。。。。。。。。。。。。。。。。。。。。。

 # Accept every block device:
        # filter = [ "a|.*/|" ]
        # Reject the cdrom drive:
        # filter = [ "r|/dev/cdrom|" ]
        # Work with just loopback devices, e.g. for testing:
        # filter = [ "a|loop|", "r|.*|" ]
        # Accept all loop devices and ide drives except hdc:
        # filter = [ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ]
        # Use anchors to be very specific:
        # filter = [ "a|^/dev/hda8$|", "r|.*/|" ]
        #
        # This configuration option has an automatic default value.
        # filter = [ "a|.*/|" ]


        # Configuration option devices/global_filter.
        # Limit the block devices that are used by LVM system components.
        # Because devices/filter may be overridden from the command line, it is
        # not suitable for system-wide device filtering, e.g. udev and lvmetad.
        # Use global_filter to hide devices from these LVM system components.
        # The syntax is the same as devices/filter. Devices rejected by
        # global_filter are not opened by LVM.
        # This configuration option has an automatic default value.
    global_filter = [   "a|/dev/sda7|", "r|.*/|" ]

找到global_filter一行发现,此filter允许(a)/dev/sda7,拒绝(r)其他所有此目录下名称(如上,此目录为dir=/dev下),

bingo,问题就出在这里,/dev/sdb/在这里被过滤掉了,因此不搜索。

解决之道就出来了,在此行【】中添加:“a|sdb1|”,注意不能用/dev/sdb1,因为/dev/已经有了,就是上面说的dir=/dev/。

之后再执行pvcreate命令,通过,问题解决。

©️2020 CSDN 皮肤主题: 终极编程指南 设计师:CSDN官方博客 返回首页