首页 > 其他分享 >lvm之vg缩容

lvm之vg缩容

时间:2023-01-11 15:33:41浏览次数:43  
标签:缩容 --- vg dev volume PE lvm vg0 Physical

lvm技术主要用于系统盘,一般不会进行vg缩容操作,

但也不排除有例外情况,这种时候需要咋操作?

注:严重怀疑市面上某些不愿让人看到底层操作系统的存储设备,其底层运用的就是类似的技术,或者压根儿就是lvm2。

 

移除不是用pvremove命令直接移除就行,因为要移除的硬盘上很有可能有数据存在,所以移除前需要把硬盘上的数据转移到其他硬盘,转移成功后在移除。步骤如下:

1,先查看硬盘上是否有PE被用
-------------------------------------------------------------------------
root@debian:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 vg0 lvm2 a-- 2.00g 1020.00m
/dev/sdb2 vg0 lvm2 a-- 3.00g 0 #/dev/sdb上有2个分区都存在PE,因为PFree小于PSize
/dev/sdc vg0 lvm2 a-- 5.00g 4.99g

root@debian:~# pvdisplay -m      #更直观的查看
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size 2.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 511
Free PE 255
Allocated PE 256          #以用PE数
PV UUID Q9L0el-2PXV-bLy4-eVck-MsWm-1bBL-ODGByA

--- Physical Segments ---
Physical extent 0 to 255:
Logical volume /dev/vg0/lvol0      #PV被lvol0占用一部份
Logical extents 0 to 255
Physical extent 256 to 510:
FREE

--- Physical volume ---
PV Name /dev/sdb2
VG Name vg0
PV Size 3.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 767
Free PE 0
Allocated PE 767         #以用PE数
PV UUID zMP4oN-GbB2-h2Xg-Ksxi-KM94-hesj-s3s3FA

--- Physical Segments ---
Physical extent 0 to 255:
Logical volume /dev/vg0/lv0      #PV被lv0占用一部份
Logical extents 0 to 255
Physical extent 256 to 511:
Logical volume /dev/vg0/lv1      #PV被lv1占用一部份
Logical extents 0 to 255
Physical extent 512 to 766:
Logical volume /dev/vg0/lv0      #PV被lv0占用一部份
Logical extents 256 to 510

--- Physical volume ---
PV Name /dev/sdc
VG Name vg0
PV Size 5.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1279
Free PE 1278        #可用PE数
Allocated PE 1
PV UUID sApAs0-0s6C-02Tb-Y70L-PDkZ-ZxRG-o4zaJK

--- Physical Segments ---
Physical extent 0 to 513:
FREE
Physical extent 514 to 514:
Logical volume /dev/vg0/lv0
Logical extents 511 to 511
Physical extent 515 to 1278:
FREE

root@debian:~#
-------------------------------------------------------------------------
通过pvdisplay -m 命令可以更直观的查看PE的使用情况, /dev/sdb硬盘两个分区一共被占用了256+767=1023个PE,而/dev/sdc有1278个可用的PE,同时三个PV在同一个
卷组vg0中,所以我们可以通过命令pvmove把物理卷/dev/sdb1和/dev/sdb2中的PE转移到同卷组中的/dev/sdc物理卷中,如果物理卷中没有剩余PE请添加PV扩充PE。


2,通过命令pvmove把物理卷中的PE转移到同卷组中其他的物理卷中
-------------------------------------------------------------------------
root@debian:~# pvmove /dev/sdb1 /dev/sdc           #将/dev/sdb1中以用的PE转移到 /dev/sdc中
/dev/sdb1: Moved: 16.41%
root@debian:~# pvmove -v /dev/sdb2 /dev/sdc       #将/dev/sdb2中以用的PE转移到 /dev/sdc中,同时显示详细过程
Cluster mirror log daemon is not running.
Wiping internal VG cache
Wiping cache of LVM-capable devices
Archiving volume group "vg0" metadata (seqno 53).
Creating logical volume pvmove0
Moving 511 extents of logical volume vg0/lv0
Moving 256 extents of logical volume vg0/lv1
activation/volume_list configuration setting not defined: Checking only host tags for vg0/lv0.
activation/volume_list configuration setting not defined: Checking only host tags for vg0/lv1.
Setting up pvmove in on-disk volume group metadata.
Creating vg0-pvmove0
Loading vg0-pvmove0 table (254:3)
Loading vg0-lv0 table (254:1)
Loading vg0-lv1 table (254:2)
Suspending vg0-lv0 (254:1) with device flush
Suspending vg0-lv1 (254:2) with device flush
activation/volume_list configuration setting not defined: Checking only host tags for vg0/pvmove0.
Resuming vg0-pvmove0 (254:3)
Loading vg0-pvmove0 table (254:3)
Suppressed vg0-pvmove0 (254:3) identical table reload.
Resuming vg0-lv0 (254:1)
Resuming vg0-lv1 (254:2)
Creating volume group backup "/etc/lvm/backup/vg0" (seqno 54).
Checking progress before waiting every 15 seconds.
/dev/sdb2: Moved: 1.30%
/dev/sdb2: Moved: 33.38%
/dev/sdb2: Moved: 66.62%
/dev/sdb2: Moved: 100.00%
Polling finished successfully.

root@debian:~# pvdisplay -m
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size 2.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 511
Free PE 511
Allocated PE 0            #/dev/sdb1中没有占用的PE,转移成功
PV UUID Q9L0el-2PXV-bLy4-eVck-MsWm-1bBL-ODGByA

--- Physical Segments ---
Physical extent 0 to 510:
FREE

--- Physical volume ---
PV Name /dev/sdb2
VG Name vg0
PV Size 3.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 767
Free PE 767
Allocated PE 0            #/dev/sdb2中没有占用的PE,转移成功
PV UUID zMP4oN-GbB2-h2Xg-Ksxi-KM94-hesj-s3s3FA

--- Physical Segments ---
Physical extent 0 to 766:
FREE

--- Physical volume ---
PV Name /dev/sdc
VG Name vg0
PV Size 5.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1279
Free PE 255
Allocated PE 1024
PV UUID sApAs0-0s6C-02Tb-Y70L-PDkZ-ZxRG-o4zaJK

--- Physical Segments ---        #全部转移到/dev/sdc 中
Physical extent 0 to 255:
Logical volume /dev/vg0/lv0
Logical extents 0 to 255
Physical extent 256 to 511:
Logical volume /dev/vg0/lv1
Logical extents 0 to 255
Physical extent 512 to 513:
FREE
Physical extent 514 to 514:
Logical volume /dev/vg0/lv0
Logical extents 511 to 511
Physical extent 515 to 770:
Logical volume /dev/vg0/lvol0
Logical extents 0 to 255
Physical extent 771 to 1025:
Logical volume /dev/vg0/lv0
Logical extents 256 to 510
Physical extent 1026 to 1278:
FREE

root@debian:~#

-------------------------------------------------------------------------

 

3,通过命令vgreduce 删除卷组中的物理卷
-------------------------------------------------------------------------
root@debian:~# vgreduce vg0 /dev/sdb1 /dev/sdb2      #删除卷组中的2个物理卷
Removed "/dev/sdb1" from volume group "vg0"
Removed "/dev/sdb2" from volume group "vg0"

root@debian:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 --- 2.00g 2.00g                #删除成功
/dev/sdb2 lvm2 --- 3.00g 3.00g
/dev/sdc vg0 lvm2 a-- 5.00g 1020.00m
root@debian:~#
-------------------------------------------------------------------------

4,通过命令pvremove删除物理卷
-------------------------------------------------------------------------
root@debian:~# pvremove /dev/sdb1 /dev/sdb2         #删除连个物理卷
Labels on physical volume "/dev/sdb1" successfully wiped.
Labels on physical volume "/dev/sdb2" successfully wiped.
-------------------------------------------------------------------------
root@debian:~# pvs
PV VG Fmt Attr PSize PFree            #删除成功
/dev/sdc vg0 lvm2 a-- 5.00g 1020.00m
root@debian:~#

标签:缩容,---,vg,dev,volume,PE,lvm,vg0,Physical
From: https://www.cnblogs.com/santia-god/p/17043904.html

相关文章

  • LLVM 指令与lowering代码结构
    LLVM指令与lowering代码结构LLVM 是一个很复杂的软件,了解LLVM的工作原理不是很容易,然而,对于刚开始接触LLVM整个框架的工作原理来说,详细而深入,不如广泛而浅显,所以有......
  • 04-VGG16 图像分类
       图1VGG的网络结构  图2VGG16的网络 VGG网络结构的理解,参考:https://blog.csdn.net/Keep_Trying_Go/article/details/123943751Cifar10的vgg16网络pyto......
  • 逻辑卷LVM
    lvm创建流程:作用:1、很容易实现分区的扩容和缩容2、磁盘可以是分区也可以是整个硬盘,空间大小也可以不一样lvm实现过程第一步:将分区或者硬盘指定为物理卷(pvcreate)......
  • LLVM TableGen杂谈
    LLVMTableGen杂谈1.什么是tablegen tablegen是llvm用于开发和维护编译器中公共特性的条目(e.g.指令描述,寄存器描述)的代码,使之灵活的描述与构造的自动化工具.......
  • lvm卷
    物理卷(PhysicalVolume,PV):就是真正的物理硬盘或分区。卷组(VolumeGroup,VG):将多个物理卷合起来就组成了卷组。组成同一个卷组的物理卷可以是同一块硬盘的不同分区,也可以是不......
  • SVG click event Designs
    <!doctypehtml><html><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,u......
  • linux如何在没有做lvm情况下在线扩容磁盘(仅限于虚拟机,可以直接扩容磁盘的那种)
    前言当我们工作中难免会出现磁盘需要扩容的情况,如果生产环境的磁盘当初做了lvm那对于扩容磁盘那一定很简单,但是我们难免会遇到一种情况,那就是当时这个主机的磁盘我们并没......
  • LLVM IR 代码生成与解析器、抽象语法树
    LLVMIR代码生成与解析器、抽象语法树概述将基于词法分析器,为Kaleidoscope构建一个完整的解析器(Parser)。通过解析器,我们可以定义并构造抽象语法树(AbstractSyntaxTre......
  • Centos7下非lvm的分区扩容(重要)
    前言:一般在生产环境中,如果需要使用一个分区保存大量的文件,建议的做法是在虚拟化环境中增加一块单独的硬盘,挂载一个单独的分区,比如/data上图我们可以看到sdb整块硬盘 ......
  • LLVM IR与C++ MUL函数代码
    LLVMIR与C++MUL函数代码使用LLVMIR写程序熟悉LLVMIR最好的办法就是使用IR写几个程序。在开始写之前,建议先花30分钟-1个小时再粗略阅读下官方手册(https://llvm.org/do......