unknow device
。 可能说的有点乱,但大概就是这么个意思。】[root@rhel ~]# fdisk -l /dev/vda
Disk /dev/vda: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe2ce4614Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
/dev/vda3 41943040 629145599 587202560 280G 8e Linux LVM
[root@rhel ~]#
[root@rhel ~]# pvsPV VG Fmt Attr PSize PFree/dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 rootvg lvm2 a-- <280.00g 0
[root@rhel ~]# vgsVG #PV #LV #SN Attr VSize VFreerootvg 2 2 0 wz--n- 298.99g 0
[root@rhel ~]#
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
/dev/vda3 41943040 109051903 67108864 32G 82 Linux swap / Solaris
/dev/vda4 109051904 629145599 520093696 248G 8e Linux LVMFilesystem/RAID signature on partition 3 will be wiped.Command (m for help): w
The partition table has been altered.
Syncing disks.# 可以看到现在显示还是处于异常状态,vda3已经不存在了。
[root@rhel ~]#
[root@rhel ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 300G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 297G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 32G 0 part
| `-rootvg-root 253:0 0 297G 0 lvm /
[unknown]
了,而且一直有报错。。。。[root@rhel ~]# pvsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to /dev/vda3).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.PV VG Fmt Attr PSize PFree/dev/vda2 rootvg lvm2 a-- <19.00g 0 [unknown] rootvg lvm2 a-m <280.00g 0
[root@rhel ~]# vgsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to /dev/vda3).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.VG #PV #LV #SN Attr VSize VFreerootvg 2 2 0 wz-pn- 298.99g 0
[root@rhel ~]#
[root@rhel ~]# vgextend rootvg /dev/vda4WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to /dev/vda3).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.Physical volume "/dev/vda4" successfully created.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to /dev/vda3).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.Volume group "rootvg" successfully extended
[root@rhel ~]# vgsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.VG #PV #LV #SN Attr VSize VFree rootvg 3 2 0 wz-pn- <546.99g <248.00g
[root@rhel ~]# pvsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 rootvg lvm2 a-- <248.00g <248.00g[unknown] rootvg lvm2 a-m <280.00g 0
[root@rhel ~]#
pvs命令的pv名称为[unknown]
,并且一直有一堆报错信息。
[root@rhel ~]# pvsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 rootvg lvm2 a-- <248.00g <248.00g[unknown] rootvg lvm2 a-m <280.00g 0
[root@rhel ~]#
[root@rhel ~]#
[root@rhel ~]# vgsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.VG #PV #LV #SN Attr VSize VFree rootvg 3 2
4.3.7. 从卷从 组中删除物理卷
要从卷组中删除未使用的物理卷, 请使用 vgreduce 命令。 vgreduce 命令通 过删除一个或多个空物理 卷来 缩小卷组的容量。 这样就可以使不同的卷组自由使用那些物理卷,或者将其从系统中删除。
在从卷组中删除物理卷前,您可以使用 pvdisplay 命令确定物理卷没有被任何 逻辑逻卷使用。
如果物理卷仍在使用,您必须使用使 pvmove 命令将数据迁移到 另一个物理卷。
然后使用 一 vgreduce 命 令删除物理卷。
以下命令将物理卷 以 /dev/hda1 从卷组 my_volume_group 中删除。 # vgreduce my_volume_group /dev/hda1
如果逻辑 卷包含失 败的物理卷,您就无法使用 该逻辑 卷。要从卷 组中删除缺少的物理卷,您可以使用 vgreduce 命令的 --remove mising 参数,如果缺少物理卷上没有分配 逻辑 卷。
如果物理卷包含 镜像片段 类型的 逻辑逻 卷的 镜像,您可以使用 像 vgreduce --removemissing – mirrorsonly --force 命令从 镜像中 删除该镜 像。 这样 只删除从物理卷中 镜像镜像的逻辑 卷。
[root@rhel ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 300G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 297G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 32G 0 part
| `-rootvg-root 253:0 0 297G 0 lvm /
`-vda4 252:4 0 248G 0 part
[root@rhel ~]## 看下面我接触占用的时候,提示有卷在使用中,可以使用--mirrorsonly --force参数强制删除
[root@rhel ~]# vgreduce --removemissing /dev/rootvgWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: Partial LV root needs to be repaired or removed. There are still partial LVs in VG rootvg.To remove them unconditionally use: vgreduce --removemissing --force.To remove them unconditionally from mirror LVs use: vgreduce --removemissing --mirrorsonly --force.WARNING: Proceeding to remove empty missing PVs.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.[root@rhel ~]## 强制修复,不行。[root@rhel ~]# vgreduce --removemissing --force rootvgWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: Removing partial LV rootvg/root.Logical volume rootvg/root contains a filesystem in use.
[root@rhel ~]#
[root@rhel ~]#
[root@rhel ~]# vgsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.VG #PV #LV #SN Attr VSize VFree rootvg 3 2 0 wz-pn- <546.99g <248.00g
[root@rhel ~]# # 另一种强制修复删除,依然不行。
[root@rhel ~]# vgreduce --removemissing --force /dev/rootvgWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.WARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: Removing partial LV rootvg/root.Logical volume rootvg/root contains a filesystem in use.
[root@rhel ~]# vgsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.VG #PV #LV #SN Attr VSize VFree rootvg 3 2 0 wz-pn- <546.99g <248.00g
[root@rhel ~]#
[root@rhel ~]# pvsWARNING: Couldn't find device with uuid BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw.WARNING: VG rootvg is missing PV BJDsFk-8faO-XonP-jvUI-wEmt-JXj0-YuJQfw (last written to [unknown]).WARNING: Couldn't find all devices for LV rootvg/root while checking used and assumed devices.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 rootvg lvm2 a-- <248.00g <248.00g[unknown] rootvg lvm2 a-m <280.00g 0
[root@rhel ~]#
Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'.Command (m for help): w
The partition table has been altered.
Syncing disks.
pa
[root@test-11 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
`-vda3 252:3 0 80G 0 part
[root@test-11 ~]#
[root@test-11 ~]# vgcreate vgtest /dev/vda3 Physical volume "/dev/vda3" successfully created.Volume group "vgtest" successfully created
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 1 0 0 wz--n- <80.00g <80.00g
[root@test-11 ~]# lvcreate -l 100%free -n lvtest vgtestLogical volume "lvtest" created.
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest vgtest -wi-a----- <80.00g
[root@test-11 ~]#
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
/dev/vda3 41943040 75497471 33554432 16G 83 Linux
/dev/vda4 75497472 209715199 134217728 64G 8e Linux LVMCommand (m for help): w
The partition table has been altered.
Syncing disks.[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
| `-vgtest-lvtest 253:2 0 80G 0 lvm
`-vda4 252:4 0 64G 0 part
[root@test-11 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@test-11 ~]#
[root@test-11 ~]# pvsWARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.PV VG Fmt Attr PSize PFree/dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <80.00g 0
[root@test-11 ~]#
[root@test-11 ~]#
[root@test-11 ~]# vgextend vgtest /dev/vda4WARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.Physical volume "/dev/vda4" successfully created.WARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.WARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?Volume group "vgtest" successfully extended
[root@test-11 ~]#
[root@test-11 ~]# pvsWARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <80.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g
[root@test-11 ~]# vgsWARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.VG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 2 1 0 wz--n- 143.99g <64.00g
[root@test-11 ~]#
[root@test-11 ~]# vgreduce --removemissing vgtest WARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.Volume group "vgtest" is already consistent.
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 64G 0 part
[root@test-11 ~]# pvsWARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <80.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 64G 0 part
[root@test-11 ~]# pvsWARNING: Device /dev/vda3 has size of 33554432 sectors which is smaller than corresponding PV size of 167772160 sectors. Was device resized?WARNING: One or more devices used as PVs in VG vgtest have changed sizes.PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <80.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g
[root@test-11 ~]#
vgreduce --removemissing vg_name
【如果失败,根据提示加个--force
即可】【不能有占用,有占用先umount再操作】# 恢复报错了,提示强制报错,心里一紧,心想不会凉了吧。
[root@test-11 ~]# vgreduce --removemissing vgtest WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.WARNING: VG vgtest is missing PV XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA (last written to /dev/vda3).WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.WARNING: Partial LV lvtest needs to be repaired or removed. There are still partial LVs in VG vgtest.To remove them unconditionally use: vgreduce --removemissing --force.To remove them unconditionally from mirror LVs use: vgreduce --removemissing --mirrorsonly --force.WARNING: Proceeding to remove empty missing PVs.WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.
[root@test-11 ~]#
[root@test-11 ~]# pvsWARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.WARNING: VG vgtest is missing PV XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA (last written to [unknown]).PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g[unknown] vgtest lvm2 a-m <80.00g 0
[root@test-11 ~]#
[root@test-11 ~]# # 加个强制 诶 成功了,问题解决。 注:这个vg下的lv也自动被删除了。
[root@test-11 ~]# vgreduce --removemissing --force vgtest WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.WARNING: VG vgtest is missing PV XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA (last written to [unknown]).WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.WARNING: Removing partial LV vgtest/lvtest.WARNING: Couldn't find device with uuid XvEHOY-p3Tp-6wbL-EPkc-cDIE-MUKv-r97PCA.Logical volume "lvtest" successfully removedWrote out consistent volume group vgtest.
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g
[root@test-11 ~]#
[root@test-11 ~]# lvcreate -l 100%free -n lvtest_1 vgtest
WARNING: xfs signature detected on /dev/vgtest/lvtest_1 at offset 0. Wipe it? [y/n]: yWiping xfs signature on /dev/vgtest/lvtest_1.Logical volume "lvtest_1" created.
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest_1 vgtest -wi-a----- <64.00g
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFreerootvg 1 2 0 wz--n- <19.00g 0 vgtest 1 1 0 wz--n- <64.00g 0
[root@test-11 ~]#
[root@test-11 ~]# mkfs.xfs /dev/vgtest/lvtest
meta-data=/dev/vgtest/lvtest isize=512 agcount=4, agsize=4194048 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=1, sparse=1, rmapbt=0= reflink=1
data = bsize=4096 blocks=16776192, imaxpct=25= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=8191, version=2= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@test-11 ~]# mkdir lvtest
[root@test-11 ~]# mount /dev/vgtest/lvtest /lvtest
mount: /lvtest: mount point does not exist.
[root@test-11 ~]#
[root@test-11 ~]# mount /dev/vgtest/lvtest lvtest
[root@test-11 ~]#
[root@test-11 ~]# cd lvtest
[root@test-11 lvtest]# touch test{1..50}
[root@test-11 lvtest]# ls
test1 test11 test13 test15 test17 test19 test20 test22 test24 test26 test28 test3 test31 test33 test35 test37 test39 test40 test42 test44 test46 test48 test5 test6 test8
test10 test12 test14 test16 test18 test2 test21 test23 test25 test27 test29 test30 test32 test34 test36 test38 test4 test41 test43 test45 test47 test49 test50 test7 test9
[root@test-11 lvtest]# cd
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 64G 0 part `-vgtest-lvtest 253:2 0 64G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFreerootvg 1 2 0 wz--n- <19.00g 0 vgtest 1 1 0 wz--n- <64.00g 0
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree/dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g 0
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest vgtest -wi-ao---- <64.00g
[root@test-11 ~]#
[root@test-11 ~]# vgextend vgtest /dev/vda3Physical volume "/dev/vda3" successfully created.Volume group "vgtest" successfully extended
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 2 1 0 wz--n- 79.99g <16.00g
[root@test-11 ~]#
[root@test-11 ~]# lvextend -l 100%free /dev/vgtest/lvtestNew size given (4095 extents) not larger than existing size (16383 extents)
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 64G 0 part `-vgtest-lvtest 253:2 0 64G 0 lvm /root/lvtest
[root@test-11 ~]# lvextend -L +15G /dev/vgtest/lvtest Size of logical volume vgtest/lvtest changed from <64.00 GiB (16383 extents) to <79.00 GiB (20223 extents).Logical volume vgtest/lvtest successfully resized.
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest vgtest -wi-ao---- <79.00g
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <16.00g 1020.00m/dev/vda4 vgtest lvm2 a-- <64.00g 0
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 19G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
| `-vgtest-lvtest 253:2 0 79G 0 lvm /root/lvtest
`-vda4 252:4 0 64G 0 part `-vgtest-lvtest 253:2 0 79G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# vgreduce vgtest /dev/vda3 Physical volume "/dev/vda3" still in use
[root@test-11 ~]#
[root@test-11 ~]# pvremove /dev/vda3PV /dev/vda3 is used by VG vgtest so please use vgreduce first.(If you are certain you need pvremove, then confirm by using --force twice.)/dev/vda3: physical volume label not removed.
[root@test-11 ~]# pvremove /dev/vda3 --forcePV /dev/vda3 is used by VG vgtest so please use vgreduce first.(If you are certain you need pvremove, then confirm by using --force twice.)/dev/vda3: physical volume label not removed.
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <16.00g 1020.00m/dev/vda4 vgtest lvm2 a-- <64.00g 0
[root@test-11 ~]# pvremove --force /dev/vda3 PV /dev/vda3 is used by VG vgtest so please use vgreduce first.(If you are certain you need pvremove, then confirm by using --force twice.)/dev/vda3: physical volume label not removed.
[root@test-11 ~]#
Command (m for help): p
Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe2ce4614Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 41943039 39843840 19G 8e Linux LVM
/dev/vda4 75497472 209715199 134217728 64G 8e Linux LVMCommand (m for help): w
The partition table has been altered.
Syncing disks.[root@test-11 ~]#
[root@test-11 ~]#
[root@test-11 ~]# partprobe /dev/vda
Error: Partition(s) 3 on /dev/vda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.
[root@test-11 ~]#
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 vgtest lvm2 a-- <16.00g 1020.00m/dev/vda4 vgtest lvm2 a-- <64.00g 0
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 2 1 0 wz--n- 79.99g 1020.00m
[root@test-11 ~]#
[root@test-11 ~]# reboot
[root@test-11 ~]# pvsWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to /dev/vda3).PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g 0 [unknown] vgtest lvm2 a-m <16.00g 1020.00m
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 35G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
`-vda4 252:4 0 64G 0 part
[root@test-11 ~]#
[root@test-11 ~]# pvsWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to /dev/vda3).PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g 0 [unknown] vgtest lvm2 a-m <16.00g 1020.00m
[root@test-11 ~]#
[root@test-11 ~]# vgsWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to /dev/vda3).VG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 2 1 0 wz-pn- 79.99g 1020.00m
[root@test-11 ~]# lvsWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to /dev/vda3).LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest vgtest -wi-----p- <79.00g
[root@test-11 ~]#
[root@test-11 ~]# vgreduce --removemissing vgtestWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to /dev/vda3).WARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: Partial LV lvtest needs to be repaired or removed. There are still partial LVs in VG vgtest.To remove them unconditionally use: vgreduce --removemissing --force.To remove them unconditionally from mirror LVs use: vgreduce --removemissing --mirrorsonly --force.WARNING: Proceeding to remove empty missing PVs.WARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.
[root@test-11 ~]# vgreduce --removemissing vgtest --forceWARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: VG vgtest is missing PV FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp (last written to [unknown]).WARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.WARNING: Removing partial LV vgtest/lvtest.WARNING: Couldn't find device with uuid FA5IJi-Hc5y-9rrS-lTwK-YeI1-MvBU-7K04gp.Logical volume "lvtest" successfully removedWrote out consistent volume group vgtest.
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 1 0 0 wz--n- <64.00g <64.00g
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <64.00g <64.00g
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g
[root@test-11 ~]#
[root@test-11 ~]#
[root@test-11 ~]# lvcreate -l 100%free -n lvtest_1 vgtestLogical volume "lvtest_1" created.
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest_1 vgtest -wi-a----- <48.00g
[root@test-11 ~]# mkfs.xfs /dev/vgtest/lvtest_1
meta-data=/dev/vgtest/lvtest_1 isize=512 agcount=4, agsize=3145472 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=1, sparse=1, rmapbt=0= reflink=1
data = bsize=4096 blocks=12581888, imaxpct=25= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=6143, version=2= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@test-11 ~]# mount /dev/vgtest/lvtest_1 lvtest
[root@test-11 ~]# touch lvtest/test{1..50}
[root@test-11 ~]# ls lvtest/
test1 test11 test13 test15 test17 test19 test20 test22 test24 test26 test28 test3 test31 test33 test35 test37 test39 test40 test42 test44 test46 test48 test5 test6 test8
test10 test12 test14 test16 test18 test2 test21 test23 test25 test27 test29 test30 test32 test34 test36 test38 test4 test41 test43 test45 test47 test49 test50 test7 test9
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 35G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 48G 0 part `-vgtest-lvtest_1 253:2 0 48G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# vgextend vgtest /dev/vda3Physical volume "/dev/vda3" successfully created.Volume group "vgtest" successfully extended
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- <19.00g 0 vgtest 2 1 0 wz--n- 63.99g <16.00g
[root@test-11 ~]# lvcreate -l 100%free -n lvtest_2 vgtest
WARNING: xfs signature detected on /dev/vgtest/lvtest_2 at offset 0. Wipe it? [y/n]: yWiping xfs signature on /dev/vgtest/lvtest_2.Logical volume "lvtest_2" created.
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest_1 vgtest -wi-ao---- <48.00g lvtest_2 vgtest -wi-a----- <16.00g
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 35G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
| `-vgtest-lvtest_2 253:3 0 16G 0 lvm
`-vda4 252:4 0 48G 0 part `-vgtest-lvtest_1 253:2 0 48G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 35G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
| `-vgtest-lvtest_2 253:3 0 16G 0 lvm
`-vda4 252:4 0 48G 0 part `-vgtest-lvtest_1 253:2 0 48G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# lvremove /dev/vgtest/lvtest_2
Do you really want to remove active logical volume vgtest/lvtest_2? [y/n]: yLogical volume "lvtest_2" successfully removed
[root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest_1 vgtest -wi-ao---- <48.00g
[root@test-11 ~]#
[root@test-11 ~]# vgreduce vgtest /dev/vda3Removed "/dev/vda3" from volume group "vgtest"
[root@test-11 ~]#
[root@test-11 ~]# vgsVG #PV #LV #SN Attr VSize VFreerootvg 1 2 0 wz--n- <19.00g 0 vgtest 1 1 0 wz--n- <48.00g 0
[root@test-11 ~]#
[root@test-11 ~]# pvs PV VG Fmt Attr PSize PFree /dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda3 lvm2 --- 16.00g 16.00g/dev/vda4 vgtest lvm2 a-- <48.00g 0
[root@test-11 ~]#
[root@test-11 ~]# pvremove /dev/vda3Labels on physical volume "/dev/vda3" successfully wiped.
[root@test-11 ~]# pvsPV VG Fmt Attr PSize PFree/dev/vda2 rootvg lvm2 a-- <19.00g 0 /dev/vda4 vgtest lvm2 a-- <48.00g 0
[root@test-11 ~]#
[root@test-11 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 478K 0 rom
vda 252:0 0 100G 0 disk
|-vda1 252:1 0 1G 0 part /boot
|-vda2 252:2 0 35G 0 part
| |-rootvg-root 253:0 0 17G 0 lvm /
| `-rootvg-swap 253:1 0 2G 0 lvm [SWAP]
|-vda3 252:3 0 16G 0 part
`-vda4 252:4 0 48G 0 part `-vgtest-lvtest_1 253:2 0 48G 0 lvm /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 893M 0 893M 0% /dev
tmpfs tmpfs 910M 0 910M 0% /dev/shm
tmpfs tmpfs 910M 8.5M 901M 1% /run
tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/rootvg-root xfs 17G 1.8G 16G 11% /
/dev/vda1 xfs 1014M 229M 786M 23% /boot
tmpfs tmpfs 182M 0 182M 0% /run/user/0
/dev/mapper/vgtest-lvtest_1 xfs 48G 375M 48G 1% /root/lvtest
[root@test-11 ~]#
[root@test-11 ~]# cd lvtest/
[root@test-11 lvtest]# ls
test1 test11 test13 test15 test17 test19 test20 test22 test24 test26 test28 test3 test31 test33 test35 test37 test39 test40 test42 test44 test46 test48 test5 test6 test8
test10 test12 test14 test16 test18 test2 test21 test23 test25 test27 test29 test30 test32 test34 test36 test38 test4 test41 test43 test45 test47 test49 test50 test7 test9
[root@test-11 lvtest]#
[root@test-11 lvtest]# reboot [root@test-11 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rootvg -wi-ao---- <17.00g swap rootvg -wi-ao---- 2.00g lvtest_1 vgtest -wi-a----- <48.00g
[root@test-11 ~]# mount /dev/vgtest/lvtest_1 lvtest/
[root@test-11 ~]# cd lvtest/
[root@test-11 lvtest]# ls
test1 test11 test13 test15 test17 test19 test20 test22 test24 test26 test28 test3 test31 test33 test35 test37 test39 test40 test42 test44 test46 test48 test5 test6 test8
test10 test12 test14 test16 test18 test2 test21 test23 test25 test27 test29 test30 test32 test34 test36 test38 test4 test41 test43 test45 test47 test49 test50 test7 test9
[root@test-11 lvtest]#
奇葩问题 一个盘空间有299G,vg添加后只能识别到19G【也不能重复添加】
fdisk看到的也是299G
4.2.4. 重新定 义物理卷大小
如果您需要出于某种原因更改基 础块设备 的大小, 请使用使 pvresize 命令更新新大小的 VM。您可以在 LVM 正在使用物理卷 时执行这个命令。
pvresize /dev/vda2
【因为我vda2显示异常了】
上一篇:基于Redis实现的分布式锁
下一篇:链式前向星介绍以及原理