文件系统错误

Catalogue
  1. 1. EXT4-fs (sda2): I/0 error while writing superblock
  2. 2. pvcreate error : Can’t open /dev/sdb1 exclusively. Mounted filesystem?
  3. 3. Can’t remove volume group(LVM)
  4. 4. Device /dev/sdd excluded by a filter.(LVM)
  5. 5. Multiple VGs found with the same name: skipping bydata

EXT4-fs (sda2): I/0 error while writing superblock

用livecd挂载磁盘

1
2
sudo umount /dev/sda2
sudo fsck -f /dev/sda2

使用fsck修复文件系统错误

pvcreate error : Can’t open /dev/sdb1 exclusively. Mounted filesystem?

lvm分区,创建物理卷报错

1.这个分区可能被使用了

1
2
3
4
5
ll /dev/mapper/

看看分区被谁占了

使用dmsetup remove xxx,清除即可

2.它的实际原因是分区中已经存在分区表,导致pvcreate扫描出来已经存在分区表放弃新建了

1
2
3
4
使用
dd if=/dev/zero of=/dev/sdb bs=512K count=1

清除分区即可(慎用!!!)

Can’t remove volume group(LVM)

LVM: Device for PV zWRz3Q-rVbA-vM9f-n6q2-s2Oy-24i2-zKt6cO not found or rejected by a filter

(PV找不到了)

  1. 直接删除PV所属的VG

    1
    2
    3
    4
    5
    6
    vgreduce --removemissing --force VG 

    或者

    vgremove --force VG

    如果元数据区域为零则无法使用

    解决方法:从文件制作块设备并包含在 VG 中

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    dd if=/dev/zero of=/tmp/tmp.raw bs=1M count=100
    losetup -f
    losetup /dev/loop0 /tmp/tmp.raw
    vgextend $VG /dev/loop0

    After that I have Metadata Areas 1

    vgremove --force $VG

    and remove pvdevice

    pvremove /dev/loop0
  2. 删除丢失的PV

    vgreduce –removemissing $VG

Device /dev/sdd excluded by a filter.(LVM)

1
2
bash-4.2# pvremove -f /dev/sdd
Device /dev/sdd excluded by a filter.

意思是,在磁盘上找到旧分区表信息,可以使用“wipefs”清除旧分区信息。

1
2
3
4
5
bash-4.2# wipefs -a /dev/sdd
/dev/sdd:8 个字节已擦除,位置偏移为 0x00000218 (LVM2_member):4c 56 4d 32 20 30 30 31
/dev/sdd:8 个字节已擦除,位置偏移为 0xee77a55e00 (gpt):45 46 49 20 50 41 52 54
/dev/sdd:2 个字节已擦除,位置偏移为 0x000001fe (PMBR):55 aa
/dev/sdd: calling ioclt to re-read partition table: 成功

然后再执行别的操作

Multiple VGs found with the same name: skipping bydata

报错信息

1
2
3
4
5
6
7
8
9
[root@localhost /]# vgscan
Reading volume groups from cache.
Found volume group "bydata" using metadata type lvm2
Found volume group "bydata" using metadata type lvm2


[root@localhost /]# vgremove --force bydata
Multiple VGs found with the same name: skipping bydata
Use --select vg_uuid=<uuid> in place of the VG name.

两个VG名字一样,vgremove $VG不知道要删哪一个

解决方法

使用uuid指定删除

1
2
3
4
5
6
[root@localhost /]# pvs -o+vg_uuid
PV VG Fmt Attr PSize PFree VG UUID
/dev/nvme1n1 bydata lvm2 a-- 894.25g 872.25g qt4Vxd-3r6f-2KBf-x59W-jdsM-TkpC-9wdOL1
/dev/nvme7n1 bydata lvm2 a-- 894.25g 874.25g ec57To-Hw13-f32y-jxX1-kl3f-WJbU-jT4GFq

[root@localhost /]# vgremove -S vg_uuid=qt4Vxd-3r6f-2KBf-x59W-jdsM-TkpC-9wdOL1

也可以这么写

1
vgs -o+vg_uuid -S vg_name=$VG